I am implementing a mathematical model using docplex and the academic version of CPLEX.
I am attempting to solve very big problem instances.
I faced a MemoryError
.
Is there a way to overcome this? I saw that there is a possibility of using node files and setting the tree memory in Cplex Studio. However, I can't find anything in the documentation of docplex.
I would set the threads parameter to 1
Let me change my zoo example for your need. (Number of threads)
from docplex.mp.model import Model
mdl = Model(name='buses')
mdl.parameters.threads=1
nbbus40 = mdl.integer_var(name='nbBus40')
nbbus30 = mdl.integer_var(name='nbBus30')
mdl.add_constraint(nbbus40*40 + nbbus30*30 >= 300, 'kids')
mdl.minimize(nbbus40*500 + nbbus30*400)
mdl.solve()
print("threads = ",mdl.parameters.threads.get())
for v in mdl.iter_integer_vars():
print(v," = ",v.solution_value)
which gives
threads = 1
nbBus40 = 6.0
nbBus30 = 2.0
To limit memory, let me quote CPLEX documentation
"To avoid a failure due to running out of memory, set the working memory parameter, WorkMem, to a value significantly lower than the available memory on your computer (in megabytes), to instruct CPLEX to begin compressing the storage of nodes before it consumes all of available memory."