Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Variable not fixed in satisfiability problem???

    Posted 03/30/10 10:26 AM

    Originally posted by: SystemAdmin


    I have a satisfiability problem that involves real valued variables. For some reason CP Optimizer does not count these as variables when solving this problem. Is there some configuration parameter I need to set to have it include these values? I created a very simple test case to illustrate the problem:

    
    
    
    import ilog.concert.IloException; 
    
    import ilog.concert.IloNumVar; 
    
    import ilog.cp.IloCP;   
    
    public 
    
    class Test 
    {   
    
    public 
    
    static 
    
    void main(String[] _args) 
    
    throws IloException 
    { IloCP cp=
    
    new IloCP(); IloNumVar a=cp.numVar(0,Double.MAX_VALUE); cp.add(a); 
    
    if (cp.solve()) 
    { System.out.println(
    "a="+cp.getValue(a)); 
    } 
    }   
    };
    


    I then ran this using CP Optimizer 2.3 and got the following output. Note that it says there are 0 variables. If I replace line 9 above with IloIntVar a=cp.intVar(0,Integer.MAX_VALUE); it lists 1 variable and does not throw an Exception.

    
    ! ---------------------------------------------------------------------------- ! Satisfiability problem - 0 variables, 0 constraints ! Initial process time : 0.00s (0.00s extraction + 0.00s propagation) !  . Log search space  : 0.0 (before), 0.0 (after) !  . Memory usage      : 315.4 Kb (before), 315.4 Kb (after) ! ---------------------------------------------------------------------------- !   Branches  Non-fixed                Branch decision *          0      0.00s                         - ! ---------------------------------------------------------------------------- ! Solution status        : Terminated normally, solution found ! Number of branches     : 0 ! Number of fails        : 0 ! Total memory usage     : 335.4 Kb (331.4 Kb CP Optimizer + 4.0 Kb Concert) ! Time spent in solve    : 0.00s (0.00s engine + 0.00s extraction) ! Search speed (br. / s) : 0 ! ---------------------------------------------------------------------------- Exception in thread 
    "main" ilog.concert.IloException: IloCP::getValue - variable is not fixed at ilog.cp.cppimpl.cp_wrapJNI.IloCP_getValue__SWIG_2(Native Method) at ilog.cp.cppimpl.IloCP.getValue(IloCP.java:177) at ilog.cp.IloCP.getValue(IloCP.java:4657) at main(Test.java:12)
    


    Any help with this would be appreciated.

    Alex
    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: Variable not fixed in satisfiability problem???

    Posted 04/01/10 07:55 AM

    Originally posted by: Didier Vidal


    Alex,

    I am surprised that you could add a numVar to the solver. In CP Optimizer, the decision variables should be integer. You can have float expressions, and constraints on them, but they have to be derived from discrete decision variables. Here is an example in case it helps.

    
    
    
    import ilog.concert.IloException; 
    
    import ilog.concert.IloIntVar; 
    
    import ilog.cp.IloCP; 
    
    public 
    
    class MyTest 
    { 
    
    public 
    
    static 
    
    void main(String[] _args) 
    
    throws IloException 
    { IloCP cp=
    
    new IloCP(); IloIntVar a = cp.intVar(1, 10); IloIntVar b = cp.intVar(1, 10); ilog.concert.IloNumExpr f=cp.quot(a, b); cp.addLe(f, 0.4); cp.addGe(f, 0.3); cp.add(a); 
    
    if (cp.solve()) 
    { System.out.println(
    "f="+cp.getValue(f)); System.out.println(
    "a="+cp.getValue(a)); System.out.println(
    "b="+cp.getValue(b)); 
    } 
    } 
    };
    


    The output I have is the following:
    
    ! ---------------------------------------------------------------------------- ! Satisfiability problem - 2 variables, 2 constraints ! Initial process time : 0.00s (0.00s extraction + 0.00s propagation) !  . Log search space  : 6.6 (before), 5.0 (after) !  . Memory usage      : 315.4 Kb (before), 315.4 Kb (after) ! ---------------------------------------------------------------------------- !   Branches  Non-fixed                Branch decision *          1      0.00s                  _int0  =    1 ! ---------------------------------------------------------------------------- ! Solution status        : Terminated normally, solution found ! Number of branches     : 1 ! Number of fails        : 0 ! Total memory usage     : 336.0 Kb (331.4 Kb CP Optimizer + 4.5 Kb Concert) ! Time spent in solve    : 0.00s (0.00s engine + 0.00s extraction) ! Search speed (br. / s) : 100.0 ! ---------------------------------------------------------------------------- f=0.3333333333333333 a=1.0 b=3.0
    


    Didier.
    #CPOptimizer
    #DecisionOptimization