Bonsoir à tous ;
j'ai un petit problème avec mon application console ,j'éspère trouver de l'aide ici .
j'utilise visual studio express 2008 , lorsque je compile mon programme on m'affiche qu'il y'a 0 erreurs .
Cependant quand je veux voir mes résultat ( dans l'écran noir ) je clique sur "démarrer débogueur " et là y'a une fenètre qui em dit qu'il y'a une exception non géré , et qui pointe sur une ligne de mon code !!
j'ai fait une prise d'écran ici :
https://i70.servimg.com/u/f70/18/22/56/58/prise_11.jpg
mon code est :
#include "ilcplex\ilocplex.h"
#include <stdlib.h>
#include <time.h >
#include <stdio.h>
#include <iostream>
using namespace std ;
typedef IloArray<IloNumVarArray> NumVarMatrix;
ILOSTLBEGIN
int main(int argc, char** argv) {
srand( time( NULL ) );
IloEnv env;
try {
IloInt nbjobs=5;
IloInt nbmachines=2;
IloInt j,k;
int tab[5][2];
cout << "la matrice des temps de traitement est " << endl ;
for (k=0;k<2;k++)
{for (j=0;j<5;j++)
{ tab [j][k]=rand()%99;
cout << tab[j][k] <<" ";
}
cout << " " << "\n" ;
}
IloModel model(env);
// creation of variables
NumVarMatrix x(env, nbjobs);
NumVarMatrix I(env, nbmachines-1);
NumVarMatrix w(env, nbmachines-1);
// 1 : variable x
for (j = 0; j < nbjobs; j++)
{
x[j] = IloNumVarArray(env, nbjobs, 0,1, ILOINT);
}
// 2: variable I and W
for (j = 0; j < nbmachines-1; j++)
{
I[j] = IloNumVarArray (env,nbjobs-1,0,100000,ILOFLOAT);
w[j] = IloNumVarArray (env,nbjobs-1,0,100000,ILOFLOAT) ;
}
//constraint 1 :
IloExpr expr(env);
for (int k=0;k<nbjobs;k++)
{
for (int i = 0; i <nbjobs; i++)
{
expr +=x[i][k] ;
}
model.add(expr == 1);
expr.end();
}
//constraint 2 :
IloExpr expr1(env);
for (int i = 0; i <nbjobs; i++)
{
expr1 =x[i][0] ;
for (int k=1;k<nbjobs;k++)
{
expr1 +=x[i][k] ;
}
model.add(expr1 == 1);
expr1.end();
}
// constraint 3 :
IloExpr expr2(env);
for (int k=0;k<nbjobs-1;k++)
{expr2 =I[1][k] ;
model.add(expr2 == 0);
expr2.end();
}
//constraint 4 :
IloExpr expr3(env);
for (int k=0;k<nbmachines-1;k++)
{
expr3 =w[k][1] ;
model.add(expr3 == 0);
expr3.end();
}
//constraint 5 :
IloExpr expr4(env);
IloExpr expr5(env);
IloExpr expr6(env);
IloExpr expr7(env);
for (int j=0;j<nbmachines-1;j++)
{
for (int k=0;k<nbjobs-1;k++)
{for (int i=0;i<nbjobs;i++)
{
expr4 +=x[i][k+1]*tab[i][j] ;
expr6 += x[i][k]*tab[i][j+1];
}
expr5 = expr4 + w[j][k+1]+I[j][k];
expr7=expr6+w[j][k]+I[j+1][k] ;
model.add(expr5 == expr7);
expr4.end();
expr5.end();
expr6.end();
expr7.end();
}
}
//objective function :
IloExpr expr8(env);
for (int i = 0; i <nbjobs; i++)
{
for (int j=0;j<nbmachines-1;j++)
{
expr8 +=x[i][1]*tab[i][j] ;
}
}
IloExpr expr9(env);
for (int i=0;i<nbjobs-1;i++)
{
expr9 +=I[nbmachines][i];
}
model.add(IloMinimize(env, expr8+expr9));
expr8.end();
expr9.end();
///////////////////////////////////////////////////////////////////////////////resolution :
IloCplex cplex(model);
cplex.solve ();
cplex.getStatus ();
}
catch (IloException& e) {
cerr << "Concert Exception: " << e << endl;
} catch (...) {
cerr << "Other Exception" << endl;
}
env.end();
system ("pause");
} // END main
Que dois je faire ? où est l'erreur selon vous ? :-(
Merci pour toute tentative d'aide ^^
Afficher la suite