Professional Documents
Culture Documents
Prescriptive Analytics With Docplex and Pandas: Hugues Juille
Prescriptive Analytics With Docplex and Pandas: Hugues Juille
Value
Predictive
What
Prescriptive analytics is about: happened?
Analytics
Descriptive
recommending actions, Analytics
• specific scenarios,
• limited resources and
• knowledge of past and current events.
This insight can help organizations make better decisions and have greater
control of business outcomes.
3 © 2016 IBM Corporation
The Science of Better Decisions
𝑃𝑟𝑜𝑓𝑖𝑡𝑝 × 𝑃𝑟𝑜𝑑𝑢𝑐𝑡𝑖𝑜𝑛𝑝
𝑝
Constraints: demand for components
cannot exceed stock
• Easily formulate your optimization models and solve them with IBM Decision Optimization on the
Cloud solve service or CPLEX local solver (with 0 code change).
• Access to free solve capabilities to discover this new API is made easy thanks to our cloud free trial
and our new CPLEX Optimization Studio free Community Edition (aka COS CE): you can get access
to any of those two with the help of one mail address.
• Available through the standard Python pip install with no need to download anything else or
contact any IBM person if you go full cloud.
• Just look for docplex in your browser to get access to docplex pypi repo or doc.
12 © 2016 IBM Corporation
Comprehensive documentation and resources
All documentation and resources are available on-line
mdl.minimize(total_opening_cost +
Define objective total_supply_cost)
mdl.solve()
Solve the model using local Cplex
mdl.solve(url=SVC_URL, key=SVC_KEY)
or on the cloud
14 © 2016 IBM Corporation
Agenda
• What is Prescriptive Analytics?
• Why Python for Prescriptive Analytics?
• DOcplex: What is it?
• Using DOcplex for modelling an Optimization problem
• Using pandas for improved modelling capabilities
DOcplex:
for l in leg_ids:
for we in weeks:
mdl.add_constraint(
leg_teu[(l, we)] == mdl.sum(trans[(tv.leg_id, tv.mot, tv.date, tv.eqc)] *
size[tv.eqc] for tv in trans_vars_list
if tv.leg_id == l and w[tv.date] == we))
for l in leg_ids:
for we in weeks:
mdl.add_constraint(leg_teu[(l, we)] == trans_sum_grpby.result[l, we])
--> Elapsed time: 2323 ms
for l in leg_ids:
for we in weeks:
mdl.add_constraint(leg_teu[(l, we)] == trans_sum_grpby.result[l, we])
The exact same code that has been written and tested in a notebook for loading
data, modelling an optimization problem, solving it… can readily be integrated
and executed in a deployed Python environment.
Questions/Answers