Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Dividing two results

ALEX FLEISCHER

ALEX FLEISCHERMon October 28, 2013 07:22 AM

Archive User

Archive UserMon October 28, 2013 06:56 PM

ALEX FLEISCHER

ALEX FLEISCHERTue October 29, 2013 05:18 AM

ALEX FLEISCHER

ALEX FLEISCHERTue October 29, 2013 02:18 PM

ALEX FLEISCHER

ALEX FLEISCHERWed October 30, 2013 05:18 AM

Archive User

Archive UserThu November 06, 2014 05:18 AM

ALEX FLEISCHER

ALEX FLEISCHERFri November 07, 2014 02:26 AM

Archive User

Archive UserFri November 07, 2014 04:41 AM

Archive User

Archive UserFri November 07, 2014 12:17 PM

ALEX FLEISCHER

ALEX FLEISCHERFri November 07, 2014 02:21 PM

Archive User

Archive UserMon November 10, 2014 04:26 AM

ALEX FLEISCHER

ALEX FLEISCHERMon November 10, 2014 09:32 AM

  • 1.  Dividing two results

    Posted Wed October 23, 2013 04:30 PM

    Originally posted by: Puppy26


    Hi all,

    Could someone help me for the below query.

    Actually, I got two equations. say for an example,

    a= 5, b = 5, c=6, d= 4;

    x = a+b;

    y = c+d;

    Z = x/y;

    I tried to using this technique in opl cplex but I'm getting an error as "OPL cannot extract the expression" but if i give it as x - y, I'm getting the result.

    how do I get the results now!!

    Many thanks!

     

    regards,

    puppy

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Dividing two results

    Posted Mon October 28, 2013 07:22 AM

    Hi,

     

    can you post the OPL model you wrote ?

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Dividing two results

    Posted Mon October 28, 2013 06:56 PM

    Originally posted by: Puppy26


    Hi Alex,

    Here is the code

    dvar int CSSupply [Consignees][Shippers][Years];
    dvar int SCSupply [Shippers][Consignees][Years];
    dvar float StreetTurnPct [Years];
    dvar float StreetTurnPctsh [Years];

     

     forall ( y in Years)

              Streetturnvalue:

      StreetTurnPct[y] == sum (c in Consignees, s in Shippers) SCSupply[s][c][y]/Demand[y];

      

       forall (y in Years)
              Streetturnvalueb:
      StreetTurnPctsh[y] == sum (c in Consignees, s in Shippers) CSSupply[c][s][y]/Supply[y];

     

     forall (y in Years) 0 <= StreetTurnPct[y] <= 0.2;
       forall (y in Years) 0 <= StreetTurnPctsh[y] <= 0.2;
       
      forall (y in Years)
        Equity:
          sum (c in Consignees, s in Shippers) SCSupply[s][c][y] == sum (c in Consignees, s in Shippers) CSSupply[c][s][y];
          

    In the place of Demand in StreetTurnPct[y], it has to be Demand[y] - ShipperRejects [y].. Since the Demand[y] and ShipperRejects[y] both are variable, im getting error as "OPL cannot extract the expression".

    Many thanks!

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Dividing two results

    Posted Tue October 29, 2013 05:18 AM

    Hi,

    let's try to fix

    forall ( y in Years)

              Streetturnvalue:

      StreetTurnPct[y] == sum (c in Consignees, s in Shippers) SCSupply[s][c][y]/Demand[y];

    This is not allowed because of / which is not linear.

    But why do not you write

    forall ( y in Years)

              Streetturnvalue:

      0<=sum (c in Consignees, s in Shippers) SCSupply[s][c][y]<=0.2*Demand[y];

    ?

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Dividing two results

    Posted Tue October 29, 2013 01:36 PM

    Originally posted by: Puppy26


    Hi,

    As I have already mentioned, in the place of Demand[y], it has to be Demand [y] - ShipperRejects[y].... if I give 

     

    forall ( y in Years)

              Streetturnvalue:

      0<=sum (c in Consignees, s in Shippers) SCSupply[s][c][y]<=0.2*(Demand[y] - ShipperRejects[y]);

     

    I'm getting error as ShipperRejects[y] not allowed..

    May I know how can I solve this now!!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Dividing two results

    Posted Tue October 29, 2013 02:18 PM

    Hi

     

    can you attach your .mod and .dat ?

     

    Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Dividing two results

    Posted Wed October 30, 2013 05:18 AM

    PS:

    Have you declared ShipperRejects[y] ?

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Dividing two results

    Posted Thu November 06, 2014 05:18 AM

    Originally posted by: Cplexbeginner


    Hi,

     

    I have the same problem. 

    After writing a long code, I reached to the error you mentioned. It seems that "/" is not a good syntax. 

    I was wondering if somebody can help.

     

    Bests,

    Beginner,


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: Dividing two results

    Posted Fri November 07, 2014 02:26 AM

    Hi

    can you post your complete model and data ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: Dividing two results

    Posted Fri November 07, 2014 04:41 AM

    Originally posted by: Cplexbeginner


    Hello,

     

    I have attached the files.

    I could handle one constraint, with multiplying both side of the equality by the denominator. However, I could not do the same for the other constraint. The reason is that it has fractional power.

     

    Best Regards, 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 11.  Re: Dividing two results

    Posted Fri November 07, 2014 06:44 AM

    Hi

    your problem does not seem to be linear. You should have a look at what CPLEX can solve in the documentation, or linearize your model or try with CPO.

    In order to try with CPO, simply use :

    using CP;

    and then do some variable change in order to turn dvar float into dvar int

    Could that help ?

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 12.  Re: Dividing two results

    Posted Fri November 07, 2014 08:44 AM

    Originally posted by: Cplexbeginner


    Hi,

    I have done your suggestion. 

    There is no compiling error but it makes the problem infeasible.

    My variable are all float, but when I put them int, the problem becomes infeasible.

     

    What can I do to handle it?

    Bests,


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 13.  Re: Dividing two results

    Posted Fri November 07, 2014 09:02 AM

    Hi

    the attached model works

    I let you uncomment more constraint by constraint in order to spot what the issue is with your model

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 14.  Re: Dividing two results

    Posted Fri November 07, 2014 12:17 PM

    Originally posted by: Cplexbeginner


    Hi,

    I really appreciate your help.

     

    I get this error after running the attached file.

     

    "Type CPLEX Error  5002: Q in 'q16' is not positive semi-definite."

    What is it? and How can I handle it?

     

    Bests,


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 15.  Re: Dividing two results

    Posted Fri November 07, 2014 02:21 PM

    Hi

    if you kept

    using CP;
     

    you should not have that error

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 16.  Re: Dividing two results

    Posted Mon November 10, 2014 04:26 AM

    Originally posted by: Cplexbeginner


    Hi,

     

    That is great. However, the decision variables are integer. When I uncomment some constraints, the problem becomes infeasible due to int variables.

     

    Can I introduce float for CP?

     

    Best, 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 17.  Re: Dividing two results

    Posted Mon November 10, 2014 09:32 AM

    Hi

    can you have a look at the example

    examples/opl/floatexpr

    ?

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer