Decision Optimization

 View Only
  • 1.  OPL cannot extract expression

    Posted Sun September 01, 2013 03:53 PM

    Originally posted by: Puppy26


    Hi all,

    I have a simple expression in which I need to calculate the result and feed the value to calculate next result. 

    In my case, I need to retrieve the sum of the supply in warehouse. The value will be in matrix form 5*5 and it should be multiplied by certain number(say for example 50).

    dexpr float DepotValue =  CDSupply [c][d]* DSCFixed;

    dexpr float RG = Revenue * ECDemanded;

    dexpr float TC  =  

     sum (d in Depots, t in Terminals) TermintoDepotCost [t][d] * TDSupply [t][d] +
     sum (t in Terminals, d in Depots) DepottoTerminCost [d][t] * DTSupply [d][t] + 
     sum( d in Depots) DepottoDepotCost[d][d] * DDSupply [d][d] + DepotValue;

    maximize RG-TC ;

    I need the program should find the value of CDSupply which will be matrix of 5*5  [[0 0 0 0 1][0 0 0 1 0][0 0 1 0 0][0 1 0 0 0][1 0 0 0 0]] and multiply it by DSCFixed value (50) and feed the value to dexpr float TC to calculate the final result.

    Could you please let me know how I should proceed further. 

    Many thanks!

    Regards,

    Prabhu


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: OPL cannot extract expression

    Posted Mon September 02, 2013 12:24 AM

    What are the indices 'c' and 'd' in the definition of DepotValue? You need to declare them in some way, like so (replace the question marks with the appropriate sets/ranges)

    dexpr float DepotValue[c in ???][d in ???] = CDSupply[c][d] * DSCFixed;

    Then you can reference DepotValue[c][d] in the definition of TC. Or should DepotValue represent the sum over all 'c' and 'd'? In that case you are missing a 'sum' in the definition of DepotValue.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: OPL cannot extract expression

    Posted Mon September 02, 2013 04:00 AM

    Originally posted by: Puppy26


    Hi Daniel,

    Thanks for your feedback. I have rewrote the code as you mentioned. But still I couldn't get the value for DepotValue[c][d].

    dexpr float DepotValue[c in Consignees][d in Depots] = CDSupply[c][d] * DSCFixed;

    I'm still not getting the output for DepotValue[c][d] in the results section. Moreover If I add DepotValue[c][d] in TC, I'm getting error as "Index out of bound for array DepotValue" and another error as "OPL cannot extract expression: CDSupply [c][d]*50.

    Actually I need the final output of the calculation(like DepotValue[c][d]= 100).

    Could you please help me. If you want, I can upload the entire code for your reference.

    Many Thanks!

    Prabhu


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: OPL cannot extract expression