Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Cannot use the type int with "in"

    Posted 11/08/16 09:25 PM

    Originally posted by: M.Heshmat


    Hello there,

    I have an error called {Cannot use the type int with "in"}. Could you help me to remove this error, please? 

    I am attaching the .mod file.

    Thank you.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Cannot use the type int with "in"

    Posted 11/09/16 03:17 AM

    Hi,

    after "in" you should have a set or a range, not a number.

    So for example, you should change

    Constraint10: sum(j in Nurses,k in Chairs, s in (S-R[i]+1)) y[i,j,k,s]==1;

    into

    Constraint10: sum(j in Nurses,k in Chairs, s in (S-R[i]+1..S-R[i]+1)) y[i,j,k,s]==1;
        

    to get rid of the error

    regards

     

     


        


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Cannot use the type int with "in"

    Posted 11/09/16 03:27 AM

    Originally posted by: M.Heshmat


    Dear Alex,

    Thank you very much.

    Best Regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Cannot use the type int with "in"

    Posted 11/09/16 04:25 AM

    Originally posted by: M.Heshmat


    Dear Alex,

    I have changed the number into range, and the error has been gotten rid. However, Cplex cannot extract the model. Maybe a logical error.

    Could you give me a piece of advice? 

    Thanks


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Cannot use the type int with "in"

    Posted 11/16/16 02:08 AM

    The error I get for your model is "Variables are not supported in ranges when not fixed". And I think that pretty clearly tells what is wrong: You are using a decision variable as the bound of a range. That is not supported. I think the problematic parts of your model are the ones in red below

    Constraint11: sum(i in Patients, j in Nurses, t in (v..u)) y[i,j,k,t]<=1;
    constraint12: sum(i in Patients, k in Chairs,t in (w..x))

    where the range of t is bounded by decision variables.

    However, the quantities v, u, w, x do not need to be decision variables. You can define them as

     int v[i in Patients][s in Slots] = maxl(s-R[i]+1,1);
     int u[i in Patients][s in Slots] = minl((S-R[i]+1),s);
     int w[i in Patients][s in Slots] = maxl(s-R[i]+1,1);
     int x[i in Patients][s in Slots] = minl((S-R[i]+1),s);

    and then write the constraints as

    Constraint11: sum(i in Patients, j in Nurses, t in (v[i][s]..u[i][s])) y[i,j,k,t]<=1;
    constraint12: sum(i in Patients, k in Chairs,t in (w[i][s]..x[i][s])) A[i]*y[i,j,k,t]<=Amax;


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Cannot use the type int with "in"

    Posted 11/16/16 02:51 AM

    Originally posted by: M.Heshmat


    Thank you very much, I really appreciate that.


    #CPLEXOptimizers
    #DecisionOptimization