[TEST] HS118 no also tests for correctness of actual solution found. Removed debug statements. QPS files with ranges now work correctly.
parent
427d938631
commit
54e7e84c21
|
@ -81,20 +81,21 @@ void RawQP::addRangeSingle(
|
|||
boost::fusion::vector<std::vector<char>, std::vector<char>,
|
||||
std::vector<char>, std::vector<char>, std::vector<char>, double,
|
||||
std::vector<char>> const & vars) {
|
||||
std::cout << "SINGLE RANGE ADDED" << std::endl;
|
||||
std::string var_(at_c < 1 > (vars).begin(), at_c < 1 > (vars).end());
|
||||
std::string row_(at_c < 3 > (vars).begin(), at_c < 3 > (vars).end());
|
||||
double range = at_c < 5 > (vars);
|
||||
ranges[row_] = range;
|
||||
std::cout << "VAR:" << var_ << " ROW: " << row_ << " RANGE: " << range
|
||||
<< std::endl;
|
||||
if (debug) {
|
||||
std::cout << "SINGLE RANGE ADDED" << std::endl;
|
||||
std::cout << "VAR:" << var_ << " ROW: " << row_ << " RANGE: " << range
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
void RawQP::addRangeDouble(
|
||||
boost::fusion::vector<std::vector<char>, std::vector<char>,
|
||||
std::vector<char>, std::vector<char>, std::vector<char>, double,
|
||||
std::vector<char>, std::vector<char>, std::vector<char>, double> const & vars) {
|
||||
std::cout << "DOUBLE RANGE ADDED" << std::endl;
|
||||
std::string var_(at_c < 1 > (vars).begin(), at_c < 1 > (vars).end());
|
||||
std::string row1_(at_c < 3 > (vars).begin(), at_c < 3 > (vars).end());
|
||||
std::string row2_(at_c < 7 > (vars).begin(), at_c < 7 > (vars).end());
|
||||
|
@ -102,8 +103,11 @@ void RawQP::addRangeDouble(
|
|||
double range2 = at_c < 9 > (vars);
|
||||
ranges[row1_] = range1;
|
||||
ranges[row2_] = range2;
|
||||
std::cout << "VAR: " << var_ << " ROW1: " << row1_ << " RANGE1: " << range1
|
||||
<< " ROW2: " << row2_ << " RANGE2: " << range2 << std::endl;
|
||||
if (debug) {
|
||||
std::cout << "DOUBLE RANGE ADDED" << std::endl;
|
||||
std::cout << "VAR: " << var_ << " ROW1: " << row1_ << " RANGE1: " << range1
|
||||
<< " ROW2: " << row2_ << " RANGE2: " << range2 << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -285,12 +285,14 @@ TEST(QPSolver, HS118) {
|
|||
QP problem = QPSParser("HS118.QPS").Parse();
|
||||
VectorValues actualSolution;
|
||||
VectorValues expectedSolution;
|
||||
// expectedSolution.insert(Symbol('X',1), 2.0*I_1x1);
|
||||
// expectedSolution.insert(Symbol('X',2), 0.0*I_1x1);
|
||||
double solutionValues[15] = {8,49,3,1,56,0,1,63,6,3,70,12,5,77,18};
|
||||
for (int index = 0; index < 15; ++index) {
|
||||
expectedSolution.insert(Symbol('X',index+1), solutionValues[index]);
|
||||
}
|
||||
boost::tie(actualSolution, boost::tuples::ignore) = QPSolver(problem).optimize();
|
||||
double error_actual = problem.cost.error(actualSolution);
|
||||
CHECK(assert_equal(6.64820452e2,error_actual, 1e-7))
|
||||
// CHECK(assert_equal(expectedSolution, actualSolution))
|
||||
CHECK(assert_equal(expectedSolution, actualSolution))
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
Loading…
Reference in New Issue