Decision Optimization

Decision Optimization

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

 View Only
  • 1.  ILOINT type violation

    Posted Fri June 20, 2014 02:12 PM

    Originally posted by: sanchit_singh


    In the code below, the line in the bold, represents clear cut violation of integer bounds for x4 variable, logically status returned should have been infeasible, but if you compile the code, x4 takes value as 3!! Can someone explain how are these arguments processed in CPLEX, and what is the make sure way of enforcing cplex to stricltly take care of fractional bounds!

     

    // -------------------------------------------------------------- -*- C++ -*-
    // File: ilomipex1.cpp
    // Version 12.5
    // --------------------------------------------------------------------------
    // Licensed Materials - Property of IBM
    // 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55 5655-Y21
    // Copyright IBM Corporation 2000, 2012. All Rights Reserved.
    //
    // US Government Users Restricted Rights - Use, duplication or
    // disclosure restricted by GSA ADP Schedule Contract with
    // IBM Corp.
    // --------------------------------------------------------------------------
    //
    // ilomipex1.cpp - Entering and optimizing a MIP problem
     
    #include <ilcplex/ilocplex.h>
     
    ILOSTLBEGIN
     
    static void
       populatebyrow(IloModel model, IloNumVarArray var, IloRangeArray con);
     
    int
    main (void) {
       IloEnv env;
       try {
          IloModel model(env);
     
          IloNumVarArray var(env);
          IloRangeArray con(env);
          populatebyrow (model, var, con);
     
          IloCplex cplex(model);
          cplex.solve();
     
          env.out() << "Solution status = " << cplex.getStatus() << endl;
          env.out() << "Solution value  = " << cplex.getObjValue() << endl;
     
          IloNumArray vals(env);
          cplex.getValues(vals, var);
          env.out() << "Values        = " << vals << endl;
          cplex.getSlacks(vals, con);
          env.out() << "Slacks        = " << vals << endl;
     
          cplex.exportModel("mipex1.lp");
       }
       catch (IloException& e) {
          cerr << "Concert exception caught: " << e << endl;
       }
       catch (...) {
          cerr << "Unknown exception caught" << endl;
       }
     
       env.end();
    getchar();
       return 0;
     
    }  // END main
     
     
    static void
    populatebyrow (IloModel model, IloNumVarArray x, IloRangeArray c)
    {
       IloEnv env = model.getEnv();
     
       x.add(IloNumVar(env, 0.0, 40.0));
       x.add(IloNumVar(env));
       x.add(IloNumVar(env));
       x.add(IloNumVar(env, 2.3, 2.4, ILOINT));
       model.add(IloMaximize(env, x[0] + 2 * x[1] + 3 * x[2] + x[3]));
     
       c.add( - x[0] +     x[1] + x[2] + 10 * x[3] <= 20);
       c.add(   x[0] - 3 * x[1] + x[2]             <= 30);
       c.add(              x[1]        - 3.5* x[3] == 0);
       model.add(c);
     
    }  // END populatebyrow
     

    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: ILOINT type violation

    Posted Fri June 20, 2014 03:10 PM

    I've reproduced your issue.  Because you're using ILOINT for the type, and both the lower bound and upper bound are getting rounded up, we end up with "x4 = 3" in the LP file.  You can work around this by rounding the values for lb and ub in the way you want before passing them to the IloNumVar constructor.  Or, if you really want a float here, then use ILOFLOAT.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: ILOINT type violation

    Posted Fri June 20, 2014 03:34 PM

    Originally posted by: sanchit_singh


    Yes, thanks for that, I also read on that, just like you are saying, lb is rounded down and ub is rounded up, when ILONUMVAR::INT or ILOINT is option.


    #CPLEXOptimizers
    #DecisionOptimization