Weighted multi-objectives not working as expected
AnsweredHi,
I have the following MOO problem for a Electric vehicle charging station.
Problem background:
Vehicles come to charging slots, v in the charging station with a certain deadline and a demanded state of charge (0-1) (think of this a petrol/gas) to be supplied by the deadline.
The number of elements in SOCdep represent the number of vehicles at a charging station. The value inside represents the required final level of charge (0-1). SOC_1 is the intial amount of charge the vehicle has when it enters the charging station. char_per (charing period) is the time in hours for which a particular vehicle will charge. $ \Delta t $ is the time in hours that will split each char_per into timeslots, i.
The three objectives are:
1.Minimization of EV charging Cost (Linear equation). WEP is wholesale electricity price. V is constant voltage. delta t is time for a single timeslot i.
2.Minimization of overall battery capacity degradation Cost. (2nd order polynomial equation) the coefficients p are constant. SOCavg is defined in the constraints. adjavar is a constant. Can i violate the rule of only having linear Mulit-objectives using a 2nd degree polynomial?
3.Maximization of EV rental availability (Linear equation)
which is equal to
The weights wi,v are given in the constaints. V is a constant voltage.
Charging current is the decision variable and we will supply a specific current to charge a particular v in at timeslot i.
The constraints are specified as follows:
- For all objectives:
- Max and min current handled by the vehicle (1)
- Max and min current handled by the charging station (2)
- Deadline (departure time) (3)
- Total Charge demanded by the deadline (4)
- Minimization of overall battery capacity degradation objective:
- SOC update (5)
- SOC average and deviation update (6 & 7)
- Maximization of EV rental availability objective:
- Decaying weights update to pull current allocation to front of schedule (8)
This is a nonconvex problem because the 2nd objective is a concave objective and we try to minimize it.
I am using the following weighted objectives code for gurobi
m = gp.Model('moo')
m.params.NonConvex = 2
m.reset(0)
max_current = Imax
peak_cost = 98.37
peak_bat_deg = 3.2924*10**-4
max_avail_val = max_current*Nv*max_timeslot
max_bat_deg = peak_bat_deg*Nv*max_timeslot
max_char_cost = peak_cost*max_timeslot*Nv*vbat*max_current*del_t
W1 = Weight[0]
W2 = Weight[1]
W3 = Weight[2]
WEPV,viz_WEPV, viz_timev_cost = MOO_char_cost_obj(SOC_xtra,df,m,I,TT,max_TT,Imax,Icmax,Nv, SOCdep, char_per, SOC_1, del_t,Cbat, begin_time)
cap_loss_array,viz_timev_bat = MOO_bat_deg_obj(SOC_xtra,m,I,TT,max_TT,Imax,Icmax,Nv, SOCdep, char_per, SOC_1, del_t,Cbat,begin_time)
tot_char_curr, weights = MOO_rental_avail_obj(SOC_xtra,m,I,TT,max_TT,Imax,Icmax,Nv, SOCdep, char_per, SOC_1, del_t,Cbat)
m.ModelSense = GRB.MINIMIZE
m.setObjectiveN( (1/max_char_cost)*sum([a*b*vbat for a,b in zip(tot_char_curr,WEPV)]) ,0,weight = W1)
m.setObjectiveN( (1/max_bat_deg)*sum( cap_loss_array) ,1,weight = W2)
m.setObjectiveN( -1*(1/max_avail_val)*(sum([a*b for a,b in zip(tot_char_curr,weights)]) ) ,2,weight = W3, reltol=0.1 )
m.update()
print('\n Weights =', W1, W2, W3, '\n')
m.optimize()
The weights [W1, W2, W3] I am testing with are just [1,0,0]. [0,1,0], [0,0,1]. As if only one objective is being solved for.
when I query for objective values after a solution all 3 objectives give a non zero value. I was expecting to get 0 for the weights that were set to 0. Is it because the solution Ii,v is just plugged into the respective objectives and whatever that calculates to is given?
obj1 = m.getObjective(0)
ob1 = obj1.getValue()
obj2 = m.getObjective(1)
ob2 = obj2.getValue()
obj3 = m.getObjective(2)
ob3 = obj3.getValue()
I would like to know this:
lets say, I just solve a simple case like below where 3 vehicles enter the station at the same time with different SOCdep and char_per and leave at the same time.
Should the weights [1,0,0] give the most minimum possilbe objective value for the first objective (charging cost)? likewise for weights [0,1,0] should I get the most minumum value for objective 2? Also similarly for weights [0,0,1] ?
The objective values are not as such. As shown below in the objective function space. green weights [0,1,0] is minimizes the first objective (charing cost) value more than the weights [1,0,0]. Is this because of the way I normalize the objective functions? Is it because I should NOT plot it this way because plugging in decision variable values into objectives that had 0 weights is not a meaningful objective value as it was not involved in the minimization?
Thanks.
-
Hi Jose,
This is a quite complicated problem but I try to answer at least some of your questions:
- Quadratic objective functions are allowed, also in multi-objective models, so your second objective is fine.
- When you query the objective values after optimization, you will get the value of the objective function without being multiplied with its weight. So having non-zero values for all 3 objectives is ok, even if two of them have weight 0. Those 2 objectives are just not considered when searching for an optimal solution and will most probably have sub-optimal values.
- Weights [1,0,0] will just minimize the first objective function. Likewise, weights [0,1,0] and [0,0,1] will minimize only the second and the third objective, respectively.
If weights [0,1,0] give you a better objective value for the first function than weights [1,0,0], then there is a problem somewhere. Could you show the 2 solver logs for these two cases? There could for example be numerical issues.
Best regards,
Mario0 -
Hi Mario,
Thanks for your reply.
I understand the 1st and 2nd bullet points.
For your 3rd point, somehow the results of MOO is different when I define the objectives individually using
m.setObjectiveN()
versus when I define my own single weighted sum of objectives using
m.setObjective( w1*obj1 + w2*obj2 + w2*obj2 )
I find the results of the single weighted sum of objectives to be correct and make sense. Maybe, can you explain this?
The exact syntax for the two cases is given below.
case 1:
m.setObjectiveN( ( num_stab*sum([a*b*vbat for a,b in zip(tot_char_curr,WEPV)]) - utopia_obj1 ) / ( nadir_obj1 - utopia_obj1 ) ,0,weight = W1)
m.setObjectiveN( ( num_stab*sum( cap_loss_array) - utopia_obj2) / (nadir_obj2 - utopia_obj2) ,1,weight = W2)
m.setObjectiveN( ( num_stab*(sum([a*b for a,b in zip(tot_char_curr,weights)]) ) - utopia_obj3 ) / (nadir_obj3 - utopia_obj3) ,2,weight = W3 )case 2:div_obj1 = 1/( nadir_obj1 - utopia_obj1 )
div_obj2 = 1/( nadir_obj2 - utopia_obj2 )
div_obj3 = 1/( nadir_obj3 - utopia_obj3 )
m.setObjective( W1*( sum([num_stab*a*b for a,b in zip(tot_char_curr,WEPV)]) - utopia_obj1 )*div_obj1 + W2*( num_stab*sum( cap_loss_array) - utopia_obj2 )*div_obj2 + W3*( -1*num_stab*(sum([a*b for a,b in zip(tot_char_curr,weights)])) - utopia_obj3 )*div_obj3 , GRB.MINIMIZE )I know the reason for the last problem.
"If weights [0,1,0] give you a better objective value for the first function than weights [1,0,0], then there is a problem somewhere."
I am doing a sequence of optimizations and the results from the past optimization updates the states used in the future optimizations so I get these unexpected results.
Thanks, :)
0 -
Hi Jose,
Your two ways of defining a single weighted objective function should be equivalent and the usage of the methods seems to be correct.
However, I can spot two differences in your code snippets:- In case 2 and objective 1, the multiplier "vbat" is missing.
- In case 1 and objective 3, the multiplier "-1" to convert it to maximization is missing.
Best regards,
Mario0 -
Hi Mario,
Thanks, I have made those two changes and now the code behaves in the same manner.
Best regards,
Peeterson.
0
Please sign in to leave a comment.
Comments
4 comments