I ran my program in Visual Studio 2010 with C++ calling cplex.

An error said: IloExtractable 99 has not been extracted by IloAlgorithm 0097F848.

I had no idea about this error. Could you help me?

The codes are as follows.

//////////////////////////////////////////////////////////////////////////
#include <ilcplex/ilocplex.h>

ILOSTLBEGIN

int main(int argc, char** argv) {

    IloEnv env;

    try {
        const char* filename;    //data input
        if(argc>1)
            filename = argv[1];
        else
            filename = "C:\\Users\\Ximenes\\Desktop\\try1.txt";
        ifstream f(filename, ios::in);
        if(!f) {
            cerr << "No such file: " << filename << endl;
            throw(1);
        }

        IloNum T;
        IloNumArray2 r(env);
        IloNumArray2 p1(env);
        IloNumArray2 p2(env);
        IloNumArray2 s(env);

        f>>T;
        f>>r;
        f>>p1;
        f>>p2;
        f>>s;

        cout << "T=" << T << endl;
        cout << "r=" << r << endl;
        cout << "p1=" << p1 << endl;
        cout << "p2=" << p2 << endl;
        cout << "s=" << s << endl;

        int N=r.getSize();
        cout << "N=" << N << endl;
        for(int i=0;i<N;i++){
            cout << "r[" << i << "]=" << r[i] << endl;
            cout << "p1[" << i << "]=" << p1[i] << endl;
            cout << "p2[" << i << "]=" << p2[i] << endl;
        }
        IloIntArray n(env,N);
        IloInt total=0;
        for(int i=0;i<N;i++){
            n[i]=r[i].getSize();
            cout << "n[" << i << "]=" << n[i] << ",";
            total+=n[i];
        }

        cout << "total=" << total << endl;

        IloModel model(env);
        IloArray<IloArray<IloBoolVarArray>>z(env, N);  //var definitions
        for(int i=0;i<N;i++){
            z[i]=IloArray<IloBoolVarArray>(env,n[i]);
            for(int j=0;j<n[i];j++){
                z[i][j]=IloBoolVarArray(env,total);
            }          
        }

        IloArray<IloArray<IloBoolVarArray>>e(env, N); 
        for(int i=0;i<N;i++){
            e[i]=IloArray<IloBoolVarArray>(env,n[i]);
            for(int j=0;j<n[i];j++){
                e[i][j]=IloBoolVarArray(env,total);
            }          
        }

        IloArray<IloBoolVarArray>y(env,N);
        for(int i=0;i<N;i++)
            y[i]=IloBoolVarArray(env,n[i]);

        IloArray<IloBoolVarArray>t(env,total);
        for(int i=0;i<total;i++)
            t[i]=IloBoolVarArray(env,total);

        IloArray<IloArray<IloArray<IloArray<IloArray<IloBoolVarArray>>>>>a(env, N); 
        for(int i=0;i<N;i++){
            a[i]=IloArray<IloArray<IloArray<IloArray<IloBoolVarArray>>>>(env,n[i]);
            for(int k=0;k<n[i];k++){
                a[i][k]=IloArray<IloArray<IloArray<IloBoolVarArray>>>(env,total);
                for(int m=0;m<total;m++){
                    a[i][k][m]=IloArray<IloArray<IloBoolVarArray>>(env,N);
                    for(int j=0;j<N;j++){
                        a[i][k][m][j]=IloArray<IloBoolVarArray>(env,n[j]);
                        for(int l=0;l<n[j];l++)
                            a[i][k][m][j][l]=IloBoolVarArray(env,total);
                    }

                }
            }
        }

        IloArray<IloArray<IloArray<IloArray<IloArray<IloBoolVarArray>>>>>b(env, N);  
        for(int i=0;i<N;i++){
            b[i]=IloArray<IloArray<IloArray<IloArray<IloBoolVarArray>>>>(env,n[i]);
            for(int k=0;k<n[i];k++){
                b[i][k]=IloArray<IloArray<IloArray<IloBoolVarArray>>>(env,total);
                for(int m=0;m<total;m++){
                    b[i][k][m]=IloArray<IloArray<IloBoolVarArray>>(env,N);
                    for(int j=0;j<N;j++){
                        b[i][k][m][j]=IloArray<IloBoolVarArray>(env,n[j]);
                        for(int l=0;l<n[j];l++)
                            b[i][k][m][j][l]=IloBoolVarArray(env,total);
                    }

                }
            }
        }

        IloArray<IloArray<IloArray<IloArray<IloArray<IloBoolVarArray>>>>>c(env, N);  
        for(int i=0;i<N;i++){
            c[i]=IloArray<IloArray<IloArray<IloArray<IloBoolVarArray>>>>(env,n[i]);
            for(int k=0;k<n[i];k++){
                c[i][k]=IloArray<IloArray<IloArray<IloBoolVarArray>>>(env,total);
                for(int m=0;m<total;m++){
                    c[i][k][m]=IloArray<IloArray<IloBoolVarArray>>(env,N);
                    for(int j=0;j<N;j++){
                        c[i][k][m][j]=IloArray<IloBoolVarArray>(env,n[j]);
                        for(int l=0;l<n[j];l++)
                            c[i][k][m][j][l]=IloBoolVarArray(env,total);
                    }
                }
            }
        }

        IloArray<IloArray<IloArray<IloArray<IloArray<IloBoolVarArray>>>>>d(env, N);  
        for(int i=0;i<N;i++){
            d[i]=IloArray<IloArray<IloArray<IloArray<IloBoolVarArray>>>>(env,n[i]);
            for(int k=0;k<n[i];k++){
                d[i][k]=IloArray<IloArray<IloArray<IloBoolVarArray>>>(env,total);
                for(int m=0;m<total;m++){
                    d[i][k][m]=IloArray<IloArray<IloBoolVarArray>>(env,N);
                    for(int j=0;j<N;j++){
                        d[i][k][m][j]=IloArray<IloBoolVarArray>(env,n[j]);
                        for(int l=0;l<n[j];l++)
                            d[i][k][m][j][l]=IloBoolVarArray(env,total);
                    }

                }
            }
        }

        IloNumVarArray I(env,total-1,0.0,T);

        IloNumVarArray W(env,total,0.0,T);

        //constraints
        IloExpr expr(env);
        for(int i=0;i<N;i++){              
            for(int j=0;j<n[i];j++){
                expr+=e[i][j][0]*p1[i][j];           
                expr+=p2[i][j]*y[i][j];              
            }
        }
        for(int i=0;i<total-1;i++){                      
            expr+=I[i];       
        }

        for(int m=0;m<total-1;m++){               
            for(int h=m+1;h<total;h++){
                for(int i=0;i<N;i++){
                    for(int k=0;k<n[i];k++){
                        for(int j=0;j<N;j++){
                            for(int l=0;l<n[j];l++)   
                                expr+=b[i][k][m][j][l][h]*s[i][j];
                        }
                    }
                }
            }
        }
        model.add(expr<=T);
        expr.end();

        for(int m=0;m<total-1;m++){
            IloExpr expr(env);
            for(int i=0;i<N;i++){
                for(int j=0;j<n[i];j++){
                    expr+=e[i][j][m+1]*p1[i][j]-e[i][j][m]*p2[i][j];
                }             
            }
            expr+=W[m+1]-W[m]-I[m];
            model.add(expr==0);
            expr.end();
        }

        for(int i=0;i<N;i++){           
            for(int j=0;j<n[i];j++){
                IloExpr expr(env);
                for(int k=0;k<total;k++)
                    expr+=z[i][j][k];
                model.add(expr==1);
                expr.end();
            }
        }

        for(int k=0;k<total;k++){      
            IloExpr expr(env);
            for(int i=0;i<N;i++){
                for(int j=0;j<n[i];j++)
                    expr+=z[i][j][k];
            }
            model.add(expr==1);
            expr.end();
        }

        for(int m=0;m<total-1;m++){     
            for(int h=m+1;h<total;h++){
                IloExpr expr(env);
                for(int i=0;i<N;i++){                   
                    for(int k=0;k<n[i];k++){                  
                        for(int j=0;j<N;j++){
                            for(int l=0;l<n[j];l++){
                                expr+=d[i][k][m][j][l][h]; 
                            }
                        }
                    }
                }
                expr-=t[m][h];
                model.add(expr==0);
                expr.end();
            }                       
        }

        for(int m=0;m<total-1;m++){
            IloExpr expr(env);
            for(int h=m+1;h<total;h++)
                expr+=t[m][h];
            model.add(expr<=1);
            expr.end();
        }

        //Objection
        IloExpr profitSum(env);
        for(int i=0;i<N;i++){
            for(int j=0;j<n[i];j++){
                profitSum+=r[i][j]*y[i][j];
            }
        }
        model.add(IloMaximize(env, profitSum));
        profitSum.end();

        IloCplex cplex(env);
        cplex.setParam(IloCplex::MIPEmphasis, 4);

        if(cplex.solve()){ 
            cout << " Optimal Value = " << cplex.getObjValue() << endl;
            for(int i=0;i<N;i++)
                for(int j=0;j<n[i];j++)
                    cout << "y[" << i << "][" << j << "]=" << cplex.getValue(y[i][j]);
        }
    }
    catch(IloException& ex) {
        cerr << "Error: " << ex << endl;
    }
    catch(...) {
        cerr << "Error" << endl;
    }

    env.end(); 
    system("pause");
    return 0;
}
//////////////////////////////////////////////////////////////////////////

