--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to am...@googlegroups.com.
To unsubscribe from this group, send email to ampl+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ampl?hl=en.
To improve performance you really do need to look at the "mipdisplay=2"
output. When the "gap" stays large and the "nodes left" grows steadily,
then chances are that CPLEX (or any similar solver) will take a very long
time. If you know a feasible solution that gives a much better objective
value than what appears in the "best integer" column, then setting the
variables to this solution before solving may be helpful. In particular if
nothing appears under "best integer" then CPLEX was unable to find a
feasible solution and you could definitely help things out by supplying one.
(But if you can't find a feasible solution either then it's possible that
none exists.)
Bob Fourer
4...@ampl.com
var Buy {j in FOOD} >= f_min[j], <= f_max[j],
:= (f_min[j] + f_max[j]) / 2;
(Be sure to use ":=", as "=" will permanently define the variable to equal
the expression.) You can also make any number of assignments of initial
values using "let" statements:
let {j in FOOD} Buy[j] := (f_min[j] + f_max[j]) / 2;
let Buy['FISH'] := 3;
You can also assign initial values as data just as you do for parameters:
var Buy := BEEF 1 CHK 2 FISH 3 HAM 3 MCH 5 MTL 4 SPG 4 TUR 1 ;
Any of the formats that work for parameters will also work for variables.
If you assign values to variables in more than one way, the last values
assigned before the "solve;" are the ones that the solver receives.