20 from threading
import Thread
22 from StringIO
import StringIO
24 from io
import StringIO
26 if __name__ ==
"__main__":
28 ws = GamsWorkspace(system_directory = sys.argv[1])
35 j1 = ws.add_job_from_file(
"clad")
38 f = open(os.path.join(ws.working_directory,
"cplex.opt"),
"w")
42 f.write(
"interactive 1\n")
44 f.write(
"iafile cplex.op2\n")
47 opt = ws.add_options()
50 opt.solvelink = SolveLink.LoadLibrary
55 opt_thread = Thread(target=j1.run, args=(opt,), kwargs={
"output":sw})
59 steps = [(5.0,
"epgap 0.1"),
66 opt_thread.join(s[0] - prev_step)
67 if not opt_thread.is_alive():
71 f = open(os.path.join(ws.working_directory,
"cplex.op2"),
"w")
76 print(
"Interrupted Cplex to continue with new option: " + s[1])
78 if opt_thread.is_alive:
82 if not "Interrupted..." in log:
83 raise Exception(
"Expected the solver to be interrupted at least once.")