Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  the solution does nt satisfy the constrainsts

    Posted 01/09/15 09:35 AM

    Originally posted by: Mehrsa


    Hi every one

    I have started learning opl and cplex on my own, I solve 2 simple problems but on the second one, The cplex gives me the solution that it does nt satisfy the constraints. I do nt know what I am doing wrong, please help me.

     

    int m =...;

    int n =...;

    int s[1..n]=...;

    int d[1..n]=...;

    float t[1..m][1..n]=...;

    float c[1..n]=...;

     

    dvar int+ x [1..n];

     

    maximize

    sum (j in 1..n)( x[j]+s[j]-d[j]);

     

    subject to {

    forall (i in 1..m)

    sum (j in 1..n)

    t[i][j] * x[j]<=c[i];

    forall (j in 1..n)

    d[j]-s[j]<= x[j] ;

    }

    m=2;

    n=2;

    s=[30 90];

    d=[75 95];

    t=[[50 24]

    [30 33]

    ];

    c=[2400 2100]

     

    the solution is (45,6) which is not correct.

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: the solution does nt satisfy the constrainsts

    Posted 01/09/15 10:00 AM

    Hi

    if you add

    assert

     

    forall (i in 1..m)

     

    sum (j in 1..n)

     

    t[i][j] * x[j]<=c[i];

     

    assert

    forall (j in 1..n)

     

    d[j]-s[j]<= x[j] ;

    in the postprocessing it works fine.

    Which constraint is violated according to you ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: the solution does nt satisfy the constrainsts

    Posted 01/09/15 10:14 AM

    Originally posted by: Mehrsa


    Thank you

    I added assert before every forall as you said, it gives me an error ( an unexpected assert).

    the first constraint is violated and in the problem browser it says solution with objective 1.

    I just have 1 objective function and it doesn't give me any quantity with this solution.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: the solution does nt satisfy the constrainsts

    Posted 01/09/15 10:23 AM

    Hi,

    you get the same solution if you write

    dvar int x;

    dvar int y;

     

    maximize x+30-75+y+90-95;

    subject to

    {

    50*x+24*y<=2400;

    30*x+33*y<=2100;

    x>=45;

    y>=5;

    }

    Let me give you the model with asserts:

    int m=...;

     

    int n=...;

     

    int s[1..n]=...;

     

    int d[1..n]=...;

     

    float t[1..m][1..n]=...;

     

    float c[1..n]=...;

     

     

     

    dvar int+ x [1..n];

     

     

     

    maximize

     

    sum (j in 1..n)( x[j]+s[j]-d[j]);

     

     

     

    subject to{

     

    forall (i in 1..m)

     

    ct1:sum (j in 1..n)

     

    t[i][j] * x[j]<=c[i];

     

    forall (j in 1..n)

     

    ct2:d[j]-s[j]<= x[j] ;

     

    }

     

     

     

    assert

     

    forall (i in 1..m)

     

    sum (j in 1..n)

     

    t[i][j] * x[j]<=c[i];

     

    assert

    forall (j in 1..n)

     

    d[j]-s[j]<= x[j] ;

     

     

    To get some displey you may add

    execute

    {

    writeln();

     

    writeln("x=",x);

     

     

    }

    and you will get

     

    x= [45 6]

    regards

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: the solution does nt satisfy the constrainsts

    Posted 01/09/15 10:59 AM

    Originally posted by: Mehrsa


    Yes, the model I wrote is the same as yours, Although x=[45,6] is in feasible region, it is not the optimum, and that is my problem. because I solved it with simplex  in the paper.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: the solution does nt satisfy the constrainsts

    Posted 01/09/15 11:10 AM

    Hi,

    so what would be the optimum ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer