Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  CPLEX (default) cannot extract this expression

    Posted 11/06/15 06:00 AM

    Originally posted by: StefanWeiser


    Hello,

    I implemented a model in Optimization Studio and now got an error that I cannot erase. The display shows:

    CPLEX (default) cannot extract this expression: minimize TotalCost (that is my objective function) 

    My recent change was an implementation of a pairwise function for one sort of costs. Is this expression a certain type of mistakes? 

    Thanks for your thoughts on this problem! 


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: CPLEX (default) cannot extract this expression

    Posted 11/06/15 06:34 AM

    Could you show us the offending TotalCost expression?

    Usually you get this error if you try to do something that is not supported by the solver, for example dividing by decision variables or having cubic (or even higher order) terms in decision variables.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: CPLEX (default) cannot extract this expression

    Posted 11/06/15 07:01 AM

    Originally posted by: StefanWeiser


    Thanks for your fast reply. I attached my code at this post.

     

     //Index
     
    int N = ...;
    int NbPeriods = ...;
     
    range Periods = 1..NbPeriods;
     
    // Parameters
     
    float p[1..N] = ...;
    float s[1..N+1] = ...;
     
    float Demand [Periods] = ...;

    // Decision Variables

    dvar int x2 [Periods];  //Variable Price Quantity

    // Objective function

    dexpr float TotalCost [t in Periods] =
    piecewise ( i in 1..N){
         s[i] -> p[i];
         s[N+1]
     } (1, 1) x2[t];

     

     
    minimize TotalCost ;




    subject to {

    forall ( t in Periods)
      Demand [t] == x2[t];

    forall ( t in Periods) {
     
      x2[t] >= 0;


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: CPLEX (default) cannot extract this expression

    Posted 11/06/15 12:18 PM

    Hi,

    you are minimizing an array, which does not mean much.

    If you write

    minimize sum(p in Periods)TotalCost[p] ;

    then it will work and minimize the sum of the array.

    You may also minimize the max of the array:

    minimize max(p in Periods)TotalCost[p] ;

    regards

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: CPLEX (default) cannot extract this expression

    Posted 11/07/15 10:14 AM

    Originally posted by: StefanWeiser


    I figured out that, besides the array minimization, the starting point in the last line of the code has to be (0,0) instead of (1,1).

    Otherwise it doesent work at all!

     

    dexpr float TotalCost [t in Periods] =
    piecewise ( i in 1..N){
         s[i] -> p[i];
         s[N+1]
     } (1, 1) x2[t];

     

    Thanks for your help!


    #CPLEXOptimizers
    #DecisionOptimization