Originally posted by: Marcelo.cl
Hi to all, I'm new here and I would like to ask for your help.
I have a MIP model.
Certain constraits entered by the user could be impossible to be accomplished.
So, I need to manage this infeasibility by ignoring these type of constraints.
Reading this forum, I found I can use RefineConflict + GetConflict.
I'm using in this way:
opl.Cplex.RefineConflict(constraints, preferences)
For i As Integer = 0 To cantRestricciones - 1
Console.WriteLine(opl.Cplex.GetConflict(constraints(i)).ToString())
Next
So, I can know which constrints make my model unfeasible.
But now, i want to discard these constarints and continue solving my model.
One way to do that is to write again the data file and run the model again with the new data.
But I'm wondering if there is any way to "delete" or relax the unfeasible constraints and continue running the same execution that was unfeasible before, in order to gain time, and do not start over.
I'm working with these software:
-
IBM ILOG OPL IDE Versión: 6.3
IBM ILOG CPLEX 12.1.0
IBM ILOG CP Optimizer 2.3
IBM ILOG Concert Technology 2.9
-
Visual Studio 2005 with Visual Basic (.Net Framework 2.0)
I really would appreciate some help.
Thanks in advance.
This is the code I'm working with. It's not finished yet, but is the main part.
Dim status As Integer = 127
OplFactory.DebugMode = False
Dim oplF As OplFactory = New OplFactory
Dim errorHandler As OplErrorHandler = oplF.CreateOplErrorHandler()
Dim modelSource As OplModelSource = oplF.CreateOplModelSource(RutaModeloAsignacionMes)
Dim settings As OplSettings = oplF.CreateOplSettings(errorHandler)
Dim def As OplModelDefinition = oplF.CreateOplModelDefinition(modelSource, settings)
Dim cplex As Cplex = oplF.CreateCplex()
cplex.SetOut(Nothing)
cplex.SetParam(ILOG.CPLEX.Cplex.DoubleParam.TiLim, 60 * 1) ''--> minutos de time limit
Dim opl As OplModel = oplF.CreateOplModel(def, cplex)
Dim dataSource As OplDataSource = oplF.CreateOplDataSource(dataFile)
opl.AddDataSource(dataSource)
opl.Generate()
Dim isConSolucion As Boolean = cplex.Solve()
While isConSolucion = False And cplex.GetCplexStatus.ToString = "AbortTimeLim"
isConSolucion = cplex.Solve()
End While
If isConSolucion Then
Console.Out.WriteLine("OBJECTIVE: " + Str(opl.Cplex.ObjValue))
status = 0
Else
Console.WriteLine("No solution")
status = 1
'''''''''''''''''''''''''''''''
'conflicts
Console.Out.WriteLine("There are conflicts.....")
Dim restricciones As IConstraintMap = opl.GetElement("ctRestLibre").AsConstraintMap
Dim setRestricciones As ITupleSet = opl.GetElement("restriccionesLibre").AsTupleSet
Dim itRest As IEnumerator = setRestricciones.GetEnumerator
Dim cantRestricciones As Integer = setRestricciones.Size
Dim constraints(cantRestricciones - 1) As ILOG.Concert.IConstraint
Dim preferences(cantRestricciones - 1) As Double
Dim ixRest As Integer = 0
While itRest.MoveNext
Dim t As ITuple = itRest.Current
preferences(ixRest) = ixRest + 1
constraints(ixRest) = restricciones.Get(t)
ixRest = ixRest + 1
End While
opl.Cplex.RefineConflict(constraints, preferences)
For i As Integer = 0 To cantRestricciones - 1
Console.WriteLine(opl.Cplex.GetConflict(constraints(i)).ToString())
Next
End If
oplF.End()
Environment.ExitCode = status
Return isConSolucion
#CPLEXOptimizers#DecisionOptimization