Set a time limit for each lexicographic level and a global workmem limit in DOcplex

79 views Asked by At

I am working on a multi-objective problem using lexicographic ordering. I want to set a different time limit and a different MIP GAP for each level, that is, a vector of time limits and a vector of MIP GAPs of size equal to the number of targets. I also want to control working memory and node storage.

Problem: I can't find the way to specify these parameters to make them all work together. If I specify the vector of time limits and MIP GAPs, the solver ignores the workingmem parameter.

I tried:

model = Model(name='Model_name')

model.parameters.parallel = -1 # oportunistic
model.parameters.workmem = 10000 # 10 GB 
model.parameters.mip.strategy.file = 3 # Save nodes on disk and compressed

model.set_multi_objective('max',objectives, priorities=[3,2,1], names=objective_names)

paramsets = model.build_multiobj_paramsets(timelimits=[time1, time2, time3], mipgaps=[gap1, gap2, gap3])

solution = model.solve(url=None, key=None, log_output=True, clean_before_solve=True, parameter_sets=paramsets)

when I run the model the workmem limit is not respected and memory usage increases until it runs out of memory. I also get the following message:

warning: inconsistent parallel mode settings ignored, using opportunistic.

I also tried:

model = Model(name='Model_name')

model.parameters.parallel = -1 # oportunistic
model.parameters.workmem = 10000 # 10 GB 
model.parameters.mip.strategy.file = 3 # Save nodes on disk and compressed

model.maximize_static_lex(objectives, objnames=objective_names)
solution = model.solve(url=None, key=None, log_output=True, clean_before_solve=True)

With this last try, the workmem limit and node file storage works fine, but I can’t introduce a different time limits and different gaps for each lexicographic level. My question: Is there a way to control the workmem parameter (globally) and at the same time specify different time limits and mip gaps for each lexicographic level?

1

There are 1 answers

3
Alex Fleischer On

In the solve you can use time limits as parameters:

timelimits=[5, 10]

mdl.set_multi_objective(sense, exprs, priorities, weights, abstols=None,
                        reltols=None, names=None)

mdl.solve(lex_mipgaps = [0.001, 0.05], log_output=True,lex_timelimits = timelimits)

in the example https://github.com/AlexFleischerParis/zoodocplex/blob/master/zoomultiobjective.py

from docplex.mp.model import Model

mdl = Model(name='buses')

nbbus50 = mdl.integer_var(name='nbBus50')
nbbus40 = mdl.integer_var(name='nbBus40')
nbbus30 = mdl.integer_var(name='nbBus30')

cost = mdl.continuous_var(name='cost')
co2emission = mdl.continuous_var(name='co2emission')

mdl.add_constraint(nbbus50*50+nbbus40*40 + nbbus30*30 >= 200, 'kids')
mdl.add_constraint(co2emission==nbbus50+nbbus40*1.1+nbbus30*1.2)
mdl.add_constraint(cost==nbbus40*500 + nbbus30*400+nbbus50*625)
                
sense="min"
exprs=[cost,co2emission]
priorities=[1,2]
weights=[1,1]
timelimits=[5, 10]

mdl.set_multi_objective(sense, exprs, priorities, weights, abstols=None,
                        reltols=None, names=None)

mdl.solve(lex_mipgaps = [0.001, 0.05], log_output=True,lex_timelimits = timelimits)

for v in mdl.iter_integer_vars():
    print(v," = ",v.solution_value)

print("The minimum cost is ",cost.solution_value);
print("CO2 emission is ",co2emission.solution_value);