Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Problem when relaxing the LP, changing the binary variable to continous one

    Posted 02/12/15 08:14 AM

    Originally posted by: Zak86


    Hi guys,

    I work with CPLEX package in JAVA using Eclipse.

    I have to solve a binary LP problem and i have to begin with the solution of the relaxed problem. I mean that i have to change the solution binary variable ( which is an array) to a continuous (or fractional ) variable in the interval [0,1].

    So, in the declaration of this variable for the relaxed LP, instead of :

    IloIntVar[] x = cplex.boolVarArray(N);

    I put :

    IloNumVar[] x = cplex.numVarArray(N, 0.0, 0.1) ;  in order to have a real-type solution.

    For the first time that i execute ( Run ) the main class, i got this message :

    Parallel mode: deterministic, using up to 4 threads for concurrent optimization.
    Tried aggregator 1 time.
    LP Presolve eliminated 20046 rows and 7939 columns.
    Aggregator did 4032 substitutions.
    Reduced LP has 181 rows, 189 columns, and 3223 nonzeros.
    Presolve time = 0.02 sec. (12.31 ticks)
    Initializing dual steep norms . . .
    Reinitializing dual norms . . .
     
    Iteration log . . .
    Iteration:     1   Dual objective     =             1.000000
    Markowitz threshold set to 0.1
    Iteration:     2   Dual objective     =             1.000000
    Iteration:     3   Dual objective     =             1.000000
    Iteration:     5   Dual objective     =             1.000000
    Iteration:     6   Dual objective     =             1.000000
    Markowitz threshold set to 0.99999
    Iteration:     7   Dual objective     =             1.000000
    Iteration:     8   Dual objective     =             1.000000
    Iteration:    10   Dual objective     =             1.000000
    Iteration:    12   Dual objective     =             1.000000
    Iteration:    14   Dual objective     =             1.000000
    Iteration:    15   Dual objective     =             1.000000
    Iteration:    17   Dual objective     =             1.000000
    Iteration:    18   Dual objective     =             1.000000
    Iteration:    20   Dual objective     =             1.000000
    Iteration:    22   Dual objective     =             1.000000
    Iteration:    24   Dual objective     =             1.000000
    Iteration:    26   Dual objective     =             1.000000
    Iteration:    28   Dual objective     =             1.000000
    Iteration:    29   Dual objective     =             1.000000
    Iteration:    31   Dual objective     =             1.000000
    Iteration:    33   Dual objective     =             1.000000
    Iteration:    36   Dual objective     =             1.000000
    Iteration:    38   Dual objective     =             1.000000
    Iteration:    40   Dual objective     =             1.000000
    Iteration:    42   Dual objective     =             1.000000
    Iteration:    44   Dual objective     =             1.000000
    Iteration:    45   Dual objective     =             1.000000
    Iteration:    47   Dual objective     =             1.000000
    Reinitializing dual norms . . .
    Reinitializing dual norms . . .
    Markowitz threshold set to 0.1
     
    Iteration log . . .
    Iteration:     1   Dual objective     =             1.000000
    Markowitz threshold set to 0.99999
    Iteration:     2   Dual objective     =             1.000000
    Iteration:     3   Dual objective     =             1.000000
    Iteration:     5   Dual objective     =             1.000000
    Iteration:     6   Dual objective     =             1.000000
    Iteration:     7   Dual objective     =             1.000000
    Iteration:     8   Dual objective     =             1.000000
    Iteration:    10   Dual objective     =             1.000000
    Iteration:    12   Dual objective     =             1.000000
    Iteration:    14   Dual objective     =             1.000000
    Iteration:    15   Dual objective     =             1.000000
    Iteration:    17   Dual objective     =             1.000000
    Iteration:    18   Dual objective     =             1.000000
    Iteration:    20   Dual objective     =             1.000000
    Iteration:    22   Dual objective     =             1.000000
    Iteration:    24   Dual objective     =             1.000000
    Iteration:    26   Dual objective     =             1.000000
    Iteration:    28   Dual objective     =             1.000000
    Iteration:    29   Dual objective     =             1.000000
    Iteration:    31   Dual objective     =             1.000000
    Iteration:    33   Dual objective     =             1.000000
    Iteration:    36   Dual objective     =             1.000000
    Iteration:    38   Dual objective     =             1.000000
    Iteration:    40   Dual objective     =             1.000000
    Iteration:    42   Dual objective     =             1.000000
    Iteration:    44   Dual objective     =             1.000000
    Iteration:    45   Dual objective     =             1.000000
    Iteration:    47   Dual objective     =             1.000000
     
    Dual simplex solved model.

    And for the second time that i execute the main class, without changing anything in the code ( and it's very mysterious ), i got this message :

    Parallel mode: deterministic, using up to 4 threads for concurrent optimization.
    Infeasible column 'x2'.
    Presolve time = 0.00 sec. (1.95 ticks)

    Can you help me please to correctly get the relaxed solution ? I have a doubt on the declaration of the output variable x . Note that , all the message that i'm getting now are the second message.

    Is there any other method to solve directly the relaxed LP without modification on the declaration of the variables ?

    Thank you very much,

    Zak 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Problem when relaxing the LP, changing the binary variable to continous one

    Posted 02/12/15 09:40 AM

    This is very odd, provided you are indeed solving the exact same problem on the exact same machine.

    Can you please call

    cplex.exportModel("model.sav");
    cplex.writeParam("params.prm");

    before calling cplex.solve() and check that the files produced in the two runs are exactly the same?

    The preferred way to solve the relaxation is to create your model with integer/binary variables and then add IloConversion (as created by IloCplex.conversion()) to the model to instruct CPLEX to relax those variables. After solving the relaxation you can remove the conversion objects from the model to restore the original type.

    BTW, the correct place to post questions that are not related to OPL is this Forum.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Problem when relaxing the LP, changing the binary variable to continous one

    Posted 02/12/15 10:11 AM

    Originally posted by: Zak86


    Hi Daniel,

    Thanks a lot for replying me :-) Effectively, i'm a beginner with CPLEX. Thanks for the other correct Forum  :-) .

    Please Daniel, concerning your proposition, i would like to tell you shortly about the important point ( created object)  of my original code ( not relaxed)  to guide me more clearly, as i'm a beginner :-(

    1) i create IloCplex cplex = new IloCplex ()    ===> So i did'nt use the IloModel object

    2) i make the declaration of variables ( 2 binary variables and 2 integer variables ) such that 

    IloIntVar[] x = cplex.boolVarArray(VectCell.size())

    IloNumVar [][] w = new IloNumVar[Nb_cell_tot][ ]

    3) I create the objective function through

    IloObjective obj = cplex.addMinimize(expr) ; 

    4) For each constraint, i use cplex.addLe(...)

    5) cplex.solve()

    In fact, I don't understand why these Binary/integer declaration of the variable , i have an optimal solution ( NO PROBLEM encoutered), and the message includes parameters about branch and cuts , number of nodes, iteration etc .... . However with a numerical declaration ( the modification that i made ) ,the message is completely different ,  it speaks ( as i sad )  about Dual objective, parallel mode, markowitch threshold etc ... 

    For the IloConservasion that you recommend, do you mean that i have to keep these steps and just add IloCplex.conversion() before cplex.solve() ?

    What is the exact "conversion" function to add please ?

    Thanks again ;-)

    Zak

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Problem when relaxing the LP, changing the binary variable to continous one

    Posted 02/12/15 10:40 AM

    Depending on whether you create your variable x with cplex.boolVarArray(N) or cplex.numVarArray(N, 0.0, 1.0), a variable x[i] is constraint to be either in {0,1} (only values 0 and 1 are allowed) or in [0,1] (all values between zero and one are allowed). Thus the two different functions create variables with completely different domains.

    Variables that are restricted to be integer (bool vars) are known as integer variables. If a model/problem does not contain any integer variables then it is a continuous problem and can be solved for example by the dual simplex algorithm. This is what happened in your first post: you have a continuous problem and that was solved by the dual simplex algorithm. This is what is shown in the output.

    If you have integer variables in your problem then dual simplex will not do. Instead the problem must be solved by a completely different algorithm, known as branch and bound. This algorithm will show a completely different type of log output.

    Note that a restriction "x in {0,1}" is much stricter than "x in [0,1]", so it can well be that the LP relaxation has a feasible solution while the corresponding integer problem does not have a feasible solution.

    The conversion you would need is this:

    // Relax all variables in x
    IloConversion conversion = cplex.conversion(x, IloNumVarType.Float);
    cplex.add(conversion);
    ...
    // Unrelax the variables
    cplex.remove(conversion);

    And yes, you can keep your code and just insert the conversion right before solve().


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Problem when relaxing the LP, changing the binary variable to continous one

    Posted 02/12/15 10:51 AM

    Originally posted by: Zak86


    Thanks a lot , for this good clarification :-). I understand now the difference between the two log outputs that i though it's an Cplex error :p

    I will test what you recommend me. 

    Thank you again,

    Good luck for your work

    Zak


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Problem when relaxing the LP, changing the binary variable to continous one

    Posted 02/12/15 12:02 PM

    Originally posted by: Zak86


    Daniel,

    Sorry again for the disturb.

    I add the IloConversion object to change the type of all correspondant variables, and i add also the two function cplex.exportModel("model.sav")and cplex.writeParam("params.prm")that you recommend. Howeveri get the same output message as the first problem that i post :

    Parallel mode: deterministic, using up to 4 threads for concurrent optimization.

    Infeasible column 'x2'.

    Presolve time = 0.04 sec. (1.95 ticks)

    It's mysterious for me that i don't get a solution for this relaxed problem which is supposed to be easier.

    As i said, i get, however, an optimal solution for the original problem ( with just bool and integer variables ) and this was the message output.

    ...Cover cuts applied:  4

    Mixed integer rounding cuts applied:  3

    Gomory fractional cuts applied:  1

    Root node processing (before b&c):

      Real time             =    0.22 sec. (32.68 ticks)

    Parallel b&c, 4 threads:

      Real time             =    0.00 sec. (0.00 ticks)

      Sync time (average)   =    0.00 sec.

      Wait time (average)   =    0.00 sec.

                              ------------

    Total (root+branch&cut) =    0.22 sec. (32.68 ticks)

     Solution Status = Optimal 

    Solution value = 6.0

    Please, How can i manage the Relaxed Problem and get a feasible solution?

    Thank you,

    Zak

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Problem when relaxing the LP, changing the binary variable to continous one

    Posted 02/13/15 12:10 AM

    This is odd. If the integer problem is feasible then the relaxed problem should be feasible as well. Unless this is bad numerics this smells like a bug.

    Can you attach the .sav and .prm file for the integer and for the relaxed problem here?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Problem when relaxing the LP, changing the binary variable to continous one

    Posted 02/18/15 11:29 AM

    Originally posted by: Zak86


    Dear Daniel,

    Do you have a mail address to which can i send you my .prm/.sav files of the original and relaxed problem Please ?

    It's really absurd what i'm facing when solving the relaxed problem.

    I have to minimize sum( x[i] ) where i in [1 .. N ] and x[ ] a binary array variable.

    The original problem (x binary)  gives me a logic solution with an optimal status and value = to 6 .

    However, when relaxing the problem ( just to put x[ ] continuous in [0 1] using IloConversion conversion1 = cplex.conversion(x, IloNumVarType.Float); cplex.add(conversion1);  and without any other modification on constraints ) ,

    it gives me also optimal solution status, however with a value = to zero .

    This latter "Relaxed" Solution value ( zero )  is really absurd !  First, because i have a very clear constraint in which we must have at least one x[i] <> 0 . Second,  (even when we don't suppose this constraint of forcing at least one x[i] not null) ,  if the Zero solution is the optimal one, why the original problem did'nt give this solution ? 

    Thank you for your help,

    Zak

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: Problem when relaxing the LP, changing the binary variable to continous one

    Posted 02/19/15 04:48 AM

    Originally posted by: Zak86


    Dear Daniel,

    Sorry, i didn't see that i can attach a file via the CPLEX forum :-) I'm just a beginner in this Network .

    I attached you , as you recommended, the two .sav and .prm files for, repectively , the original problem and relaxed one.

    Please, take account about my last reply in which i explained the problem faced in the original and relaxed LP.

    Thank you very much for your help and sorry again for the disturb,

    Zak


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: Problem when relaxing the LP, changing the binary variable to continous one

    Posted 02/24/15 01:54 AM

    This latter "Relaxed" Solution value ( zero )  is really absurd !  First, because i have a very clear constraint in which we must have at least one x[i] <> 0 . Second,  (even when we don't suppose this constraint of forcing at least one x[i] not null) ,  if the Zero solution is the optimal one, why the original problem did'nt give this solution ?

    Since the relaxed model is less constraint than the original one, it is perfectly fine that this produces a better solution than the original model. In the relaxed model variables can be fractional while in the original model they cannot. Allowing fractional variables may certainly allow for better solutions.

    Something is very wrong with your model. I can see that there are coefficients like 1.79769313486232e+308 in your problem matrix. What are these supposed to mean. This sort of coefficients will cause numerical trouble and that may be the reason why you get an all-0 solution.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 11.  Re: Problem when relaxing the LP, changing the binary variable to continous one

    Posted 02/24/15 04:05 AM

    Originally posted by: Zak86


    Hi Daniel,

    Thank you very much four your reply :-)

    Effectively , i have a kind of constraint with a Log(Z) expression where Z is a fractional number very near to 0 .

    So i should calibrate the constant Z to get a valid solution.

    Thank you again,

    Regards,

    Zak

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer