Violation d'accès lors de la lecture de l'emplacement 0x0000001c

Violation d'accès lors de la lecture de l'emplacement 0x0000001c - C++ - Programmation

Marsh Posté le 04-12-2013 à 04:28:25    

Salut tout le monde!
 
j'utilise Gecode comme solveur de mon modèle , mais mon code me donne cette erreur :

Code :
  1. Access Violation when reading of the location 0x0000001c


 
voici mon code:
 

Code :
  1. #include <gecode/driver.hh>
  2. #include <gecode/int.hh>
  3. #include <gecode/minimodel.hh>
  4. #include <iostream>
  5. #include <vector>
  6. using namespace Gecode;
  7. using namespace std;
  8. class manel : public MaximizeScript {
  9. protected:
  10.   IntVar gain1;
  11.   static const int n=6;//nbre des testeurs  
  12.   static const int m=6;//  nbre des noeuds
  13.         IntVarArray a;
  14. public:
  15.   manel(void)
  16.       : a(*this,m*n,0,1),gain1(*this,0,100000) {
  17.         Matrix <IntVarArray> X (a,m,n);
  18.             vector<int> R1;
  19.             R1.push_back(20);R1.push_back(10);R1.push_back(15);R1.push_back(5);R1.push_back(25);R1.push_back(30);
  20.         vector<int> C1;
  21.             C1.push_back(50);C1.push_back(30);C1.push_back(15);C1.push_back(15);C1.push_back(60);C1.push_back(20);
  22.         vector<int> B1;
  23.             B1.push_back(10);B1.push_back(15);B1.push_back(40);B1.push_back(50);B1.push_back(60);B1.push_back(70);
  24.         vector<int> Dr1;
  25.             Dr1.push_back(1);Dr1.push_back(1);Dr1.push_back(10);Dr1.push_back(5);Dr1.push_back(15);Dr1.push_back(15);
  26.         vector<int> Dc1;
  27.             Dc1.push_back(1);Dc1.push_back(2);Dc1.push_back(20);Dc1.push_back(15);Dc1.push_back(15);Dc1.push_back(15);
  28.         vector<int> Db1;
  29.             Db1.push_back(1);Db1.push_back(2);Db1.push_back(10);Db1.push_back(10);Db1.push_back(20);Db1.push_back(20);
  30.         int g [n][m] ;
  31.             //for(unsigned int i=0; i < n; ++i)
  32.             // g.emplace_back(std::vector<int>(m));
  33.             g[0][0]=125;g[0][1]=150;g[0][2]=1;g[0][3]=0;g[0][4]=0;g[0][5]=0;
  34.             g[1][0]=125;g[1][1]=150;g[1][2]=1;g[1][3]=0;g[1][4]=0;g[1][5]=0;
  35.             g[2][0]=125;g[2][1]=150;g[2][2]=1;g[2][3]=0;g[2][4]=0;g[2][5]=0;
  36.             g[3][0]=125;g[3][1]=150;g[3][2]=1;g[3][3]=0;g[3][4]=0;g[3][5]=0;
  37.             g[4][0]=125;g[4][1]=150;g[4][2]=1;g[4][3]=0;g[4][4]=0;g[4][5]=0;
  38.             g[5][0]=125;g[5][1]=150;g[5][2]=1;g[5][3]=0;g[5][4]=0;g[5][5]=0;
  39.         /*for(int i=0; i<n; i++)
  40.         {
  41.             for (int j =0; j<m;j++)
  42.                 g[i][j]=50;
  43.         }*/
  44.             //creation of constraints  
  45.             // ... over rows
  46.         for ( int j=0; j<n;j++)
  47.         {
  48.                 linear(*this , X.row(j),IRT_EQ,1);
  49.         }
  50.         //... over columns
  51.                  for (int i = 0; i < m; i++) {
  52.                      linear(*this, Dr1,X.col(i),IRT_LQ,R1[i]);
  53.                                              }
  54.                 for (int i = 0; i < m; i++) {
  55.                     linear (*this, Dc1, X.col(i), IRT_LQ,C1[i]);
  56.                                          }
  57.                  for (int i = 0; i <m; i++) {
  58.                      linear (*this, Db1, X.col(i), IRT_LQ,B1[i]);
  59.                                    }
  60.                  //objectiv function
  61.                  IntArgs res(m*n);
  62.                  IntVarArgs X1(m*n);
  63.                  IntVarArgs f(n*m);
  64.                  IntVar z;
  65.                  int count=0;
  66.                   int count1=0;
  67.                   int count2=0;
  68.                   int count3=0;
  69.                  for (int i=0; i<n; i++)
  70.                      {
  71.                          for (int j=0; j<m; j++)
  72.                          {
  73.                              res[count] = g[i][j];
  74.                              count++;
  75.                              X1[count1] = X(i,j);
  76.                              count1++;
  77.                              rel(*this,z==res[count]*X1[count1]);
  78.                              f[count2]=z;
  79.                              count2++;
  80.                          }
  81.                  }
  82.             // constraint over the objective function     
  83.          linear(*this, f, IRT_EQ, gain);*/
  84.           //Branching
  85.         branch(*this, a, INT_VAR_SIZE_MAX(), INT_VAL_MAX());
  86.   }
  87.   virtual IntVar cost(void) const {
  88.     return gain1;
  89.   }
  90.   /// Print solution
  91.   virtual void print(void) const {
  92.    std::cout << a << std::endl;
  93.   }
  94.   // Constructor for cloning \a s
  95.   manel(bool share, manel& s)
  96.     : MaximizeScript(share,s) {
  97.    // gain.update(*this, share, s.gain);
  98.     a.update(*this, share, s.a);
  99.   }
  100.   // Copy during cloning
  101.   virtual Space* copy(bool share) {
  102.     return new manel(share,*this);
  103.   }
  104. };
  105. int main(int argc, char* argv[]) {
  106.       manel* m = new manel;
  107.    if (manel* s = bab(m)) {
  108.      s->print(); delete s; //Or whatever
  109. }
  110.   system("pause" );
  111.   return 0;
  112. }


 
 
