Multi objective result changes from single objective, when model is exact the same
AnsweredHello All,
How can it be that my optimization result changes when I change my single objective model to a multi-objective model with only one objective, where everything remains the same exact for objective definition through model.setObjectiveN() instead of model.setObjective()
E.g.:
Changing this:
model.setObjective(
quicksum(
itinerary_fam_df.loc[i, "Fare"] * x[n, i]
for n in O_D.index
for i in usable_its_if[(f"{n}")]
if (n, i) in x
)
- quicksum(
aircraft_data.loc[k, "c_inv(EUR)"] * z[k, r]
for k in aircraft_data.index for r in max_aircraft_per_type_range
)
- quicksum(
(
w[(iteration - 1)][scenario][f'z[{k},{r}]']
- rho[iteration] * x_avg[(iteration - 1)][f'z[{k},{r}]']
+ rho[iteration]/2
)* z[k, r]
for k in aircraft_data.index
for r in max_aircraft_per_type_range
)
- quicksum(
(
eta_leg_fam.iat[l, k] * Leg_fam.loc[l, "Distance"] * p_fuel
+ Leg_fam.loc[l, f'{aircraft_data.loc[k, "AC Code"]} cost']
)
* f[l, k]
for l in Leg_fam.index
for k in aircraft_data.index
if not np.isnan(eta_leg_fam.iat[l, k])
if not np.isnan(Leg_fam.loc[l, f'{aircraft_data.loc[k, "AC Code"]} cost'])
if (l, k) in f
)
)
to this
model.setObjectiveN(
quicksum(
itinerary_fam_df.loc[i, "Fare"] * x[n, i]
for n in O_D.index
for i in usable_its_if[(f"{n}")]
if (n, i) in x
)
- quicksum(
aircraft_data.loc[k, "c_inv(EUR)"] * z[k, r]
for k in aircraft_data.index for r in max_aircraft_per_type_range
)
- quicksum(
(
w[(iteration - 1)][scenario][f'z[{k},{r}]']
- rho[iteration] * x_avg[(iteration - 1)][f'z[{k},{r}]']
+ rho[iteration]/2
)* z[k, r]
for k in aircraft_data.index
for r in max_aircraft_per_type_range
)
- quicksum(
(
eta_leg_fam.iat[l, k] * Leg_fam.loc[l, "Distance"] * p_fuel
+ Leg_fam.loc[l, f'{aircraft_data.loc[k, "AC Code"]} cost']
)
* f[l, k]
for l in Leg_fam.index
for k in aircraft_data.index
if not np.isnan(eta_leg_fam.iat[l, k])
if not np.isnan(Leg_fam.loc[l, f'{aircraft_data.loc[k, "AC Code"]} cost'])
if (l, k) in f
),
index=0,
priority=1,
weight=1
#reltol= obj_tolerance
)
changes the Obj value from 1.7e06 to 2.6e06. How can that be?
-
Hi Timo,
How can that be?
It shouldn't. Can you write your two models to MPS files and upload them to a file sharing site (such as DropBox, Google Drive, public Github repo etc) so we can take a look?
- Riley
0 -
Hi Riley,
Thanks for looking into it. I saw you also commented the more detailed forum post on it. I will edit the post to have the indentation, sorry about this.
Here are the model files:
Best
Timo
0 -
Hi Timo,
Which version of Gurobi are you using? There was a bug in v12.0.0 related to setting objectives in multiobjective models - see "Incorrect handling of duplicate indices in
setObjectiveN
" from Known issues in Gurobi 12.0.0This bug was fixed in v12.0.1 so if you're not using that then please test it.
- Riley
0 -
Hi,
That seems to have been the problem. Looks like it's fixed now.
Thank you!
1
Please sign in to leave a comment.
Comments
4 comments