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
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
add a comment |
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
add a comment |
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
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
ampl
asked Mar 25 at 16:34
ReinderienReinderien
6,2242 gold badges31 silver badges58 bronze badges
6,2242 gold badges31 silver badges58 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
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
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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