Originally posted by: KTAT_Leonardo_Lamorgese
Hi,
I am developing a code using Java and the CPLEX Concert Technology interface.
My optimization model starts as a Linear Program, with only IloNumVar variables and a series of linear constraints.
I then compute to find if the solution is acceptable(for the actual real life application),and if it is not I introduce some new bigM constraints and generate a new IloIntVar variable Y ( with 0 as lower bound and 1 as upperbound, which HAS to be INTEGER) adding it to my IloCplex object as an IloColumn.
This works fine because when I print the .lp file the constraints and variables are added correctly.
The problem is that once I compute this model with the new constraints and variables (cplex.solve() ), the cplex.getValue method, applied to the IloIntVar's Y does not return,as I would expect, ONLY 0 and 1's, for example:
y_0 = 0.0
y_1= 1.0
y_2= 0.0
........
.......
but also returns decimal values very close to 0 and 1 like :
y_0 = 0.0
y_1= 0.9999999999967543
y_2= 2.0235567788 E-9
y_3=1.0
and so on.
Is this to be considered normal? because I need to be modeling, when I introduce these variables, only integer values (specifically only 0 or 1). Is there some sort of casting that I have to apply? Or have I missed out some step?
Any help would be very appreciated,
L
#CPLEXOptimizers#DecisionOptimization