+ All Categories
Home > Documents > A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations ›...

A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations ›...

Date post: 25-Jun-2020
Category:
Upload: others
View: 4 times
Download: 0 times
Share this document with a friend
22
A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady Hunsaker John Forrest Lou Hafer Robin Lougee-Heimer Ted Ralphs Matthew Saltzman [email protected] CORS/INFORMS Banff 2004 – p. 1/22
Transcript
Page 1: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

A Gentle Introduction to COIN-OR’sOptimization Solver Interface (OSI)

Brady Hunsaker

John Forrest

Lou Hafer

Robin Lougee-Heimer

Ted Ralphs

Matthew Saltzman

[email protected]

CORS/INFORMS Banff 2004 – p. 1/22

Page 2: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Outline

COIN-OR and OSI

Using OSI in your code

Examples and possibilities

Accessing documentation

Downloading, configuring, and compiling OSI

Asking for help

CORS/INFORMS Banff 2004 – p. 2/22

Page 3: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

What is COIN-OR?

COmputational INfrastructure for Operations Research.

A consortium of researchers and practitionersdedicated to improving the state of computationalresearch in OR.

An initiative promoting the development and use ofinteroperable, open-source software for operationsresearch.

A repository of open-source software for OR.

Incorporated as the COIN-OR Foundation, Inc., inMarch, 2004. Nonprofit application pending.

CORS/INFORMS Banff 2004 – p. 3/22

Page 4: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

The COIN-OR Repository

A library of interoperable software tools for buildingoptimization codes, as well as several stand-alonepackages.

A venue for peer review of OR software tools.

A development platform for open-source projects,including a CVS repository.

Currently hosted by IBM, in process of moving toINFORMS.

CORS/INFORMS Banff 2004 – p. 4/22

Page 5: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Some COIN-OR Components

OSI an open solver interface layer

COIN COIN-OR utility library

BCP a parallel branch-cut-price framework

CGL a cut generation library

SBB Simple Branch and Bound, a branch and cut code

CLP COIN LP, a native simplex solver

VOL the Volume Algorithm

CORS/INFORMS Banff 2004 – p. 5/22

Page 6: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Optimization Solver Interface (OSI)

Uniform interface to LP/IP solvers:

CLP (COIN-OR)

CPLEX (ILOG)

dylp (dynamic LP; BonsaiG LP Solver)

GLPK (GNU LP Kit)

OSL (IBM)

SoPlex (Konrad-Zuse-Zentrum für InformationstechnikBerlin)

Volume (COIN-OR)

XPRESS (Dash Optimization)

CORS/INFORMS Banff 2004 – p. 6/22

Page 7: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Reasons to use COIN-OR OSI

Learn one API for many solvers

Perform development with ‘white box’ open sourcesolvers.

Switch easily from one solver to another

CORS/INFORMS Banff 2004 – p. 7/22

Page 8: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Steps to use OSI

1. Download source code

2. Configure based on available solvers

3. Compile

4. Create a makefile for your project (optional)

5. Use OSI in your code

CORS/INFORMS Banff 2004 – p. 8/22

Page 9: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

C++ basics

Related data and functions (methods) are groupedtogether into objects

Usually, data in objects is accessed through functions

In OSI, the main objects come from the classOsiSolverInterface

Function calls are referenced similar to structures in C.Say the object is OsiSolverInterface *si

si->getObjValue()

si.getObjValue() if si is not a pointer

CORS/INFORMS Banff 2004 – p. 9/22

Page 10: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Online C++ references

C++ Annotations by Frank B. Brokken; intended forpeople who know C and want to learn C++.

http://www.icce.rug.nl/documents/cplusplus/cplusplus.html

C/C++ Reference, http://www.cppreference.com/

CORS/INFORMS Banff 2004 – p. 10/22

Page 11: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Using OSI

Solver dependent parts:

Include the header files for solver(s) you want to use.

Create an OsiXxxSolverInterface object.

Solver independent:

Call functions to load/create a problem.

Call functions to solve the problem.

Call functions to report on the solution, modify theproblem and re-solve, or do something else

CORS/INFORMS Banff 2004 – p. 11/22

