Using quadratic constraint(s) with multiobjective function (python)
AnsweredI am building an multiobjective optimization model with a quadratic constraint. However, when I solve the model I get the following error :
Gurobi Optimizer version 9.0.3 build v9.0.3rc0 (win64)
Optimize a model with 6 rows, 917 columns and 2266 nonzeros
Model fingerprint: 0xacd4957f
Model has 1 quadratic constraint
Model has 457 general constraints
Variable types: 2 continuous, 915 integer (914 binary)



GurobiError: Model too large, QP not enabled, or restricted Gurobi license
I am using community edition of Gurobi. However, when I solve the same problem with a single objective function, solver finds an optimal solution.
I am enclosing the python code below
mdl_gur = gp.Model("")
sku_binary_var = mdl_gur.addVars(skus, vtype=GRB.BINARY, name = lambda p: '%s' % p)
num_sku_selected = mdl_gur.addVar(name = 'total_selected_sku', vtype=GRB.INTEGER)
mdl_gur.addConstr(num_sku_selected == gp.quicksum(sku_binary_var[i] for i in skus))
mdl_gur.addConstr(gp.quicksum(sku_binary_var[i] * sku_char[i]['shelf_capacity'] * sku_char[i]['item_cbm'] for i in skus) <= VOLUME_CAPACITY_CBM, name = 'volume_constraint')
mdl_gur.addConstr(gp.quicksum(sku_binary_var[i] * sku_char[i]['shelf_capacity'] * sku_char[i]['cost'] for i in skus) <= MAX_COST, name = 'cost_constraint')
tot_margin = mdl_gur.addVar(name = 'tot_margin', vtype=GRB.CONTINUOUS)
avg_margin = mdl_gur.addVar(name = 'avg_margin', vtype=GRB.CONTINUOUS)
# indicator constraints to help calculate average margin
indic_varbs = mdl_gur.addVars(range(1, len(skus)+1), vtype=GRB.BINARY)
for i in range(1, len(skus)+1):
mdl_gur.addGenConstrIndicator(indic_varbs[i], 1, num_sku_selected == i)
mdl_gur.addConstr(gp.quicksum(indic_varbs[i] for i in range(1, len(skus)+1)) == 1)
mdl_gur.addConstr(tot_margin == gp.quicksum(sku_binary_var[i] * sku_char[i]['avg_wk_sales_units'] * sku_char[i]['margin'] for i in skus))
# calculating average margin (tot_margin / num_sku_selected)
# this is the quadratic constraint
mdl_gur.addQConstr(avg_margin == tot_margin * gp.quicksum(indic_varbs[i] * (1 / i) for i in range(1, len(skus) + 1)))
mdl_gur.addConstr(avg_margin >= 8)
# below are 2 other objective that I'd like to maximize
obj_freq = gp.quicksum(sku_binary_var[i] * sku_char[i]['freq_trans'] for i in skus)
obj_unique = gp.quicksum(sku_binary_var[i] * sku_char[i]['uniq_factor'] for i in skus)
mdl_gur.update()
mdl_gur.setObjectiveN(tot_margin, 0, 2)
mdl_gur.setObjectiveN(obj_freq, 1, 1)
mdl_gur.setObjectiveN(obj_unique, 2, 0)
mdl_gur.ModelSense = 1 #GRB.MAXIMIZE
mdl_gur.optimize()

running above code results in the error I highlighted above. Strangely, if remove multiobjective, and maximize just total_margin :
mdl_gur.setObjective(tot_margin, GRB.MAXIMIZE)
the program returns an optimal solution.
could you please let me know what I am missing ?
Thank you,
Bhartendu

What type of license are you using? There is only one version of Gurobi, but certain license types may restrict how large of problems you are able to solve. The \( \texttt{gurobipy} \) pip installation includes such a sizerestricted license (which cannot be used in production).
It could be that Gurobi's presolve handles the singleobjective and multiobjective models differently. As a result, it's possible that the presolved multiobjective model has more quadratic terms than allowed by your license.
I see one of my colleagues has opened a ticket for you in our online support portal to discuss this further.
0 
Hi Eli,
I am using online course license that Gurobi offers (https://www.gurobi.com/downloads/eulaacademiconlinecourselicenserequest/). I think this license type has an upper cap of having max 2000 decision variables and 2000 constraints. It's free to use.
If your could pls confirm that the license type is a limiting factor here.
0 
This issue is being handled in a support request.
0
Please sign in to leave a comment.
Comments
3 comments