Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Cannot extract expression

    Posted 03/09/13 04:14 PM

    Originally posted by: SystemAdmin


    Hi !
    "
    //Paramètres
    {string} supplier=...;
    {string} scenario=...;
    {string} location=...;
    {string} component=...;
    float necessarycomponentscomponent=...;
    float fixedcostlocation=...;
    float manufactcostlocation=...;
    float co2suppliercomponent,scenario,supplier,location=...;
    float co2customerscenario,location=...;
    float purchasecostcomponent,scenario,supplier,location=...;
    float distributioncostlocation,scenario=...;
    float unitprice=...;
    int basedemand=...;
    float alpha=...;
    float psy=...;
    float omegamax=...;
    //
    //Variables de décision
    dvar int openlocation in 0..1; //yj
    dvar int approcomponent,scenario,supplier,location in 0..1; //ypmsj
    dvar int distributionscenario,location in 0..1; //ymj
    dvar float+ componentquantitycomponent,scenario,supplier,location; //vpmsj
    dvar int+ productquantitylocation; //xj
    dvar int+ distributedquantityscenario,location; //wmj
    dvar float beta;
    dvar float d;
    //
    //Fonction objectif
    maximize
    sum(j in location) productquantity[j]*unitprice
    - sum(s in supplier) sum(j in location) sum (p in component) sum(m in scenario) purchasecostp,m,s,j*componentquantityp,m,s,j
    - sum(j in location) fixedcost[j]*open[j]
    - sum(j in location) manufactcost[j]*productquantity[j]
    - sum(j in location) sum(m in scenario) distributioncostj,m ;
    //Contraintes
    subject to {
    beta==(omegamax-sum(m in scenario)sum(p in component) sum(s in supplier) sum(j in location) necessarycomponents[p]*co2supplierp,m,s,j*approp,m,s,j-sum(j in location)sum(m in scenario)co2customerm,j*distributionm,j)/omegamax;
    d == basedemand+alpha*beta;
    sum(j in location) sum(m in scenario) distributedquantityj,m<=d;//3
    forall(j in location)
    sum(m in scenario) distributedquantitym,j==productquantity[j];//4
    forall(p in component,j in location)
    sum(m in scenario) (sum(s in supplier) componentquantityp,m,s,j)==productquantity[j]*necessarycomponents[p];//5
    forall (p in component,s in supplier,j in location)
    sum(m in scenario) approp,m,s,j<=1;//6
    forall(j in location)
    sum(m in scenario) distributionm,j<=1;//7
    sum(j in location) open[j]<=1;//8
    forall(p in component,j in location)
    sum(s in supplier)sum(m in scenario) approp,m,s,j<=1;//9
    forall(j in location)
    {
    (1/psy)*open[j]<=productquantity[j];
    productquantity[j]<=psy*open[j];
    }//10
    forall(m in scenario,j in location)
    {
    (1/psy)*distributionm,j<=distributedquantitym,j;
    distributedquantitym,j<=psy*distributionm,j;
    }//11
    forall(p in component,m in scenario,s in supplier, j in location)
    {
    (1/psy)*approp,m,s,j<=componentquantityp,m,s,j;
    componentquantityp,m,s,j<=psy*approp,m,s,j;
    } //12
    d>=0;
    beta>=0;//13-14

    }
    "
    When I try to execute this code I have a series of errors starting with
    CPLEX(default) cannot extract expression: sum(m in scenario) distributedquantity[j][m].
    Can you help me with this?
    I found similar posts about this problem and couldn't apply a working solution!
    Thank you for your help.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Cannot extract expression

    Posted 03/10/13 05:26 PM

    Originally posted by: SystemAdmin


    Check the order in which you specify the indices.

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Cannot extract expression

    Posted 03/11/13 04:02 AM

    Originally posted by: SystemAdmin


    Your code is ultra-hard to read. Please wrap code into '{code}' tags so that it is easier to read.
    What I can see is that you index distributedquantity inconsistently: in most places you index by m and j (m is scenario, j is location). However, in the offending place you seem to index by j and m, that is location first. That is inconsistent with the definition of distributedquantity. Maybe that is the problem?
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Cannot extract expression

    Posted 03/11/13 09:16 AM

    Originally posted by: SystemAdmin


    Thank you for your help!
    I will try to make my posts easier to read in the future.
    #CPLEXOptimizers
    #DecisionOptimization