Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  variable declaration problem

    Posted 02/15/17 09:41 AM

    Originally posted by: Guerlain


    Hi

    I try to formulate an inventory management problem and the program run but the demand should change and take the values as mentioned in the model

    if (t<1) (demand[i][t]=demand_in[i]) else (demand[i][t]=level_sup[i]-stock[i][t]).

    I think I should declare the demand as a variable but I don't know how to do it

    Here my data and mod files.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: variable declaration problem

    Posted 02/15/17 09:59 AM

    Do you mean this (with Demand declared as 'dvar int')?

    forall (i in 2..n) {
      forall (t in Periods) {
        if (t<1) {
          Demand[i][t]==Demand_in[i];
        }
        else {
          Demand[i][t]==level_sup[i]-stock[i][t];
        }       
      }
    }


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: variable declaration problem

    Posted 02/15/17 10:16 AM

    Originally posted by: Guerlain


    when I use the demand as a dvar I've this error message (CPLEX Error  5002: Q in 'q2' is not positive semi-definite.)


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: variable declaration problem

    Posted 02/15/17 12:29 PM

    Hi,

    this is because of

    forall(i in cities, t in Periods)   
    sum(i in 2..n) Demand[i][t]*y[i][t] <= stock[1][t];

    that you could linearize with Linearizing the product of a binary and a continuous variable at http://www.leandro-coelho.com/linearization-product-variables/

    or you could use a logical constraint and write

    dvar int Demandy[2..n][Periods];

    and later

    forall(i in cities,t in Periods)   
    sum(i in 2..n)
    Demandy[i][t] <= stock[1][t];

    forall(i in 2..n, t in Periods) (y[i][t]==1) => (Demandy[i][t]==Demand[i][t]);
    forall(i in 2..n, t in Periods) (y[i][t]==0) => (Demandy[i][t]==0);

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: variable declaration problem

    Posted 02/16/17 06:44 AM

    Originally posted by: Guerlain


    Thanks Alex I correct the model and now it gives the right results Yes


    #CPLEXOptimizers
    #DecisionOptimization