[TEST] Added Test HS35MOD
[FEATURE] Added support for FX bounds for QPS Parsing format.release/4.3a0
parent
4ba87c59e7
commit
ac1a02337e
|
@ -0,0 +1,21 @@
|
|||
NAME HS35MOD
|
||||
ROWS
|
||||
N OBJ.FUNC
|
||||
G R------1
|
||||
COLUMNS
|
||||
C------1 OBJ.FUNC -.800000e+01 R------1 -.100000e+01
|
||||
C------2 OBJ.FUNC -.600000e+01 R------1 -.100000e+01
|
||||
C------3 OBJ.FUNC -.400000e+01 R------1 -.200000e+01
|
||||
RHS
|
||||
RHS OBJ.FUNC -.900000e+01
|
||||
RHS R------1 -.300000e+01
|
||||
RANGES
|
||||
BOUNDS
|
||||
FX BOUNDS C------2 0.500000e+00
|
||||
QUADOBJ
|
||||
C------1 C------1 0.400000e+01
|
||||
C------1 C------2 0.200000e+01
|
||||
C------1 C------3 0.200000e+01
|
||||
C------2 C------2 0.400000e+01
|
||||
C------3 C------3 0.200000e+01
|
||||
ENDATA
|
|
@ -198,6 +198,8 @@ void RawQP::addBound(
|
|||
up[varname_to_key[var_]] = number;
|
||||
else if (type_.compare(std::string("LO")) == 0)
|
||||
lo[varname_to_key[var_]] = number;
|
||||
else if (type_.compare(std::string("FX")) == 0)
|
||||
fx[varname_to_key[var_]] = number;
|
||||
else
|
||||
std::cout << "Invalid Bound Type: " << type_ << std::endl;
|
||||
|
||||
|
@ -334,6 +336,9 @@ QP RawQP::makeQP() {
|
|||
for (Key k : keys) {
|
||||
if (std::find(Free.begin(), Free.end(), k) != Free.end())
|
||||
continue;
|
||||
if (fx.count(k) == 1)
|
||||
madeQP.equalities.push_back(
|
||||
LinearEquality(k, I_1x1, fx[k] * I_1x1, dual_key_num++));
|
||||
if (up.count(k) == 1)
|
||||
madeQP.inequalities.push_back(
|
||||
LinearInequality(k, I_1x1, up[k], dual_key_num++));
|
||||
|
|
|
@ -54,12 +54,13 @@ private:
|
|||
std::string name_;
|
||||
std::unordered_map<Key, double> up;
|
||||
std::unordered_map<Key, double> lo;
|
||||
std::unordered_map<Key, double> fx;
|
||||
std::vector<Key> Free;
|
||||
const bool debug = false;
|
||||
|
||||
public:
|
||||
RawQP() :
|
||||
row_to_constraint_v(), E(), IG(), IL(), varNumber(1), b(), ranges(), g(), varname_to_key(), H(), f(), obj_name(), name_(), up(), lo(), Free() {
|
||||
row_to_constraint_v(), E(), IG(), IL(), varNumber(1), b(), ranges(), g(), varname_to_key(), H(), f(), obj_name(), name_(), up(), lo(), fx(), Free() {
|
||||
}
|
||||
|
||||
void setName(
|
||||
|
|
|
@ -303,6 +303,15 @@ TEST(QPSolver, HS35) {
|
|||
CHECK(assert_equal(1.11111111e-01,error_actual, 1e-7))
|
||||
}
|
||||
|
||||
TEST(QPSolver, HS35MOD) {
|
||||
QP problem = QPSParser("HS35MOD.QPS").Parse();
|
||||
VectorValues actualSolution;
|
||||
boost::tie(actualSolution, boost::tuples::ignore) = QPSolver(problem).optimize();
|
||||
double error_actual = problem.cost.error(actualSolution);
|
||||
CHECK(assert_equal(2.50000001e-01,error_actual, 1e-7))
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************************* */
|
||||
// Create Matlab's test graph as in http://www.mathworks.com/help/optim/ug/quadprog.html
|
||||
QP createTestMatlabQPEx() {
|
||||
|
|
Loading…
Reference in New Issue