Pouvez vous m'aider pour résoudre ce problème??
 
merci d'avance


---------------
when there is a will there is a way
Reply

Marsh Posté le 04-12-2013 à 04:28:25   

Reply

Marsh Posté le 05-12-2013 à 23:45:05    

Code :
  1. int main(int argc, char* argv[])
  2. {
  3.    manel* m = new manel;
  4.    if (manel* s = bab(m))
  5.    {
  6.      s->print(); delete s; //Or whatever
  7.    }
  8.   system("pause" );
  9.   return 0;
  10. }
 

elle fait quoi ta fonction bab() ?


Message édité par in_your_phion le 05-12-2013 à 23:45:42
Reply

Marsh Posté le 08-12-2013 à 13:47:17    

lignes 18, 20, 22, 24, 26, 28 : R1, C1, B1, Dr1, Dc1, Db1 sont des vector<int> déclarés, mais ils ne sont jamais initialisés.


---------------
J'ai un string dans l'array (Paris Hilton)
Reply

Marsh Posté le 12-12-2013 à 13:02:15    

Harkonnen a écrit :

lignes 18, 20, 22, 24, 26, 28 : R1, C1, B1, Dr1, Dc1, Db1 sont des vector<int> déclarés, mais ils ne sont jamais initialisés.


Ben si: la ligne suivante?
 


---------------
Seul Google le sait...
Reply

Marsh Posté le 16-12-2013 à 21:13:35    

breizhbugs a écrit :


Ben si: la ligne suivante?

 



Au temps pour moi,  je m'attendais à trouver un new. Déformation de C#-eux [:tinostar]


---------------
J'ai un string dans l'array (Paris Hilton)
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed