ILOG CPLEX introduction Presenter: Meng-yen Li. Outline Introduction Using the interactive interface Read problem from file LP format Demo with FS problem.

Slides:



Advertisements
Similar presentations
Understanding optimum solution
Advertisements

SCIP Optimization Suite
Introduction to Sensitivity Analysis Graphical Sensitivity Analysis
What is GAMS?. While they are not NLP solvers, per se, attention should be given to modeling languages like: GAMS- AIMMS-
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2002 Lecture 8 Tuesday, 11/19/02 Linear Programming.
EE 553 Integer Programming
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
Linear Programming Fundamentals Convexity Definition: Line segment joining any 2 pts lies inside shape convex NOT convex.
GAMS/GAMSIDE AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl and improved upon by previous lab instructors.
Linear Programming and CPLEX Ting-Yuan Wang Advisor: Charlie C. Chen Department of Electrical and Computer Engineering University of Wisconsin-Madison.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2006 Lecture 9 Wednesday, 11/15/06 Linear Programming.
Computational Methods for Management and Economics Carla Gomes
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Computational Methods for Management and Economics Carla Gomes
 2002 Prentice Hall. All rights reserved. 1 Intro: Java/Python Differences JavaPython Compiled: javac MyClass.java java MyClass Interpreted: python MyProgram.py.
1 Linear Programming Using the software that comes with the book.
Introduction to C Programming
AMPL Presentation 1 By Raymond Kleinberg Outline AMPL - Ugh! - What is it good for? Basics Starting a Problem Running the Problem Example.
Spreadsheet Modeling & Decision Analysis:
Solver & Optimization Problems n An optimization problem is a problem in which we wish to determine the best values for decision variables that will maximize.
LP formulation of Economic Dispatch
Input/Output  Input/Output operations are performed using input/output functions  Common input/output functions are provided as part of C’s standard.
Introduction to Mathematical Programming OR/MA 504 Chapter 3.
START EXCEL BUILD OR RETRIEVE YOUR OPTIMIZATION MODEL SAVE YOUR WORKBOOK!! CHOOSE “Solver…” IN THE “Tools” MENU SPECIFY IN SOLVER DIALOG BOX: 1.CELL TO.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
C&O 355 Lecture 2 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A.
Special Conditions in LP Models (sambungan BAB 1)
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
ILOG CPLEX CPLEX is a product developed by ILOG to solve LPs MIPs QPs
The Two-Phase Simplex Method LI Xiao-lei. Preview When a basic feasible solution is not readily available, the two-phase simplex method may be used as.
Simplex method (algebraic interpretation)
1 ILOG CPLEX CPLEX is a product developed by ILOG to solve  LPs  MIPs  QPs  MIQPs  Network Flow problems CPLEX technologies  CPLEX callable library.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
To accompany Quantitative Analysis for Management, 8e by Render/Stair/Hanna 11-1 © 2003 by Prentice Hall, Inc. Upper Saddle River, NJ Chapter 11.
EE/Econ 458 Duality J. McCalley.
15.053Tuesday, April 9 Branch and Bound Handouts: Lecture Notes.
OR Chapter 8. General LP Problems Converting other forms to general LP problem : min c’x  - max (-c)’x   = by adding a nonnegative slack variable.
OR Simplex method (algebraic interpretation) Add slack variables( 여유변수 ) to each constraint to convert them to equations. (We may refer it as.
CPSC 536N Sparse Approximations Winter 2013 Lecture 1 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAAAAAA.
Spreadsheet Modeling & Decision Analysis A Practical Introduction to Management Science 5 th edition Cliff T. Ragsdale.
A First Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington Credits: a significant part of.
LINGO TUTORIAL. WHAT IS LINGO : LINGO is a software tool designed to efficiently build and solve linear, nonlinear, and integer optimization models. CREATING.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Integer Programming, Branch & Bound Method
Business Mathematics MTH-367 Lecture 16. Chapter 11 The Simplex and Computer Solutions Methods continued.
Production systems LP and MILP models. Introduction  Linear programing (LP) is a base tool in optimization  George B. Dantzig developed the simplex.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
1 2 Linear Programming Chapter 3 3 Chapter Objectives –Requirements for a linear programming model. –Graphical representation of linear models. –Linear.
LINGO TUTORIAL.
An Introduction to Linear Programming
Cplex: Advanced Example
Stat 261 Two phase method.
Chap 10. Sensitivity Analysis
IENG 212 LAB 1 Research Assıstant: Kehınde Adewale ADESINA
Solver & Optimization Problems
The CPLEX Library: Mixed Integer Programming
Chapter 5 Sensitivity Analysis: An Applied Approach
Wyndor Example; Enter data
Chap 9. General LP problems: Duality and Infeasibility
Chapter 6. Large Scale Optimization
Chapter 5. The Duality Theorem
A QUICK START TO OPL IBM ILOG OPL V6.3 > Starting Kit >
Integer Programming (정수계획법)
Using the ODH-CPLEX Python Interface
Intersection Cuts from Bilinear Disjunctions
Chapter 6. Large Scale Optimization
IENG 212 LAB 1 Research Assıstant: Kehınde Adewale ADESINA
Presentation transcript:

ILOG CPLEX introduction Presenter: Meng-yen Li

Outline Introduction Using the interactive interface Read problem from file LP format Demo with FS problem

Introduction ILOG CPLEX is an optimization package. Usually shortened as “cplex” Named after Simplex method and C language. Originally developed by Robert E. Bixby. Now IBM has the acquisition of ILOG CPLEX. CPLEX was acquired by ILOG in 1997 ILOG was acquired by IBM in 2009

Capability CPLEX can solve… Very large linear programming problems(LP) Mixed integer programming problems(MIP) Quadratic objective programming problems(QP) Quadratic constraint programming problems(QCP)

Reference “ILOG CPLEX Getting Started” Ref. - “ILOG CPLEX 11.0 Getting Started”, 2007 For CPLEX starter. “ILOG CPLEX File Formats” Ref. - “ILOG CPLEX 10.0 File Formats”, 2006 For knowing file format detail, especially LP format. “ILOG CPLEX User’s Manual” Ref. - “ILOG CPLEX 9.0 User’s Manual”, 2003 For manually using CPLEX Classes and Library in C++. You can get these documents by Google. Current version is Easy / Hard

How to use CPLEX is currently installed on eda union 13 Login to edaunion.ee.ntu.edu.tw:40063 Just directly execute cplex – Type cplex Unfortunately, the License is only for one user. So if others are using or link dead when using, you may see error message from ILM(license manager)

Interactive Interface cplex IBM ILOG License Manager: "ntu-taiwan " is accessing CPLEX 12 with option(s): "e m b q use=1 MaintenanceEnd= ". Welcome to CPLEX Interactive Optimizer with Simplex, Mixed Integer & Barrier Optimizers 5724-Y48 (c) Copyright IBM Corp. 1988, All Rights Reserved. CPLEX is a registered trademark of IBM Corp. Type 'help' for a list of available commands. Type 'help' followed by a command name for more information on commands. CPLEX>

Example with manually input CPLEX> enter example Enter new problem ['end' on a separate line terminates]: maximize x1 + 2 x2 + 3 x3 subject to -x1 + x2 + x3 <= 20 x1 - 3 x2 + x3 <= 30 bounds 0 <= x1 <= 40 0 <= x2 0 <= x3 end

Example with manually input CPLEX> enter example Enter new problem ['end' on a separate line terminates]: maximize x1 + 2 x2 + 3 x3 subject to -x1 + x2 + x3 <= 20 x1 - 3 x2 + x3 <= 30 bounds 0 <= x1 <= 40 0 <= x2 0 <= x3 end Keyword enter with problem name example Problem Objective Function maximize Subject to constraints subject to Variable bounds bounds end to finish input problem

Solving the problem CPLEX> optimize Tried aggregator 1 time. No LP presolve or aggregator reductions. Presolve time = 0.00 sec. Iteration log... Iteration: 1 Dual infeasibility = Iteration: 2 Dual objective = Dual simplex - Optimal: Objective = e+02 Solution time = 0.00 sec. Iterations = 2 (1)

View solution CPLEX> display solution variables x1-x3 Variable Name Solution Value x x x

Read problem from file Manually input is too tedious. We can read the problem from file if it is stored in LP format file. You can read in many ways: read (then to be prompted to input file name) – example (then to be prompted to input file format) – lp read example lp (same to above but without prompt) read example.lp (specify extension also works)

LP format Keywordabbreviationdefault name enter read erer by manually input (input filename) maximize minimize max min (obj) subject tost(c1 …. cn) bounds end

LP format: variable naming The variable name cannot be longer than 255 characters All alphanumeric characters (a-z, A-Z, 0-9) and certain symbols: ! " # $ % & ( ),. ; _ ‘ ’ { } ~ can be used. Any combinations are allowed except the followings. Cannot start with numbers or period(.) Cannot start with e/E with another number or e (because e is reseverd for exponents and equal sense) Some examples: – O x123, #4x.3e, Example – X e2, eels,.123, 3x4

LP format: constraint naming As previous table shows The default name for objective function is obj. The default name for constraints is c1 … cn. You can change by adding labels before the linear (in)eqaulities. example: max mymax: x1 + 2x2 + 3x3 st time: -x1 + x2 + x3 <= 20 labor: x1 - 3x2 + x3 <= 30

LP format: input limit Any line with more than 510 characters is truncated. You can enter linear (in)equalities on separate lines, but without cutting the variables. example: – correct input time: -x1 + x2 + x3 labor: x1 - 3x2 + x3 – incorrect input time: -x1 + x2 + x 3 labor: x1 - 3x2 + x3

LP format: sense X1 – 3x2 + x3 <= 30 Yellow part is called sense. Blue part is called Right Hand Side(RHS). CPLEX parse constraints by these key parts. So if you add ; after a line(like c/c++) will get this warning. – Warning, line 55: Characters after RHS value are ignored. Sense  = Input format<=>== Synonym<, <=, =<, l(less)>, =>, >=, g(greater)=, e(equal) Note< is interpreted as <= by cplex > is interpreted as => by cplex

LP format: bounds Variable bounds can enter as – ln <= xn <= un You can also separately enter the bounds – ln <= xn – xn =< un Default setting – lower bound: 0 – upper bound: + ∞ For infinity, set the bounds as +infinity(+inf) / -infinity(-inf) also you can use free to indicate no bounds – x7 free – same as –inf <= x7 <= +inf

LP format: Integer Add section general/binary to list which variable is integer/0-1 integer. General/Generals/Gen is all acceptable. Binary/Binaries/Bin is all acceptable.

LP format:Mixed Integer Maximize obj: x1 + 2 x2 + 3 x3 + x4 Subject To c1: - x1 + x2 + x x4 <= 20 c2: x1 - 3 x2 + x3 <= 30 c3: x x4 = 0 Bounds 0 <= x1 <= 40 2 <= x4 <= 3 General x4 Binary x2 End

Demo Using CPLEX to solve FS problem Problem Input: X0X0 X1X1 F X0X0 X1X1 F fsp1.lp(infeasible) fsp2.lp(has solution)

Formulation FS constraint: f(m a )  f(m b )   (m a [bit])  (m b [bit])  (m a [bit])  (m b [bit])  |  (m a [bit])   (m b [bit]) |  1  (  (m a [bit])   (m b [bit])  1)  (  (m b [bit])   (m a [bit])  1) At first I didn’t know how to write a Linear Constraint for this, so I wrote a Quadratic Constraint instead. |  (m a [bit])   (m b [bit]) |  1  (  (m a [bit])   (m b [bit]) ) 2  1 X F 1 mama a[0]a[1]a[2]a[3] 0 1 mbmb b[0]b[1]b[2]b[3] 1 0 0

Convert constraints in MIQCP min dummy \x grc group/row/column \z grrc group/pairs of row/column \problem \x x0x1 encode f \0 0 0 x000 x001 x100 1 \1 1 0 x010 x011 x100 0 \2 2 0 x020 x021 x100 1 \3 3 0 x030 x031 x100 1 \4 0 1 x000 x001 x110 0 \5 1 1 x010 x011 x110 1 \6 2 1 x020 x021 x110 0 \7 3 1 x030 x031 x110 0 Use dummy variable for there’s no objective function Use \ to comment a line This problem is infeasible. And if this bit changes to 0 It will become feasible

Convert constraints in MIQCP st \full symmetry property \pair01 FSpair01: [ x000 * x000 + x000 * x001 + x000 * x100 - x000 * x010 - x000 * x011 - x000 * x100 + x001 * x000 + x001 * x001 + x001 * x100 - x001 * x010 - x001 * x011 - x001 * x100 + x100 * x000 + x100 * x001 + x100 * x100 - x100 * x010 - x100 * x011 - x100 * x100 - x010 * x000 - x010 * x001 - x010 * x100 + x010 * x010 + x010 * x011 + x010 * x100 - x011 * x000 - x011 * x001 - x011 * x100 + x011 * x010 + x011 * x011 + x011 * x100 - x100 * x000 - x100 * x001 - x100 * x100 + x100 * x010 + x100 * x011 + x100 * x100 ] >= 1 \this is the infeasible one’s FS QC(quadratic constraint) for example, other QC are omitted \Quadratic terms must put inside of square brackets []

Convert constraints in MIQCP \x0 encode \x0 pair 01 ENCODEx0bit0pair01LB: x000 + x z0010 >= -1 ENCODEx0bit0pair01UB: x000 + x z0010 <= 0 ENCODEx0bit1pair01LB: x001 + x z0011 >= -1 ENCODEx0bit1pair01UB: x001 + x z0011 <= 0 ENCODEx0pair01: 2 z z x000 - x010 - x001 - x011 >= 1 \(… from pair01 to pair23) \x1 encode \x1 pair 01 ENCODEx1bit0pair01LB: x100 + x z1010 >= -1 ENCODEx1bit0pair01UB: x100 + x z1010 <= 0 ENCODEx1pair23: 2 z x100 - x110 >= 1 Cplex interpret > 0 as >= 0 here need change to >=1

Convert constraints in MIQCP bin dummy \x0 x000 x001 x010 x011 x020 x021 x030 x031 \x1 x100 x110 \z0 z0010 z0011 z0020 z0021 z0030 z0031 z0120 z0121 z0130 z0131 z0230 z0231 \z1 z1010 end Remember to add end at last line

Use the interactive interface CPLEX> read fsp1.lp Problem 'fsp1.lp' read. Read time = 0.00 sec. CPLEX> display problem stats Problem name: fsp1.lp Variables : 24 [Binary: 24] Objective nonzeros : 1 Linear constraints : 33 [Less: 13, Greater: 20] Nonzeros : 117 RHS nonzeros : 20 Quadratic constraints: 16 [Greater: 16] Linear terms : 0 Quadratic terms : 256 RHS nonzeros : 16

Use the interactive interface CPLEX> opt (…message too long so omitted here) MIP - Integer infeasible. Current MIP best bound is infinite. Solution time = 0.12 sec. Iterations = 350 Nodes = 68 (Change the problem and rewrite constraints, store in fsp2.lp) CPLEX> r fsp2.lp CPLEX> opt (…message too long so omitted here) Solution pool: 1 solution saved. MIP - Integer optimal solution: Objective = e+00 Solution time = 0.01 sec. Iterations = 37 Nodes = 0 Command needed not to type in full if the shortened one is not ambiguous. For example, read can also just type r.

Use the interactive interface CPLEX> display sol var * Incumbent solution Variable Name Solution Value x x x x x (…other auxiliary z variables are omitted here) z All other variables matching '*' are 0. Shortened for command display solution variables * * is a wildcard character which means any matching characters that is, display all variables

Solution for FS CPLEX showed a solution to the problem – x100 x020 x031 x010 x011 are 1, others are 0 We got the solution! X0X0 X1X1 Y

Formulation But now I know how to formulate in Linear Constraint. | x  y |  1  ( (x-y) + M*b  1 )  ( (y-x) + M*(1-b)  1 )  ( (x-y) + M*b  1 )  ( (y-x) - M*b  1-M ) x, y  + Integer, b  Binary, M is a large enough + integer. Because |x-y|  Max(x, y) ( ∵ x, y  + Integer) Let M = #bit + 1

FS in Linear Constraint \full symmetry property \#bit =3, M=4 FSpair02p: x000 + x001 + x100 - x020 - x021 - x fs02 >= 1 FSpair02n: x020 + x021 + x100 - x000 - x001 - x fs02 >= -3 FSpair03p: x000 + x001 + x100 - x030 - x031 - x fs03 >= 1 FSpair03n: x030 + x031 + x100 - x000 - x001 - x fs03 >= -3 FSpair05p: x000 + x001 + x100 - x010 - x011 - x fs05 >= 1 FSpair05n: x010 + x011 + x110 - x000 - x001 - x fs05 >= -3

FS in Linear Constraint CPLEX> r fsp3.lp Problem 'fsp3.lp' read. Read time = 0.00 sec. CPLEX> dis pro sta Problem name: fsp3.lp Variables : 39 [Binary: 39] Objective nonzeros : 1 Linear constraints : 63 [Less: 13, Greater: 50] Nonzeros : 275 RHS nonzeros : 50 Variables : Min LB: Max UB: Objective nonzeros : Min : Max : Linear constraints : Nonzeros : Min : Max : RHS nonzeros : Min : Max :

FS in Linear Constraint CPLEX> opt Tried aggregator 1 time. (…) Root node processing (before b&c): Real time = 0.01 Parallel b&c, 8 threads: Real time = 0.00 Sync time (average) = 0.00 Wait time (average) = Total (root+branch&cut) = 0.01 sec. Solution pool: 1 solution saved. MIP - Integer optimal solution: Objective = e+00 Solution time = 0.01 sec. Iterations = 60 Nodes = 0

FS in Linear Constraint CPLEX> dis sol var * Incumbent solution Variable Name Solution Value x x x x x (…) All other variables matching '*' are 0.

Solution for FS CPLEX showed another solution to the problem – x000 x001 x021 x030 x110 are 1, others are 0. – It’s in fact a complement encoding compare to QCP’s. X0X0 X1X1 Y X0X0 X1X1 Y solution from QCP formulation solution from LP formulation

FS: maxmize multivalue f Problem Input: XF fsp5.lp(both function FS feasible) XF fsp6.lp(both function FS feasible)

Problem Encoding X variables: x[minterm][bit] example : x71 means 7-th minterm’s “1-th” bit All start from 0! Y variables: b[minterm][bit]

Formulation For each pair of two minterm row of X. If Y-multivalue same, skip. Add LP constraint of b-encoding not same  summation not same Min m0+m1+… \b00 + b10 - 2z >= -1 \b00 + b10 - 2z <= 0 \2z - b00 - b10 >= 1 =... \sum2 - sum3 +Mfs +(1-...) + m0>=1 \sum3 - sum2 +M(1-fs)+(1-...) + m0>=1

Thank you.