Download presentation

Presentation is loading. Please wait.

Published byLucy Homewood Modified over 2 years ago

1
COIN-OR Open Solver Interface EURO XXI in Iceland 21st European Conference on Operational Research July 5, 2006

2
EURO XXI Open Solver Interface (OSI) What is the COIN-OR OSI? How is it used? Gotchas Summary

3
EURO XXI What? OSI provides a uniform interface to many LP solvers The goal is to isolate an application from a specific solver. An application written to the OSI should be able to easily change solvers. Clp: OsiClp CPLEX: OsiCpx DyLP: OsiDylp FortMP: OsiFmp GLPK: OsiGlpk MOSEK: OsiMsk OSL: OsiOsl SoPlex: OsiSpx SYMPHONY: OsiSym Vol: OsiVol XPRESS-MP OsiXpr

4
EURO XXI How is it used OSI is a C++ abstract base class An implementation for a specific solver inherits from the OSI base class. For example: OsiClp inherits from Osi.

5
EURO XXI Example: Simple LP minimize -1x 0 - 1x 1 such that 1x 0 + 2x 1 <= 3 2x 0 + 1x 1 <= 3 x 0 >= 0 x 1 >= 0

6
EURO XXI Defining LP Model – obj. & col. bounds //Define objective coefficients. minimize -1 x0 - 1 x1 int n_cols = 2; double *objective = new double[n_cols]; objective[0] = -1.0; objective[1] = -1.0; // Define column bounds // 0 <= x0 <= infinity // 0 <= x1 <= infinity double *col_lb = new double[n_cols]; //the column lower bounds double *col_ub = new double[n_cols]; //the column upper bounds col_lb[0] = 0.0; col_lb[1] = 0.0; OsiSolverInterface *si = new OsiClpSolverInterface; col_ub[0] = si->getInfinity(); col_ub[1] = si->getInfinity();

7
EURO XXI Defining LP Model – rows //Define the constraint matrix. CoinPackedMatrix *matrix = new CoinPackedMatrix(false,0,0); matrix->setDimensions(0, n_cols); // -infinity <= 1 x0 + 2 x2 <= 3 CoinPackedVector row1; row1.insert(0, 1.0); row1.insert(1, 2.0); matrix->appendRow(row1); //-infinity <= 2 x0 + 1 x1 <= 3 CoinPackedVector row2; row2.insert(0, 2.0); row2.insert(1, 1.0); matrix->appendRow(row2); // Define Row Bounds int n_rows = 2; double *row_lb = new double[n_rows]; //the row lower bounds double *row_ub = new double[n_rows]; //the row upper bounds row_lb[0] = -1.0 * si->getInfinity(); row_ub[0] = 3.0; row_lb[1] = -1.0 * si->getInfinity(); row_ub[1] = 3.0;

8
EURO XXI Pass Model to OSI, Solve, get solution //load the problem to OSI si->loadProblem(*matrix, col_lb, col_ub, objective, row_lb, row_ub); //write the MPS file to a file called example.mps si->writeMps("example"); // Solve the (relaxation of the) problem si->initialSolve(); // Check the solution if ( si->isProvenOptimal() ) { cout getObjValue() <

9
EURO XXI Example: Cut Generation Library 1. Read mps file to define model 2. Solve lp 3. Generate cuts 4. If no new cuts generated then done 5. Add new cuts to model 6. Resolve LP 7. If objective function value changes continue with step 3

10
EURO XXI Read MPS file and initial solve OsiClpSolverInterface si; si.readMps(p0033.mps,"mps"); // Solve continuous problem si.initialSolve(); // Instantiate cut generators CglKnapsackCover knapsackCoverCg; CglSimpleRounding simpleRoundingCg;

11
EURO XXI Read MPS file and initial solve do { // Generate and apply cuts OsiCuts cuts; knapsackCoverCg.generateCuts(si,cuts); simpleRoundingCg.generateCuts(si,cuts); OsiSolverInterface::ApplyCutsReturnCode acRc = si.applyCuts(cuts,0.0); // If no cuts were applied, then done if ( acRc.getNumApplied()==0 ) break; // Resolve double obj = si.getObjValue(); // Grab obj value before resolve si.resolve(); cout <<"After applying cuts, objective value changed from " <

12
EURO XXI The Reality Osi functionality is limited compared to most LP solvers Depending on the solver and how well the solver’s derived Osi class is written there can be performance overhead Not all Osi’s behave the same (need better testing and definitions). Osi provides mechanism to get to the underlying solver

13
EURO XXI More info: www.coin-or.org These charts: www.coin-or.org/Presentations/EURO06/ matrix, vector, floatEqual classes: projects.coin-or.org/CoinUtils Osi methods: projects.coin-or.org/Osi Cgl classes: projects.coin-or.org/Cgl Examples: projects.coin-or.org/Osi/browser/trunk/Osi/examples projects.coin-or.org/Cgl/browser/trunk/Cgl/examples

Similar presentations

OK

Matrix Multiplication The Introduction. Look at the matrix sizes.

Matrix Multiplication The Introduction. Look at the matrix sizes.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on centre of gravity Ppt on trial and error problem Ppt on natural and human nature Ppt on idiopathic thrombocytopenia purpura in children Ppt on endangered and extinct species in india Ppt on artificial intelligence and robotics Ppt on harmful effects of fast food Download small ppt on global warming Ppt on political parties and electoral process in the philippines Ppt on solar energy pdf