#include //#include //#include #include using namespace std; #include "OsiClpSolverInterface.hpp" int main(int argc, char** args) { OsiClpSolverInterface m; /* Wolsey : Page 130 max 4x1 - x2 7x1 - 2x2 <= 14 x2 <= 3 2x1 - 2x2 <= 3 x1 in Z+, x2 >= 0 */ double inf_ = m.getInfinity(); int n_cols = 2; int n_rows = 3; double obj[2] = {-4.0, 1.0}; double collb[2] = {0.0, 0.0}; double colub[2] = {inf_, inf_}; double rowlb[3] = {-inf_, -inf_, -inf_}; double rowub[3] = {14.0, 3.0, 3.0}; int rowIndices[5] = {0, 2, 0, 1, 2}; int colIndices[5] = {0, 0, 1, 1, 1}; double elements[5] = {7.0, 2.0, -2.0, 1.0, -2.0}; CoinPackedMatrix M(true, rowIndices, colIndices, elements, 5); m.loadProblem(M, collb, colub, obj, rowlb, rowub); m.enableSimplexInterface(true); m.initialSolve(); cout << "Dual of first row: " << m.getRowPrice()[0] << endl; cout << endl; m.setRowBounds(0, -inf_, 15); m.getModelPtr()->checkSolution(); cout << "Primal infeasibilities: " << m.getModelPtr()->numberPrimalInfeasibilities() << '\t' << m.getModelPtr()->sumPrimalInfeasibilities() << endl; cout << "Dual infeasibilities: " << m.getModelPtr()->numberDualInfeasibilities() << '\t' << m.getModelPtr()->sumDualInfeasibilities() << endl; cout << "Proven Optimal: " << m.isProvenOptimal() << "\t Abandoned: " << m.isAbandoned() << endl; m.resolve(); cout << "Dual of first row: " << m.getRowPrice()[0] << endl; cout << endl; m.setRowBounds(0, -inf_, 13); m.getModelPtr()->checkSolution(); cout << "Primal infeasibilities: " << m.getModelPtr()->numberPrimalInfeasibilities() << '\t' << m.getModelPtr()->sumPrimalInfeasibilities() << endl; cout << "Dual infeasibilities: " << m.getModelPtr()->numberDualInfeasibilities() << '\t' << m.getModelPtr()->sumDualInfeasibilities() << endl; cout << "Proven Optimal: " << m.isProvenOptimal() << "\t Abandoned: " << m.isAbandoned() << endl; m.resolve(); cout << "Dual of first row: " << m.getRowPrice()[0] << endl; return 0; }