I want to state multiple objectives in AMPL + Gurobi. Below is the snipped from .mod file -
# sets and parameter declarations
....
param vns > 0 ;
set VANS = 0 .. vns - 1;
suffix objpriority >= 0 integer;
# decision variables
....
# constraints
....
# objective functions
minimize max_time_limit:
s ;
minimize number_of_vans_used:
sum {k in VANS} z[k] ;
let max_time_limit.objpriority := 1 ;
let number_of_vans_used.objpriority := 2 ;
when I run the .mod file, I get a weird error
error processing set VANS:
no value for vns
Interestingly, when I run optimisation model with single objective (one at a time) the code runs absolutely fine. Am I stating the above correctly ?
Any help is highly appreciated.
1 Like
Hi @Bhartendu_Awasthi,
The problem may be here:
The error may be happening if the let
statements are evaluated before setting the data. If you have just the second objective and the second let statement you should get the same error.
In AMPL there is lazy-evaluation, but the moment the let statement is evaluated AMPL tries to instantiate the objective and needs data for that.
Thank you. Could you please suggest how to rectify the issue. Sorry, I am relatively new to AMPL.
Thanks.
On possibility to to move the let statements closer to the solve command since at the point you will already have all the data loaded as it will be necessary to solve the problem. Another option for this case in particular you can have a let vns := ...;
before the let statements related to objpriority.
1 Like