Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Use IloIntervalVar and IloIntervalSequence in C++

    Posted 03/24/17 05:18 AM

    Originally posted by: MarcosThomaz


    Hello everyone,

    I created this code in C++: http://pastebin.com/tugcqTc9

    myfile.txt: http://pastebin.com/PQn6VFxs

     

    The compilation is ok, but when I run my application, I receive this error: CannoExtractException: IloAlgorithm cannot extract extractables 54, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 56 and 56

    The complete log error is here: http://pastebin.com/k41PzRZh

     

    What's wrong with my code?

     

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: Use IloIntervalVar and IloIntervalSequence in C++

    Posted 03/27/17 05:51 AM

    Originally posted by: ol


    Hello,

    the links have been removed.


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: Use IloIntervalVar and IloIntervalSequence in C++

    Posted 03/27/17 02:36 PM

    Originally posted by: MarcosThomaz


    Ok... this is my code:

    #include "ilcplex/cplex.h"
    #include "ilcplex/ilocplex.h"
    
    ILOSTLBEGIN
    
    using namespace std;
    
    
    int main(){
            char *filename = "myfile.txt";
            ifstream fin(filename);
    
            IloInt n, i;
    
    
            if (!fin.is_open())
                    exit(1);
    
            fin >> n;
    
            IloEnv env;
            try{
                    IloModel model(env);
                    IloIntArray ciw(env, n), cip(env, n), cid(env, n);
                    for (i = 0; i < n; i++){
                            fin >> cip[i];
                    }
                    for (i = 0; i < n; i++){
                            fin >> ciw[i];
                    }
                    for (i = 0; i < n; i++){
                            fin >> cid[i];
                    }
                    fin.close();
    
                    IloIntervalVarArray interv(env, n);
                    for (i = 0; i < n; ++i){
                            interv[i] = IloIntervalVar(env, cip[i]);
                    }
                    IloIntervalSequenceVar seq(env, interv);
                    IloIntExpr f(env);
                    for (i = 0; i < n; i++){
                            f += IloMax(0, (IloEndOf(interv[i]) - cid[i])) * ciw[i];
                    }
                    IloNum ob = 0;
                    IloObjective obj = IloMinimize(env, f);
                    model.add(obj);
    
                    model.add(IloNoOverlap(env, seq));
    
                    IloCplex cplex(model);
                    cplex.solve();
                    cout << cplex.getObjValue() << endl;
            }
            catch (IloAlgorithm::CannotExtractException& e)
            {
                    std::cerr <<
                            "CannoExtractException: " << e << std::endl; IloExtractableArray failed = e.getExtractables();
    
                                            for (IloInt i = 0; i < failed.getSize() && i<10; ++i) std::cerr <<
                                                    "\t" << failed[i] << std::endl;
            }
            catch (IloException& ex) {
                    env.out() << "Error CPLEX: " << ex << std::endl;
            }
            catch (...){
                    cerr << Other Error!" << endl;
            }
            env.end();
            getch();
            return 0;
    }
    

     

     

     

    The myfile.txt is:

    10 
    99 100 93 85 15 97 47 38 29 35 
    2 2 8 4 8 9 7 7 3 7 
    382 155 444 127 332 562 375 663 699 252 
    

     

    This instance has the number of jobs, processing time (for each job, line 2), weight (for each job) and due date (for each job).

     

    The complete log error is:

    CannoExtractException: IloAlgorithm cannot extract extractables 54, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 56 and 56
            obj54 = (max(IloEndOf(14)[IloIntervalVar(1)[1: 0..1073741822 -- (99)0..1073741822 --> -1073741822..1073741822]:0] + -382 , 0) * 2 + max(IloEndOf(18)[IloIntervalVar(3)[1: 0..1073741822 -- (100)0..1073741822 --> -1073741822..1073741822]:0] + -155 , 0) * 2 + max(IloEndOf(22)[IloIntervalVar(4)[1: 0..1073741822 -- (93)0..1073741822 --> -1073741822..1073741822]:0] + -444 , 0) * 8 + max(IloEndOf(26)[IloIntervalVar(5)[1: 0..1073741822 -- (85)0..1073741822 --> -1073741822..1073741822]:0] + -127 , 0) * 4 + max(IloEndOf(30)[IloIntervalVar(6)[1: 0..1073741822 -- (15)0..1073741822 --> -1073741822..1073741822]:0] + -332 , 0) * 8 + max(IloEndOf(34)[IloIntervalVar(7)[1: 0..1073741822 -- (97)0..1073741822 --> -1073741822..1073741822]:0] + -562 , 0) * 9 + max(IloEndOf(38)[IloIntervalVar(8)[1: 0..1073741822 -- (47)0..1073741822 --> -1073741822..1073741822]:0] + -375 , 0) * 7 + max(IloEndOf(42)[IloIntervalVar(9)[1: 0..1073741822 -- (38)0..1073741822 --> -1073741822..1073741822]:0] + -663 , 0) * 7 + max(IloEndOf(46)[IloIntervalVar(10)[1: 0..1073741822 -- (29)0..1073741822 --> -1073741822..1073741822]:0] + -699 , 0) * 3 + max(IloEndOf(50)[IloIntervalVar(11)[1: 0..1073741822 -- (35)0..1073741822 --> -1073741822..1073741822]:0] + -252 , 0) * 7, IloObjective, Minimize);
    
            IloEndOf(14)[IloIntervalVar(1)[1: 0..1073741822 -- (99)0..1073741822 --> -1073741822..1073741822]:0]
            IloEndOf(18)[IloIntervalVar(3)[1: 0..1073741822 -- (100)0..1073741822 --> -1073741822..1073741822]:0]
            IloEndOf(22)[IloIntervalVar(4)[1: 0..1073741822 -- (93)0..1073741822 --> -1073741822..1073741822]:0]
            IloEndOf(26)[IloIntervalVar(5)[1: 0..1073741822 -- (85)0..1073741822 --> -1073741822..1073741822]:0]
            IloEndOf(30)[IloIntervalVar(6)[1: 0..1073741822 -- (15)0..1073741822 --> -1073741822..1073741822]:0]
            IloEndOf(34)[IloIntervalVar(7)[1: 0..1073741822 -- (97)0..1073741822 --> -1073741822..1073741822]:0]
            IloEndOf(38)[IloIntervalVar(8)[1: 0..1073741822 -- (47)0..1073741822 --> -1073741822..1073741822]:0]
            IloEndOf(42)[IloIntervalVar(9)[1: 0..1073741822 -- (38)0..1073741822 --> -1073741822..1073741822]:0]
            IloEndOf(46)[IloIntervalVar(10)[1: 0..1073741822 -- (29)0..1073741822 --> -1073741822..1073741822]:0]
    

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: Use IloIntervalVar and IloIntervalSequence in C++

    Posted 03/28/17 05:32 AM

    Originally posted by: ol


    Hello,

    for using interval vars you need to replace

    #include "ilcplex/cplex.h"
    #include "ilcplex/ilocplex.h"

    by 
    #include <ilcp/cp.h>

     

    regards,

    ol


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: Use IloIntervalVar and IloIntervalSequence in C++

    Posted 03/28/17 05:33 AM

    Originally posted by: ol


    and of course replace:

         IloCplex cplex(model);
         cplex.solve();

    by:

      IloCP cp(model);
      cp.solve();

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: Use IloIntervalVar and IloIntervalSequence in C++

    Posted 03/28/17 09:49 AM

    Originally posted by: MarcosThomaz


    When I was compiling receive this error:

    Error   3       error LNK2001: unresolved external symbol "private: long __thiscall IloCP::_solve(void)const " (?_solve@IloCP@@ABEJXZ)        C:\Projects\CPlex\WT\wt.obj     WT
    

    I add this folders for compile:

    C:\Program Files (x86)\IBM\ILOG\CPLEX_Studio_Community1263\opl\include

    C:\Program Files (x86)\IBM\ILOG\CPLEX_Studio_Community1263\opl\lib\x86_windows_vs2013\stat_mda

     

    I'm using Visual Studio 2013.


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 7.  Re: Use IloIntervalVar and IloIntervalSequence in C++

    Posted 03/28/17 10:06 AM

    Originally posted by: MarcosThomaz


    I'm sorry... works here. I add the library cp.lib. 

    Thank you Olivier!

     


    #DecisionOptimization
    #OPLusingCPOptimizer