Originally posted by: JPRyan
So this problem has become more crazy and I'm pretty stuck. Below is the core of the code I ran starting yesterday. The last timestamp I had from datetime.now() was 6pm last night. At 9am this morning it was still running and using about 20% of my CPU.
mdl = AdvModel(...)
# Other Parameters
mdl.parameters.timelimit.set(20)
# Build model
mdl.minimize(self.clean_expr(...))
print(datetime.now())
mdl.parameters.export_prm_to_path(...)
mdl.export_as_lp(path=r'...')
self.solution = mdl.solve(log_output=verbose)
print(human_time(mdl.solve_details.time))
I attached the last parameter file and LP file in the directory also written at 6pm the night before. So it doesn't appear to be a logging problem.
The odd thing is when I load the problem using cpx = Cplex(...\bad_inputs.lp) the problem runs just fine in 0.01 seconds.
It's worth mentioning that we discussed another problem recently. I'm the person that had the MIQP that needed fix that you suggested some weeks back using the clean_expr. This may be why the lp file has a odd structure.
def clean_expr(expr)
quadterms = dict()
idxmap = dict()
for v1, v2, a in expr.iter_quad_triplets():
idxmap[v1._index] = v1
idxmap[v2._index] = v2
key = (min(v1._index, v2._index), max(v1._index, v2._index))
quadterms[key] = quadterms.get(key, 0.0) + a
lin = expr.linear_part # includes the constant
return lin + sum([idxmap[k[0]] * idxmap[k[1]] * quadterms[k] for k in sorted(quadterms)])
A final note was there was >1000 slightly different problems that DocPlex handled always under 5 seconds and usually under 0.01 seconds before this problem MIQP.
#CPLEXOptimizers#DecisionOptimization