Page 12: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

A simple example: basic.cpp

Read MPS file and solve.

si->readMps("p0033")

si->initialSolve()

si->isProvenOptimal()

si->getObjValue()

si->getNumCols()

si->getColSolution()

CORS/INFORMS Banff 2004 – p. 12/22

Page 13: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Changing solvers is easy: basic2.cpp

Change the include file

Change the instantiation of the object

CORS/INFORMS Banff 2004 – p. 13/22

Page 14: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Querying the interface: query.cpp

si->getNumRows()

si->getNumCols()

si->getNumElements()

si->getColUpper()

si->getIterationCount()

si->isProvenPrimalInfeasible()

si->isProvenDualInfeasible()

si->isIterationLimitReached()

There are many more.

CORS/INFORMS Banff 2004 – p. 14/22

Page 15: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Setting some parameters: parameters.cpp

si->setIntParam( OsiMaxNumIteration, 10)

si->setDblParam( OsiPrimalTolerance,0.001)

si->getStrParam( OsiSolverName, solver)

CORS/INFORMS Banff 2004 – p. 15/22

Page 16: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Building an instance: build.cpp

Uses the COIN utility library to work with sparse vectors andsparse matrices.

Must include needed header files

Two new classes: CoinPackedVector andCoinPackedMatrix

Each has its own methodsrow1.insert(0, 1.0);

matrix->setDimensions(0, n_cols);

matrix->appendRow(row1);

Documentation also available for these classes.

si->loadProblem(*matrix, col_lb, ... )CORS/INFORMS Banff 2004 – p. 16/22

Page 17: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Solver-specific functions: specific.cpp

This depends on the specific solver interface.

clpPointer =(dynamic_cast<OsiClpSolverInterface*>(si))->getModelPtr();

clpPointer->setLogLevel(0)

In CPLEX, for example, you need to get the model pointerand environment pointer—there is a method to retrieveeach.

CORS/INFORMS Banff 2004 – p. 17/22

Page 18: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Other features of OSI

Several methods for loading problems

Re-solve after modifying problem

Integer programs

“Hints” for presolving, scaling, using dual simplex

Warm starts and hot starts

Simplex-level controls for basis, pivots, etc. (currentlyonly implemented for CLP, I think)

CORS/INFORMS Banff 2004 – p. 18/22

Page 19: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Accessing documentation

Most documentation is extracted from the code itselfusing doxygen.

make doc will generate documentation locally (on yourcomputer) in HTML format. You can easily adddocumentation for your modifications and additions.

Some tutorial examples and links to the documentationavailable at http://sagan.ie.lehigh.edu/coin/(maintained by Matt Galati)

Also available online at COIN-OR website:http://www.coin-or.org/

CORS/INFORMS Banff 2004 – p. 19/22

Page 20: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Downloading, Configuring, Compiling

Download tarball from www.coin-or.org.

Repository can also be accessed with CVS.

Configuration in the Makefiles directory

Edit Makefile.location to tell COIN-OR which solversare available and where they areEdit Makefile.<platform> (e.g. Makefile.Linux,Makefile.SunOS) if you want to control the compiler,linker, etc. The default settings are probably OK.

CORS/INFORMS Banff 2004 – p. 20/22

Page 21: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Compiling, Makefiles

Compile with the command make in the directory Coinand then Osi. May need to do make in subdirectories ofOsi as well, such as OsiGlpk and OsiDylp, depending onthe solvers available.

Create a Makefile for your project that indicates thelocation of OSI headers and libraries.

CORS/INFORMS Banff 2004 – p. 21/22

Page 22: A Gentle Introduction to COIN-OR’s Optimization Solver ... › Presentations › CORSINFORMS... · A Gentle Introduction to COIN-OR’s Optimization Solver Interface (OSI) Brady

Asking for help

We want to help make your use of OSI successful!

First review the appropriate documentation—the answermay be there.

Send email to [email protected] address is likely to change soon–checkwww.coin-or.org before sending.

In your email, give as much detail as you can:Operating systemCOIN-OR modules (OSI, CLP, etc.)SolversError messages

CORS/INFORMS Banff 2004 – p. 22/22


Recommended