Update type of elements in QAP eval and QAP incrEval
This commit is contained in:
parent
dbb8fbe9a7
commit
c9475c4ed0
6 changed files with 79 additions and 32 deletions
|
|
@ -71,6 +71,8 @@ public:
|
|||
consecutiveTables();
|
||||
else
|
||||
randomTables();
|
||||
|
||||
generateTables();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -365,6 +367,20 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To generate the tables:
|
||||
* The component function is random
|
||||
* each contribution is independent from the others ones
|
||||
* and drawn from the distribution given by contribution()
|
||||
*
|
||||
*/
|
||||
virtual void generateTables() {
|
||||
for(int i = 0; i < N; i++) {
|
||||
for(int j = 0; j < (1<<(K+1)); j++)
|
||||
tables[i][j] = contribution();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To generate a contribution in the table f_i
|
||||
*
|
||||
|
|
@ -386,10 +402,6 @@ protected:
|
|||
for(int i = 0; i < N; i++) {
|
||||
// random links to the bit
|
||||
choose(i, tabTirage);
|
||||
|
||||
// table of contribution with random numbers from [0,1)
|
||||
for(int j = 0; j < (1<<(K+1)); j++)
|
||||
tables[i][j] = contribution();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -403,10 +415,6 @@ protected:
|
|||
for(int i = 0; i < N; i++) {
|
||||
// consecutive link to bit i
|
||||
consecutiveLinks(i);
|
||||
|
||||
// table of contribution with random numbers from [0,1)
|
||||
for(int j = 0; j < (1<<(K+1)); j++)
|
||||
tables[i][j] = contribution();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ public:
|
|||
using nkLandscapesEval<EOT>::loadTables;
|
||||
using nkLandscapesEval<EOT>::consecutiveTables;
|
||||
using nkLandscapesEval<EOT>::randomTables;
|
||||
using nkLandscapesEval<EOT>::generateTables;
|
||||
|
||||
// parameter p : probability to have the contribution to zero, otherwise random number from [0,1)
|
||||
double p;
|
||||
|
|
@ -79,6 +80,8 @@ public:
|
|||
consecutiveTables();
|
||||
else
|
||||
randomTables();
|
||||
|
||||
generateTables();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ public:
|
|||
using nkLandscapesEval<EOT>::loadTables;
|
||||
using nkLandscapesEval<EOT>::consecutiveTables;
|
||||
using nkLandscapesEval<EOT>::randomTables;
|
||||
using nkLandscapesEval<EOT>::generateTables;
|
||||
|
||||
// parameter q : number of different integer values in the table: [0..q[
|
||||
unsigned q;
|
||||
|
|
@ -78,6 +79,8 @@ public:
|
|||
consecutiveTables();
|
||||
else
|
||||
randomTables();
|
||||
|
||||
generateTables();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -34,11 +34,14 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
|
||||
/**
|
||||
* Full evaluation Function for QAP problem
|
||||
*
|
||||
* ElemType is the type of elements in the matrix. This type must be signed and not unsigned.
|
||||
*/
|
||||
template< class EOT >
|
||||
template< class EOT, typename ElemType = long int >
|
||||
class QAPeval : public eoEvalFunc<EOT>
|
||||
{
|
||||
public:
|
||||
//typedef typename EOT::Fitness ElemType ;
|
||||
|
||||
/*
|
||||
* Constructor from instance file
|
||||
|
|
@ -56,18 +59,18 @@ public:
|
|||
unsigned i, j;
|
||||
|
||||
file >> n;
|
||||
A = new int *[n];
|
||||
B = new int *[n];
|
||||
A = new ElemType *[n];
|
||||
B = new ElemType *[n];
|
||||
|
||||
for(i = 0; i < n; i++) {
|
||||
A[i] = new int[n];
|
||||
A[i] = new ElemType[n];
|
||||
for(j = 0; j < n; j++) {
|
||||
file >> A[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < n; i++) {
|
||||
B[i] = new int[n];
|
||||
B[i] = new ElemType[n];
|
||||
for(j = 0; j < n; j++)
|
||||
file >> B[i][j];
|
||||
}
|
||||
|
|
@ -100,7 +103,7 @@ public:
|
|||
* @param _solution the solution to evaluate
|
||||
*/
|
||||
void operator()(EOT & _solution) {
|
||||
int cost = 0;
|
||||
ElemType cost = 0;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
for (int j = 0; j < n; j++)
|
||||
|
|
@ -114,7 +117,7 @@ public:
|
|||
*
|
||||
* @return matrix A
|
||||
*/
|
||||
int** getA() {
|
||||
ElemType** getA() {
|
||||
return A;
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +126,7 @@ public:
|
|||
*
|
||||
* @return matrix B
|
||||
*/
|
||||
int** getB() {
|
||||
ElemType** getB() {
|
||||
return B;
|
||||
}
|
||||
|
||||
|
|
@ -141,10 +144,10 @@ private:
|
|||
int n;
|
||||
|
||||
// matrix A
|
||||
int ** A;
|
||||
ElemType ** A;
|
||||
|
||||
// matrix B
|
||||
int ** B;
|
||||
ElemType ** B;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue