Initialize a two-dimensional array from literalsSetting an initial in solution in MathProgHow to add arrays of array in CPLEX AMPLAMPL: Solver cannot evaluate NLP objective (and/or constraint) at initial solutionVariable created from another variable in AMPLAMPL, selecting data from two setsInitialize 3 dimension variable in AMPLGet length from item setReading .sol files from RAMPL - param that maps from set to setHow can I define an array filled with a single value in AMPL

What does 'in attendance' mean on an England death certificate?

Why did the Apple IIe make a hideous noise if you inserted the disk upside down?

Understanding the as-if rule, "the program was executed as written"

Why do movie directors use brown tint on Mexico cities?

Processes in a session in an interactive shell vs in a script

Does "boire un jus" tend to mean "coffee" or "juice of fruit"?

Is this house-rule removing the increased effect of cantrips at higher character levels balanced?

My mom helped me cosign a car and now she wants to take it

iMac 2019: Can I mix the old modules with the new ones when upgrading RAM?

Could you fall off a planet if it was being accelerated by engines?

Robots in a spaceship

What was the first science fiction or fantasy multiple choice book?

How to track mail undetectably?

"nunca" placement after a verb with "no"

Why didn't Caesar move against Sextus Pompey immediately after Munda?

How useful would a hydroelectric power plant be in the post-apocalypse world?

Why is my 401k manager recommending me to save more?

Negative Voltage creating Sinking Terminal

Angle Between Two Vectors Facing A Point

ATMEGA328P-U vs ATMEGA328-PU

How to count the number of bytes in a file, grouping the same bytes?

Why isn't UDP with reliability (implemented at Application layer) a substitute of TCP?

tikz: draw multicolor curve with smooth gradient

How can this fractal shape perfectly cover a certain platonic solid?



Initialize a two-dimensional array from literals


Setting an initial in solution in MathProgHow to add arrays of array in CPLEX AMPLAMPL: Solver cannot evaluate NLP objective (and/or constraint) at initial solutionVariable created from another variable in AMPLAMPL, selecting data from two setsInitialize 3 dimension variable in AMPLGet length from item setReading .sol files from RAMPL - param that maps from set to setHow can I define an array filled with a single value in AMPL













0















I have this data file:



param: name car pro fat vit cal :=
1 'Fiddleheads' 3 1 0 3 80
2 'Fireweed Shoots' 3 0 0 4 150
3 'Prickly Pear Fruit' 2 1 1 3 190
;


and this model:



set I;
set J;

param nameI symbolic;

param carI integer >= 0;
param proI integer >= 0;
param fatI integer >= 0;
param vitI integer >= 0;
param calI integer >= 0;
param nuti in I, J = (car[i], pro[i], fat[i], vit[i]);


The last line is invalid:



mod, line 10 (offset 176):
syntax error
context: param nuti in I, J = >>> (car[i], <<< pro[i], fat[i], vit[i]);


but I don't know how to get an equivalent working. Essentially, I want to form a 3,4 array based on a literal expression. I've tried a handful of different syntaxes both in the data and model file and haven't been able to get any working.










share|improve this question


























    0















    I have this data file:



    param: name car pro fat vit cal :=
    1 'Fiddleheads' 3 1 0 3 80
    2 'Fireweed Shoots' 3 0 0 4 150
    3 'Prickly Pear Fruit' 2 1 1 3 190
    ;


    and this model:



    set I;
    set J;

    param nameI symbolic;

    param carI integer >= 0;
    param proI integer >= 0;
    param fatI integer >= 0;
    param vitI integer >= 0;
    param calI integer >= 0;
    param nuti in I, J = (car[i], pro[i], fat[i], vit[i]);


    The last line is invalid:



    mod, line 10 (offset 176):
    syntax error
    context: param nuti in I, J = >>> (car[i], <<< pro[i], fat[i], vit[i]);


    but I don't know how to get an equivalent working. Essentially, I want to form a 3,4 array based on a literal expression. I've tried a handful of different syntaxes both in the data and model file and haven't been able to get any working.










    share|improve this question
























      0












      0








      0








      I have this data file:



      param: name car pro fat vit cal :=
      1 'Fiddleheads' 3 1 0 3 80
      2 'Fireweed Shoots' 3 0 0 4 150
      3 'Prickly Pear Fruit' 2 1 1 3 190
      ;


      and this model:



      set I;
      set J;

      param nameI symbolic;

      param carI integer >= 0;
      param proI integer >= 0;
      param fatI integer >= 0;
      param vitI integer >= 0;
      param calI integer >= 0;
      param nuti in I, J = (car[i], pro[i], fat[i], vit[i]);


      The last line is invalid:



      mod, line 10 (offset 176):
      syntax error
      context: param nuti in I, J = >>> (car[i], <<< pro[i], fat[i], vit[i]);


      but I don't know how to get an equivalent working. Essentially, I want to form a 3,4 array based on a literal expression. I've tried a handful of different syntaxes both in the data and model file and haven't been able to get any working.










      share|improve this question














      I have this data file:



      param: name car pro fat vit cal :=
      1 'Fiddleheads' 3 1 0 3 80
      2 'Fireweed Shoots' 3 0 0 4 150
      3 'Prickly Pear Fruit' 2 1 1 3 190
      ;


      and this model:



      set I;
      set J;

      param nameI symbolic;

      param carI integer >= 0;
      param proI integer >= 0;
      param fatI integer >= 0;
      param vitI integer >= 0;
      param calI integer >= 0;
      param nuti in I, J = (car[i], pro[i], fat[i], vit[i]);


      The last line is invalid:



      mod, line 10 (offset 176):
      syntax error
      context: param nuti in I, J = >>> (car[i], <<< pro[i], fat[i], vit[i]);


      but I don't know how to get an equivalent working. Essentially, I want to form a 3,4 array based on a literal expression. I've tried a handful of different syntaxes both in the data and model file and haven't been able to get any working.







      ampl






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 16:34









      ReinderienReinderien

      6,2242 gold badges31 silver badges58 bronze badges




      6,2242 gold badges31 silver badges58 bronze badges




















          1 Answer
          1






          active

          oldest

          votes


















          1














          Model:



          set names;
          set components;
          param nutnames,components default 0;


          Data:



          set names := 
          Fiddleheads
          'Fireweed Shoots'
          'Prickly Pear Fruit';

          set components := car pro fat vit cal
          ;

          param nut :=
          [Fiddleheads,*]
          car 3 pro 1 vit 3 cal 80
          ['Fireweed Shoots',*]
          car 3 vit 4 cal 150
          ['Prickly Pear Fruit',*]
          car 2 pro 1 fat 1 vit 3 cal 190
          ;


          See Chapter 9 of the AMPL Book for variants.



          The "default 0" option avoids the need to explicitly list zero values, which can be useful for sparse data sets.



          It would be useful to have an AMPL input format that allows a 2-D parameter to be specified in a simple table layout with row and column headers, along the lines of your data step, but I'm not aware of one that does this.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55342463%2finitialize-a-two-dimensional-array-from-literals%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Model:



            set names;
            set components;
            param nutnames,components default 0;


            Data:



            set names := 
            Fiddleheads
            'Fireweed Shoots'
            'Prickly Pear Fruit';

            set components := car pro fat vit cal
            ;

            param nut :=
            [Fiddleheads,*]
            car 3 pro 1 vit 3 cal 80
            ['Fireweed Shoots',*]
            car 3 vit 4 cal 150
            ['Prickly Pear Fruit',*]
            car 2 pro 1 fat 1 vit 3 cal 190
            ;


            See Chapter 9 of the AMPL Book for variants.



            The "default 0" option avoids the need to explicitly list zero values, which can be useful for sparse data sets.



            It would be useful to have an AMPL input format that allows a 2-D parameter to be specified in a simple table layout with row and column headers, along the lines of your data step, but I'm not aware of one that does this.






            share|improve this answer



























              1














              Model:



              set names;
              set components;
              param nutnames,components default 0;


              Data:



              set names := 
              Fiddleheads
              'Fireweed Shoots'
              'Prickly Pear Fruit';

              set components := car pro fat vit cal
              ;

              param nut :=
              [Fiddleheads,*]
              car 3 pro 1 vit 3 cal 80
              ['Fireweed Shoots',*]
              car 3 vit 4 cal 150
              ['Prickly Pear Fruit',*]
              car 2 pro 1 fat 1 vit 3 cal 190
              ;


              See Chapter 9 of the AMPL Book for variants.



              The "default 0" option avoids the need to explicitly list zero values, which can be useful for sparse data sets.



              It would be useful to have an AMPL input format that allows a 2-D parameter to be specified in a simple table layout with row and column headers, along the lines of your data step, but I'm not aware of one that does this.






              share|improve this answer

























                1












                1








                1







                Model:



                set names;
                set components;
                param nutnames,components default 0;


                Data:



                set names := 
                Fiddleheads
                'Fireweed Shoots'
                'Prickly Pear Fruit';

                set components := car pro fat vit cal
                ;

                param nut :=
                [Fiddleheads,*]
                car 3 pro 1 vit 3 cal 80
                ['Fireweed Shoots',*]
                car 3 vit 4 cal 150
                ['Prickly Pear Fruit',*]
                car 2 pro 1 fat 1 vit 3 cal 190
                ;


                See Chapter 9 of the AMPL Book for variants.



                The "default 0" option avoids the need to explicitly list zero values, which can be useful for sparse data sets.



                It would be useful to have an AMPL input format that allows a 2-D parameter to be specified in a simple table layout with row and column headers, along the lines of your data step, but I'm not aware of one that does this.






                share|improve this answer













                Model:



                set names;
                set components;
                param nutnames,components default 0;


                Data:



                set names := 
                Fiddleheads
                'Fireweed Shoots'
                'Prickly Pear Fruit';

                set components := car pro fat vit cal
                ;

                param nut :=
                [Fiddleheads,*]
                car 3 pro 1 vit 3 cal 80
                ['Fireweed Shoots',*]
                car 3 vit 4 cal 150
                ['Prickly Pear Fruit',*]
                car 2 pro 1 fat 1 vit 3 cal 190
                ;


                See Chapter 9 of the AMPL Book for variants.



                The "default 0" option avoids the need to explicitly list zero values, which can be useful for sparse data sets.



                It would be useful to have an AMPL input format that allows a 2-D parameter to be specified in a simple table layout with row and column headers, along the lines of your data step, but I'm not aware of one that does this.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 27 at 0:37









                Geoffrey BrentGeoffrey Brent

                1,0051 gold badge8 silver badges10 bronze badges




                1,0051 gold badge8 silver badges10 bronze badges
















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55342463%2finitialize-a-two-dimensional-array-from-literals%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현