Thank you very much.

asked 19 Aug '12, 11:17

Ximenes's gravatar image

Ximenes
3045
accept rate: 0%

edited 19 Aug '12, 15:59

fbahr's gravatar image

fbahr ♦
4.6k716


I think these questions are better asked and answered at Cplex support forum, though you might get a useful answer here too. Actually I am wondering a bit on why we get specific cplex questions here, I mean they seem to answer pretty swiftly on support tickets, so I don't see the benefit of asking here, perfectly legal though :-)

link

answered 19 Aug '12, 11:38

Bo%20Jensen's gravatar image

Bo Jensen ♦
5.0k2919
accept rate: 14%

edited 19 Aug '12, 11:38

2

And (most times) it's not hard to find useful information about the error message by googling them. A quick google turned up this technote (FAQ). Unless it's something specific regarding the formulation of a problem, etc

(19 Aug '12, 11:47) yeesian
1

Turns out the OP did ask on the CPLEX forum too. Would be nice if he'd at least mentioned that he cross-posted.

(19 Aug '12, 16:19) Paul Rubin ♦♦

As for the wandering questioin of Bo, yes, I was googling the error wishing to find a proper answer just as yeesian said and I did not know OR Exchange previously. I feel sorry if my problem is not so properly pasted on this forum and I will never do it again in the future.

I want to say "thank you so much" to professor Paul. Your suggestion is really beneficial to me. I will try to find the error using your way.

(20 Aug '12, 01:48) Ximenes
1

I was just wondering why people ask here and not in cplex support, no harm done :-)

(20 Aug '12, 02:08) Bo Jensen ♦

It would not surprise me if this error occurs when you are attempting to print the solution to the problem. (You can pin that down in a debugger, or by using separate try-catch blocks for each code segment). Check to be sure that every variable whose value you are trying to print actually made it into either the objective or one of the constraints. If a variable is declared but never actually used, it is never extracted.

link

answered 19 Aug '12, 16:16

Paul%20Rubin's gravatar image

Paul Rubin ♦♦
14.6k412
accept rate: 19%

Hi, Paul, can you specify how to use separate try-catch blocks for each code segment to find the error? In my code, every variable I decleared has been used in constrains or objection. Thank you.

(20 Aug '12, 02:47) Ximenes

The first thing I would try is putting a try-catch around the line where you print out y[i][j]. In the catch block, print a message saying which values of i and j caused the exception.

If it turns out that's not where the exception occurs (I'm betting it is), then split your code (perhaps into the chunks you already have separated by blank lines) and put each chunk inside its own try-catch block, rather than putting it all inside one try. Print a different message in each catch, so that you know which block suffered the exception.

(20 Aug '12, 08:20) Paul Rubin ♦♦
1

OOPS! Never mind. I just noticed that you never extracted the model. You have made no connection between 'model' and 'cplex', so when you call cplex.solve() it is solving an empty problem. Either declare cplex with IloCplex cplex(model) or add cplex.extract(model) before calling solve().

(20 Aug '12, 08:25) Paul Rubin ♦♦

Yes, I forgot to extract the model. How dare I make such a stupid mistake. Thank you so much, professor. You are so considerate and so helpful. Thank you!

(20 Aug '12, 11:31) Ximenes

Thank you very much, professor Paul. I got the same error and struggled with it for some days. finally, I found the mistake. some of the variables I declared didn't used in the constrains. Now, it is OK. Thank you!

(24 May '13, 04:56) bairg
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×191
×30
×2

Asked: 19 Aug '12, 11:17

Seen: 2,551 times

Last updated: 24 May '13, 05:12

OR-Exchange! Your site for questions, answers, and announcements about operations research.