Originally posted by: AndrewBullock
Vincent
Thanks for the reply.
The setup is relatively straight foward. Standard LP - but quite a lot of variables.
Settings are all default bar:
<setting name="lpmethod" value="2"/> Force it to Dual SImplex
<setting name="clocktype" value="1"/> CPU rather than clock
<setting name="threads" value="1"/> Only use one processor
<category name="run">
<setting name="run_displaysolution" value="false"/> Avoid the wait
<setting name="run_displayrelaxations" value="false"/> Avoid the wait
Invocation over .NET is like this (I've trimmed out a lot of error handling and status reporting to make it more readable):
Set Factory = New OplFactory ' Create the OPL Factory which creates all the other ILOG objects
Set Project = Factory.CreateOplProject(Application.ActiveWorkbook.Path) ' Create an empty project
Set RunConfiguration = Project.MakeRunConfiguration_2(...)
Set Model = RunConfiguration.getOplModel()
Call Model.Cplex.setOut(Nothing) ' Set the console output from CPLEX to be ignored
Call Model.Generate ' Generate the OPL model
Cycle = 0 ' Start at cycle zero
Do While (Cycle < Maximum_Iterations / Iterations_Per_Cycle)
' Solve or partially solve the model and retrieve information on the solve
SolveReturn = Model.Cplex.solve()
SubStatus = Model.Cplex.CplexSubStatus ' Get the status
Objective = Model.Cplex.ObjValue ' Get the current objective
Iterations = Model.Cplex.Niterations ' Get the number of iterations in this solve cycle
' Check and respond to the returned status
Select Case SubStatus
Case "Optimal": ' Solver has reached a successful conclusion
...
Exit Do ' Leave the cycle loops
Case "AbortTimeLim":
...
Exit Do
Case "AbortItLim": ' We've completed the iterations for the cycle with no solution - time for the next cycle
Call StatusMessage("In Progress. Iterations = " + CStr(Cycle * Iterations_Per_Cycle + Iterations) + " Objective = " + CStr(Objective))
Case "Unbounded":
...
Exit Do
Case "Infeasible":
...
Exit Do
Case Else:
...
Exit Do
End Select
Cycle = Cycle + 1 ' Move to the next cycle
Loop
The key line in the above is the one in red where I get the objective from Model.Cplex.ObjValue.
Note that there is the following in the .mod to limit the number of iterations per cycle when running from .NET:
execute Set_Control_Parameters { // ILOG Script to set the two control parameters
writeln("Processing script: Set_Control_Parameters")
if(thisOplModel.settings.skipAssert) { // This is only true when invoked over .NET
cplex.tilim = TiLim; // Override the time limit and iteration limit from the .ops file with what's in the Control sheet from .NET
cplex.itlim = ItLim;
}
}
I believe the issue here is one of being able to convert from a Dual objective to a Primal one before the optimisation has reached an optimal state. The IDE manages it somehow, I just need to be able to do the same when running over .NET.
Let me know your thoughts.
Thanks
Andrew
#DecisionOptimization#OPLusingCPLEXOptimizer