ajout de std::
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1914 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
a5762fc203
commit
2c01c89a03
1 changed files with 23 additions and 23 deletions
|
|
@ -55,10 +55,10 @@ public:
|
||||||
nbLitteral = _k;
|
nbLitteral = _k;
|
||||||
|
|
||||||
// creation of the clauses
|
// creation of the clauses
|
||||||
clauses = new vector<int>[nbClauses];
|
clauses = new std::vector<int>[nbClauses];
|
||||||
|
|
||||||
// the variables are numbered from 1 to nbVar
|
// the variables are numbered from 1 to nbVar
|
||||||
variables = new vector<int>[nbVar + 1];
|
variables = new std::vector<int>[nbVar + 1];
|
||||||
|
|
||||||
//int var[nbVar];
|
//int var[nbVar];
|
||||||
std::vector<int> var;
|
std::vector<int> var;
|
||||||
|
|
@ -107,18 +107,18 @@ public:
|
||||||
*
|
*
|
||||||
* @param _fileName file name of the instance in cnf format
|
* @param _fileName file name of the instance in cnf format
|
||||||
*/
|
*/
|
||||||
MaxSATeval(string & _fileName) {
|
MaxSATeval(std::string & _fileName) {
|
||||||
fstream file(_fileName.c_str(), ios::in);
|
std::fstream file(_fileName.c_str(), std::ios::in);
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
string str = "MaxSATeval: Could not open file [" + _fileName + "]." ;
|
std::string str = "MaxSATeval: Could not open file [" + _fileName + "]." ;
|
||||||
throw runtime_error(str);
|
throw std::runtime_error(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
string s;
|
std::string s;
|
||||||
|
|
||||||
// commentaries
|
// commentaries
|
||||||
string line;
|
std::string line;
|
||||||
file >> s;
|
file >> s;
|
||||||
while (s[0] == 'c') {
|
while (s[0] == 'c') {
|
||||||
getline(file,line,'\n');
|
getline(file,line,'\n');
|
||||||
|
|
@ -127,23 +127,23 @@ public:
|
||||||
|
|
||||||
// parameters
|
// parameters
|
||||||
if (s[0] != 'p') {
|
if (s[0] != 'p') {
|
||||||
string str = "MaxSATeval: could not read the parameters of the instance from file [" + _fileName + "]." ;
|
std::string str = "MaxSATeval: could not read the parameters of the instance from file [" + _fileName + "]." ;
|
||||||
throw runtime_error(str);
|
throw std::runtime_error(str);
|
||||||
}
|
}
|
||||||
file >> s;
|
file >> s;
|
||||||
if (s != "cnf") {
|
if (s != "cnf") {
|
||||||
string str = "MaxSATeval: " + _fileName + " is not a file in cnf format.";
|
std::string str = "MaxSATeval: " + _fileName + " is not a file in cnf format.";
|
||||||
throw runtime_error(str);
|
throw std::runtime_error(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
file >> nbVar >> nbClauses;
|
file >> nbVar >> nbClauses;
|
||||||
nbLitteral = 0; // could be different from one clause to antoher, so no value
|
nbLitteral = 0; // could be different from one clause to antoher, so no value
|
||||||
|
|
||||||
// creation of the clauses
|
// creation of the clauses
|
||||||
clauses = new vector<int>[nbClauses];
|
clauses = new std::vector<int>[nbClauses];
|
||||||
|
|
||||||
// the variables are numbered from 1 to nbVar
|
// the variables are numbered from 1 to nbVar
|
||||||
variables = new vector<int>[nbVar + 1];
|
variables = new std::vector<int>[nbVar + 1];
|
||||||
|
|
||||||
// read the clauses
|
// read the clauses
|
||||||
int number;
|
int number;
|
||||||
|
|
@ -182,20 +182,20 @@ public:
|
||||||
*
|
*
|
||||||
* @param _fileName file name to export the instance
|
* @param _fileName file name to export the instance
|
||||||
*/
|
*/
|
||||||
void save(string & _fileName) {
|
void save(std::string & _fileName) {
|
||||||
fstream file(_fileName.c_str(), ios::out);
|
std::fstream file(_fileName.c_str(), std::ios::out);
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
string str = "MaxSATeval: Could not open " + _fileName;
|
std::string str = "MaxSATeval: Could not open " + _fileName;
|
||||||
throw runtime_error(str);
|
throw std::runtime_error(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write some commentaries
|
// write some commentaries
|
||||||
file << "c random max k-SAT generated by maxSATeval from paradisEO framework on sourceForge" << endl;
|
file << "c random max k-SAT generated by maxSATeval from paradisEO framework on sourceForge" << std::endl;
|
||||||
file << "c "<< endl;
|
file << "c "<< std::endl;
|
||||||
|
|
||||||
// write the parameters
|
// write the parameters
|
||||||
file << "p cnf " << nbVar << " " << nbClauses << endl;
|
file << "p cnf " << nbVar << " " << nbClauses << std::endl;
|
||||||
|
|
||||||
// write the clauses
|
// write the clauses
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
@ -265,12 +265,12 @@ public:
|
||||||
// list of clauses:
|
// list of clauses:
|
||||||
// each clause has the number of the variable (from 1 to nbVar)
|
// each clause has the number of the variable (from 1 to nbVar)
|
||||||
// when the value is negative, litteral = not(variable)
|
// when the value is negative, litteral = not(variable)
|
||||||
vector<int> * clauses;
|
std::vector<int> * clauses;
|
||||||
|
|
||||||
// list of variables:
|
// list of variables:
|
||||||
// for each variable, the list of clauses
|
// for each variable, the list of clauses
|
||||||
// when the value is negative, litteral = not(variable) in this clause
|
// when the value is negative, litteral = not(variable) in this clause
|
||||||
vector<int> * variables;
|
std::vector<int> * variables;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue