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;
|
||||
|
||||
// creation of the clauses
|
||||
clauses = new vector<int>[nbClauses];
|
||||
clauses = new std::vector<int>[nbClauses];
|
||||
|
||||
// the variables are numbered from 1 to nbVar
|
||||
variables = new vector<int>[nbVar + 1];
|
||||
variables = new std::vector<int>[nbVar + 1];
|
||||
|
||||
//int var[nbVar];
|
||||
std::vector<int> var;
|
||||
|
|
@ -107,18 +107,18 @@ public:
|
|||
*
|
||||
* @param _fileName file name of the instance in cnf format
|
||||
*/
|
||||
MaxSATeval(string & _fileName) {
|
||||
fstream file(_fileName.c_str(), ios::in);
|
||||
MaxSATeval(std::string & _fileName) {
|
||||
std::fstream file(_fileName.c_str(), std::ios::in);
|
||||
|
||||
if (!file) {
|
||||
string str = "MaxSATeval: Could not open file [" + _fileName + "]." ;
|
||||
throw runtime_error(str);
|
||||
std::string str = "MaxSATeval: Could not open file [" + _fileName + "]." ;
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
|
||||
string s;
|
||||
std::string s;
|
||||
|
||||
// commentaries
|
||||
string line;
|
||||
std::string line;
|
||||
file >> s;
|
||||
while (s[0] == 'c') {
|
||||
getline(file,line,'\n');
|
||||
|
|
@ -127,23 +127,23 @@ public:
|
|||
|
||||
// parameters
|
||||
if (s[0] != 'p') {
|
||||
string str = "MaxSATeval: could not read the parameters of the instance from file [" + _fileName + "]." ;
|
||||
throw runtime_error(str);
|
||||
std::string str = "MaxSATeval: could not read the parameters of the instance from file [" + _fileName + "]." ;
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
file >> s;
|
||||
if (s != "cnf") {
|
||||
string str = "MaxSATeval: " + _fileName + " is not a file in cnf format.";
|
||||
throw runtime_error(str);
|
||||
std::string str = "MaxSATeval: " + _fileName + " is not a file in cnf format.";
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
|
||||
file >> nbVar >> nbClauses;
|
||||
nbLitteral = 0; // could be different from one clause to antoher, so no value
|
||||
|
||||
// creation of the clauses
|
||||
clauses = new vector<int>[nbClauses];
|
||||
clauses = new std::vector<int>[nbClauses];
|
||||
|
||||
// the variables are numbered from 1 to nbVar
|
||||
variables = new vector<int>[nbVar + 1];
|
||||
variables = new std::vector<int>[nbVar + 1];
|
||||
|
||||
// read the clauses
|
||||
int number;
|
||||
|
|
@ -182,20 +182,20 @@ public:
|
|||
*
|
||||
* @param _fileName file name to export the instance
|
||||
*/
|
||||
void save(string & _fileName) {
|
||||
fstream file(_fileName.c_str(), ios::out);
|
||||
void save(std::string & _fileName) {
|
||||
std::fstream file(_fileName.c_str(), std::ios::out);
|
||||
|
||||
if (!file) {
|
||||
string str = "MaxSATeval: Could not open " + _fileName;
|
||||
throw runtime_error(str);
|
||||
std::string str = "MaxSATeval: Could not open " + _fileName;
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
|
||||
// write some commentaries
|
||||
file << "c random max k-SAT generated by maxSATeval from paradisEO framework on sourceForge" << endl;
|
||||
file << "c "<< endl;
|
||||
file << "c random max k-SAT generated by maxSATeval from paradisEO framework on sourceForge" << std::endl;
|
||||
file << "c "<< std::endl;
|
||||
|
||||
// write the parameters
|
||||
file << "p cnf " << nbVar << " " << nbClauses << endl;
|
||||
file << "p cnf " << nbVar << " " << nbClauses << std::endl;
|
||||
|
||||
// write the clauses
|
||||
unsigned int i, j;
|
||||
|
|
@ -265,12 +265,12 @@ public:
|
|||
// list of clauses:
|
||||
// each clause has the number of the variable (from 1 to nbVar)
|
||||
// when the value is negative, litteral = not(variable)
|
||||
vector<int> * clauses;
|
||||
std::vector<int> * clauses;
|
||||
|
||||
// list of variables:
|
||||
// for each variable, the list of clauses
|
||||
// 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