You are on page 1of 53

COPT: A C++ Open

Optimization Library

{Zhouwang Yang,RuiminWang}@MathU
SchoolofMathematicalScience
UniversityofScienceandTechnologyofChina
ZhouwangYang RuiminWang

UniversityofScienceandTechnologyofChina(USTC)
Mathematical
Optimization
The selection of a best element from some set
of available alternatives

Long history
Fermat&Lagrange:calculusbasedformulas
Newton&Gauss:iterativemethod
Mathematical
Optimization
Various subfields
Convexprogramming
Integerprogramming
Fractionalprogramming
Nonlinearprogramming
Stochasticprogramming
Robustprogramming
Dynamicprogramming
Combinatorialoptimization
Infinitedimensionaloptimization

Mathematical
Optimization
Very useful in many fields
Industry
Bioinformatics
Financialengineering
Machinelearning/Datamining

A lot of models and algorithms


Mathematical
Optimization
A lot of similarities among different problems
Minimizeormaximizecertainenergyfunction
Specificconstraintisaskedtobesatisfied

A framework can be designed


Motivation
Huge amount of algorithms

A lot of repeated work (very low reusability)

Existing tools
Matlab optimizationtoolbox (commercial)
Scipy (free)
Variousopenlibraries(C/C++,Python,)
Motivation
Hard to follow and extend
Matlab actuallyusesCasunderlyingcode

SodoesPython

Frameworkdiffersalotfromeachotherinopen
libraries
Motivation
To build a domestic library for optimization
study

A fast implementation
Forresearchers/ followers

A good opportunity to train coding skills


Forstudents
Target
Create an optimization library
(Domestic,CreatedinChina)

Integrate existing resources

Flexible enough for different problems


Target
Open source

Crossplatform
IDEindependentskills
gcc,g++,gfotran
MakeFile orCMakeList.txt

Carefully designed interface


Benefit
Provide an easytocode framework for doing
optimizationrelated study

Enhance the communication with industry

Improve coding skills of the students in the


Society of Mathematical Programming
Why C++
Performance per $

Power: driver at all scales

Size: limits on processor resources

Experience:
biggerexperienceonsmallerhardware
Why C++
Why C++
Why C++
Efficiency

Flexibility

Abstraction

Productivity
Matlab
Not object oriented
Nounifiedformofcode
HardforEncapsulation

Interface

Commercial
Python
Efficiency
Script

Great Language
Easyforlearning

API is provided
COPT

C++
Open
Optimization
Library
Created in China
ProposedbytheSocietyofMathematicalProgramming
DevelopedbyMathU
COPT
Designer: Ruimin Wang
BachelordegreeinUSTCin2011
PhDcandidateinUSTCsince2011

Academic experience
Decouplingfeaturesandnoisesviaanalysisbasedcompressed
sensing(2012)
Shapemodelingbydrawing(2012)
Pointbaseddifferentialcomputation(2013)
Manifoldconstructionviadictionarylearning(2013)
Sparserepresentationwithparameterizationoptimization
(2014)
Sparsity ingeometry(2014)
COPT

C++ based open source library

A lot of templates are used for flexibility


AnimportantfeatureofC++

Python interface is provided


Greatfornoveluser
COPT
Brief Introduction
Carefullydesignedbasictypes
Array,VectorBase,MatrixBase
ScalarFunction,VectorFunction
Solver
Otherpeoplecanextendbyderivingthetypes
Somealgorithmsbeenimplemented
Leastsquares
BFGS

A Simple Example

Definethescalartype
A Simple Example

Definethescalartype
DefinetheArray,basicclassforvectorandmatrix
A Simple Example

Definethescalartype
DefinetheArray,basicclassforvectorandmatrix
DefinetheVectorandMatrix
Operations
Operations

Arraylikeassignment
Matlablikeassignmentisalsoallowed:
likevec1(0)=1
Operations
Operations
Operations
Operations

Output:
Operations
Operations

Predefinedspecialmatrix
Operations
Operations

Solving linear system


Operations
COPT
What have been done:
Afriendlydesignedinterface
Clearbaseclass
Basicoperations
Linearalgebra
Functiondifferential(numerical)
Theinterfaceofasolver
COPT
Focus
Aneasytocodedevelopingframework
Crossplatformconsideration
Linux:Ubuntu
Windows
MaxOSX

Developing environment
OSXYosemitewithclang
MinGW onwindowswithg++
IDEindependent
Dependency

Classical libraries for linear operations:


Blas (fortran), cblas(C), lapack(fortran)

C++ template library linear algebra


Eigen (maybe temporary)
IDE independent
Integrated Development Environment

Visualstudio
Qt Creator
Xcode

Compiling details are ignored
Link
IDE independent
Integrated Development Environment

Visualstudio
Qt Creator
Xcode

Compiling details are ignored
Link
IDE independent
Still unfamiliar with C++ compiling

Focus on code not project

Lightweight development
GitHub

GitHub is a Git repository webbased hosting service.

It offers all of the distributed revision control and source code


management.

It provides a webbased graphical interface and desktop.


A Simple Example
Nonlinear optimization
Steepestdescentmethod
NewtonsMethod
QuasiNewtonMethod(likeBFGS)

A famous 2dimensional test function


Rosenbrock function

f (x) 100 x2 x
2 2
1 x 2
1 1
A Simple Example
A Simple Example
A Simple Example
A Simple Example
Stuff

Students in MathU:
RuiminWang,wangrm@mathu.cn
Songtao Guo,guost@mathu.cn
Jingyuan Hu,hujy@mathu.cn
Baiyu Chen,chenby@mathu.cn
More
Interface provided for Python
DonebySongtao Guo
More

Unified definition of function


Abaseclassisdefined

Automatically differential computation

Many algorithms have not been implemented yet


Constrainednonlinearoptimization
Largescalesolvers:interiorpointmethod,alternating
directionmethodofmultipliers
More

COPT v0.1 will be published before Jan. 2015


for developers only

Still a lot of remaining work


Everyoneiswelcomed
Averyinterestingproject
Agoodopportunitytochallengeyourself
Join Us!
wangrm@mathu.cn

You might also like