Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

[Help] Decision Variable Not Allowed Error

  • 1.  [Help] Decision Variable Not Allowed Error

    Posted Wed March 18, 2015 04:43 AM

    Originally posted by: charles123123


    Dear all,

    I'm a new user of CPLEX for my thesis work. I'm constantly getting an error as Decision Variable (expression) not allowed.

    I'm getting some error as "Decision variable (or expression) "D" not allowed". 

    For your reference, I have the code of the project. 

    {string} staff   = ...;
    {string} service = ...;
    int     P       = ...;
    range   plot  = 0..P;
    tuple       edge     {int i; int j;}
    setof(edge) Edges    = {<i,j> | i,j in plot};
    float cost1[Edges] = ...;
    float cost2[staff][service] = ...;
    float e[plot] = ...;
    float l[plot] = ...;
    int   r[Edges] = ...;
    // Decision variables
    dvar  boolean x[Edges][staff][service];
    dvar  float   A[plot];
    dvar  float   D[plot];
    // Objective
    minimize sum (<i,j> in Edges, h in staff, k in service)(cost1[<i,j>]+cost2[h,k])*x[<i,j>,h,k];
    subject to {
       forall (i in plot)
            e[i]<=A[i]<=l[i];
       forall (i in plot)
            D[i]==maxl(A[i]+T1[i],e[i]+T1[i]);
       forall (<i,j> in Edges : j!=0, h in staff, k in service)
            if(D[i]+T1[j]+T2[<i,j>]<=r[<i,j>]*D[j]){x[<i,j>,h,k]==0;}

    }

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: [Help] Decision Variable Not Allowed Error

    Posted Wed March 18, 2015 09:51 AM

    As specified in the reference documentation:

    Conditions in if-else statements must be ground; that is, they must not contain decision variables.

    This is what the error is telling you. You cannot have a decision variable in the condition of an "if". You may instead want to reformulate this by means of the "implies" operator (=>), see here. In your case, the reformulated constraint could look like this

    (D[i] + T1[j] + T2[<i,j>] <= r[<i,j>]*D[j])  =>  (x[<i,j>,h,k] == 0);


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: [Help] Decision Variable Not Allowed Error

    Posted Thu March 19, 2015 07:48 AM

    Originally posted by: charles123123


    Thanks a lot~


    #CPLEXOptimizers
    #DecisionOptimization