Chapter : Applied python in industrial Engineering – Optimization tool
Approach
Lê Đức Đạo, Phd
Industrial System Enginerring Department
Faculty of Mechanical Engineering
Ho Chi Minh City University Of Science and Technology
Phone: 0937286746
Email:
[email protected] OVERVIEW OF CPLEX
CONNECTORS
• CPLEX core routines are coded in C.
• CPLEX has a tool interactive optimizer for quick diagnostics
• CPLEX provides various wrappers and connectors for other programming languages
and applications.
• C++
• Java
• .NET
• MATLAB
• Python
• Excel
OVERVIEW OF CPLEX
CONNECTORS
WHY PYTHON API?
Open source scripting language
Easy to learn and maintain
Provides procedural, functional and object-oriented paradigms
Interpreted language
Provides other mature libraries for visualizations, statistical analysis and other
scientific computing
Combined capabilities of other CPLEX APIs and Interactive CPLEX
• Can be used instead of interactive CPLEX
• Has capabilities to do iterative solves, callbacks like other CPLEX APIs
INSTALL CPLEX FUNCTION
TO PYTHON
CPLEX BASIS ON LINEAR
PROGRAMMING
Two decision variable x and y
CPLEX BASIS ON LINEAR
PROGRAMMING
Optimal solution
Can we solve If
we add one
5 𝑥+ 4 𝑦=10
decision variable
z to the model
CPLEX BASIS ON LINEAR
PROGRAMMING
Import Cplex function
Import decision variable
Import constraint
Import objective and called solved functio
Result
CPLEX BASIS ON LINEAR
PROGRAMMING
CPPLEX BASIS ON LINEAR
PROGRAMMING
Import Cplex function
Different type of decision Import decision variable
variable
Import constraint
CPLEX BASIS ON LINEAR
PROGRAMMING
Solution with different type of result
x=.binary_var
y=continuous_var
z=integer_var
OPTIMIZATION PROBLEM
Production time of
Foldyphone=1.5
Production time
of tiny phone=2
MODEL FORMULATION
number of foldyphone production
number of tinyphone production
Production time
of
Objective function
Foldyphone=1.5
Maximize 900 +1100
Constraints
>=200
>=500 Production
1.5 + 2 time of tiny
phone=2
OR OPTIMIZATION TOOL
BASED ON CPLEX-PYTHON
FUNCTION
Import Cplex function
Import manufacturing product
Import parameter
OR OPTIMIZATION TOOL
BASED ON CPLEX-PYTHON
FUNCTION
Number of production constraint
Total Production Constraint
OR OPTIMIZATION TOOL
BASED ON CPLEX-PYTHON
FUNCTION
OBJ and
called solve
function
BINARY KNAPSACK
PROBLEM – IN CLASS
EXERCISES
Objective
Optimize the bag's capacity for high-value
products.
Constraint
The total weight stored in bag should be less
than bag capacity
BUILD THE MODEL – IN
CLASS EXERCISES
Objective
Max
Constraints
SOLVE THE MODEL IN CLASS
EXERCISES
Work in group for solving the model using cplex-python