Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Function operator/(int,dvar float) not available in context CPLEX.

  • 1.  Function operator/(int,dvar float) not available in context CPLEX.

    Posted Sun October 16, 2011 08:42 PM

    Originally posted by: BCDS_Daniel_Underwood


    This code works:

    dvar float x;
    minimize x^2;
    subject to
    {
        x <= 10;
        x >= 2;
    }
    


    But this code does not work:

    dvar float x;
    minimize 1/x;
    subject to
    {
        x <= 10;
        x >= 2;
    }
    


    I don't understand why the second code example fails? Are decision variables not permitted in the denominator of fractions? If not, why aren't they?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Function operator/(int,dvar float) not available in context CPLEX.

    Posted Mon October 17, 2011 04:33 PM
    Hi,

    indeed the cplex engine cannot handle such an objective since it is not linear nor quadratic.
    But you can use the CP optimizer engine. (You will then need a variable change)

    using CP;
     
    dvar int x2 in -10000..10000;
     
    dexpr float x=x2/1000;
     
    dexpr  float obj=1/x;;
    minimize obj;
    subject to
    {
        x <= 10;
        x >= 2;
    }
    


    will give x=10

    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Function operator/(int,dvar float) not available in context CPLEX.

    Posted Mon October 17, 2011 08:12 PM

    Originally posted by: BCDS_Daniel_Underwood


    Thanks a lot!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Function operator/(int,dvar float) not available in context CPLEX.

    Posted Wed June 08, 2016 12:25 PM

    Originally posted by: NRouge


    Hi,

    I'm new to Cplex and I'm facing same error. I have this problem:

     

    int noport=2;
    int noship=1;range port=1..noport;
    range ship=1..noship;

    ...

    int d[port,port]=...;

    ...

    dvar int y[port,port,ship];

    dvar int z[ship];

     

    forall (i in 1..noport-1,j in i+1..noport,k in ship)
    y[i,j,k] <= (d[i,j])/(z[k])* sum(p in i..j-1) x[p,j,k];

     

    "(d[i,j])/(z[k])" this part cause the error "Function operator/(int,dvar int) not available in context CPLEX.".

     

    It works fine if it is (d[i,j])*(z[k]), but it doesn't work with the division and I don't know why. I attached mod file of my work  for more details.

    Please help. Thank you

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Function operator/(int,dvar float) not available in context CPLEX.

    Posted Wed June 08, 2016 02:53 PM

    Hi,

    same as 5 years ago.

    Dividing by a decision variable is not linear.

    So can you try with 

    using CP;

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer