[Cbc-tickets] [COIN-OR Branch-and-Cut MIP Solver] #101: error in processing of input in callCbc1
COIN-OR Branch-and-Cut MIP Solver
coin-trac at coin-or.org
Tue Oct 19 03:13:23 EDT 2010
#101: error in processing of input in callCbc1
------------------+---------------------------------------------------------
Reporter: mkaut | Type: defect
Status: new | Priority: major
Version: 2.5 | Keywords:
------------------+---------------------------------------------------------
There is an error in the way callCbc1 processing the Cbc input parameters:
only the first parameter is processed.
This concerns the
{{{
int callCbc1(const char * input2, CbcModel & model,
int callBack(CbcModel * currentSolver, int whereFrom))
}}}
function from file `CbcSolver.cpp`, lines 1020-1066 in release 2.5.0.
I think there should be an `i++` statement somewhere after line 1060.
Without it, the `saveI` for the next token points at the `'\0'` character,
so all further tokens are returned as empty strings..[[BR]]
In addition, the `input[0] == '0'` at line 1025 is almost surely wrong - I
think we should have tested for a space there.
Anyway, I think the code is unnecessarily complicated (and hence prone to
errors) and would thus suggest to replace lines 1023-1066 with something
like
{{{
istringstream cbcArgStr(input2);
vector<string> cbcArgVect;
copy(istream_iterator<string>(cbcArgStr),
istream_iterator<string>(),
back_inserter<vector<string> >(cbcArgVect));
int n = cbcArgVect.size();
char ** argv = new char * [n+2];
argv[0]=CoinStrdup("cbc");
for (int i = 0; i < n; ++i) {
argv[i + 1] = CoinStrdup(cbcArgVect[i].c_str());
}
cbcArgVect.clear();
argv[n+1]=CoinStrdup("-quit");
}}}
(adapted from [http://stackoverflow.com/questions/236129/how-to-
split-a-string])
--
Ticket URL: <https://projects.coin-or.org/Cbc/ticket/101>
COIN-OR Branch-and-Cut MIP Solver <http://projects.coin-or.org/Cbc>
An LP-based branch-and-cut MIP solver.
More information about the Cbc-tickets
mailing list