Loading...
Searching...
No Matches
clad.py File Reference

This example demonstrates how to implement a complex termination criterion for a difficult MIP using GAMS/Cplex. More...

Go to the source code of this file.

Variables

sys clad.sys_dir = sys.argv[1] if len(sys.argv) > 1 else None
 
GamsWorkspace clad.ws = GamsWorkspace(system_directory=sys_dir)
 
GamsWorkspace clad.job = ws.add_job_from_file("clad")
 
GamsWorkspace clad.opt = ws.add_options()
 
 clad.mip
 
 clad.optfile
 
 clad.solvelink
 
 clad.threads
 
StringIO clad.sw = StringIO()
 
Thread clad.thread = Thread(target=job.run, args=(opt,), kwargs={"output": sw})
 
list clad.steps = [(5.0, "epgap 0.1"), (10.0, "epgap 0.2"), (20.0, "epagap 1e9")]
 
float clad.total_time = 0.0
 
StringIO clad.log = sw.getvalue()
 

Detailed Description

This example demonstrates how to implement a complex termination criterion for a difficult MIP using GAMS/Cplex.

We would like to achieve a globally optimal solution (relative gap 0%) but if solution time becomes larger than n1 seconds, we can compromise for a 10% gap, and if this is not achieved after n2 seconds, we compromise for a 20% gap, and again if this is not accomplished in n3 seconds we take whatever the solver has done so far and terminate the solve. This is implemented by executing GamsJob.run in an independent thread and providing new tolerances for the relative gap in the main thread by supplying new GAMS/Cplex option files and triggering the processing of the new tolerance option by GAMS/Cplex through the GamsJob.interrupt method.

Definition in file clad.py.