AMPL var bs param

7 views
Skip to first unread message

khan

unread,
Mar 22, 2018, 7:03:16 PM3/22/18
to AMPL Modeling Language
I have a variable in my program that is also present in the Objective function as:

var Pall{i in 1..n} > 0;
minimize one: sum{i in 1..n} I[i]*Pall[i];

This is how I get random values of Pall. So i wanted to have equal values of Pall. So I try to define Pall as

var Pall{i in 1..n} = Pmax/n;
where Pmax/n is constant.

But when I define like this it say by pointing the same line no where this variable has been defined:
Caution: Pall should be "param =" rather than "var =".
File: revising.mod, Line: 39, Offset: 1107.

CPLEX 12.8.0.0: infeasible problem.


What should I do?
If I define it as a param, there are no more variables in my program and it assings values to Pall as defined.







AMPL Google Group

unread,
Mar 23, 2018, 1:51:13 PM3/23/18
to am...@googlegroups.com
Do you mean the optimizer should produce the same value for all Pall? In that case, why do you need to define a list of variable? Can't you define just a variable like var Pall;? On the other hand, if you want to give initial value to variable, then you could do using let command before sending the solve to ampl. So, you will do something like
let { i in 1..n} Pall[i] := Pmax/n;

--
Paras Tiwari
am...@googlegroups.com
{#HS:546768486-3441#}
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



Reply all
Reply to author
Forward
0 new messages