No video

Solving Optimization Problems with Python Linear Programming

  Рет қаралды 86,722

Nicholas Renotte

Nicholas Renotte

Күн бұрын

Want to solve complex linear programming problems faster?
Throw some Python at it!
Linear programming is a part of the field of mathematical programming and is a powerful way of solving complex combinatorial problems. It's used in manufacturing, resources, defence and transport quite extensively to improve outcomes and push performance.
Want to learn more? Well in this video, you'll learn:
- The three key parts to any linear programming problem
- How to formulate a manufacturing optimization problem
- To solve linear programming problems with docplex and Python!
Get the code: github.com/nicknochnack/Linea...
Other Resources
Docplex Documentation: ibmdecisionoptimization.github...
Oh, and don't forget to connect with me!
LinkedIn: / nicholasrenotte
Facebook: / nickrenotte
GitHub: github.com/nicknochnack
Happy coding!
Nick

Пікірлер: 106
@ashraf3576
@ashraf3576 2 жыл бұрын
great video, it makes me easy to understand the concept of mixed integer linear programming. keep up the good work
@sumukha111
@sumukha111 2 жыл бұрын
Not many videos on the internet about docplex, please upload some more videos. Thank you mate
@anilkumarl.biradar3555
@anilkumarl.biradar3555 2 жыл бұрын
Awesome video, able to understand the concepts well 👏 It would be great, if you could do some more videos about docplex
@amoghamaresh6702
@amoghamaresh6702 2 жыл бұрын
Awesome video , it would be great help if you could do more videos about docplex
@pablomartinez1504
@pablomartinez1504 2 жыл бұрын
Fantastic Video! The instructions are really easy to follow and you do a great job explaining why you're doing stuff. Unfortunately, when I try to run it, it gives me the following error: docplex.mp.utils.DOcplexException: Cannot solve model: no CPLEX runtime found. Then pip cannot find a version of cplex that can be installed. Any suggestions?
@chanwitchanton2424
@chanwitchanton2424 3 жыл бұрын
Very nice teaching, Thank you, krub.
@giridharan6800
@giridharan6800 3 жыл бұрын
Would be great if you can explain with a time series data.
@sakatagintoki8835
@sakatagintoki8835 Жыл бұрын
I am glad that I found your channel
@TheKekko16
@TheKekko16 Жыл бұрын
Hi, thanks for the video. You explained all the concepts clearly and made it easy. I'm writing my bachelor's thesis. I've created some MILP model for feature selection in the support vector machine. Now I need to do the cross validation with the scikit learn library, but I can't use the fit method on my docplex models. Do you know how i should do?
@DahaiWang-li9gy
@DahaiWang-li9gy Ай бұрын
great job explaining the issue in a very simple and easy to understand way. One question to ask - m = Model(name= ‘Phone Production’), what is the purpose of setting ‘Phone Production’ as name for m? The same for name = ‘foldy phone production’ and name= ‘tiny phone production’. I did see they were used later in the code.
@pedramjazayeri4786
@pedramjazayeri4786 2 жыл бұрын
Is there any limitation for the number of decision variables(D.V.)? For example a code with 4 D.V. I got the optimum values, but for that problem with 6 D.V. I did not get the solution (NonType Object for [sol=m.solve()] ). what is the fault? thanks
@gabrielmedeiros9880
@gabrielmedeiros9880 2 жыл бұрын
Is there a way to print the dual values?
@jeethendraambarish100
@jeethendraambarish100 2 жыл бұрын
Wow awesome teaching, could we please get some more videos , hard to find videos on docplex
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
Sure!
@stallonetht
@stallonetht 3 жыл бұрын
Hi Nicholas, do you have any tutorial to solve non linear problem as well?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Not yet, any specific problem you're looking to solve @stallonetht?
@raihankhanphotography6041
@raihankhanphotography6041 2 жыл бұрын
You do the best educational videos of all! Thank you! A quick question -- can anyone access the IBM Watson service? Is it free or carries a fee?
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
All of them have a free tier available. Give it a crack!
@mehdismaeili3743
@mehdismaeili3743 3 ай бұрын
Excellent .
@maxsh5350
@maxsh5350 3 жыл бұрын
Hi! Thank you for the tutorial! But what to do in case of parametric programming problem? Are there any built-in libraries? like that: (c+t)x->max axmax ax
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Check this out: www.ibm.com/support/pages/solve-linear-parametric-model-using-cplex
@maxsh5350
@maxsh5350 3 жыл бұрын
@@NicholasRenotte thanks 😉👌🏻
@zahranamazian5540
@zahranamazian5540 2 жыл бұрын
Hi, I have an optimisation model in a "for loop"using Python and Gurobi. For each iteration I need to record the decision variables and use them as an input of next "for loop". I was wondering if you advise me how I can record the decision variables in each loop. Thanks
@psymfmah
@psymfmah 3 жыл бұрын
Do you have any video about how to operate non-linear least square regression with many constraints in python?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Heya @Alireza, hmm, can you share a little more on the use case? So separately leverage LS Regression then apply a constrained problem?
Жыл бұрын
hey, i have replicated the entire model but it keeps on saying m is not defined, neither is sol
@ashraf3576
@ashraf3576 2 жыл бұрын
hi Nicholas, when i run m.solve(), i got Error said that " DOcplexException: Cannot solve model: no CPLEX runtime found". Hope you can give me some idea on how to resolve this issue.
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
Run it in the IBM environment, it has the CPLEX runtime preinstalled.
@franciscozorrilla8440
@franciscozorrilla8440 2 жыл бұрын
@@NicholasRenotte how does one get access to the IBM environment?
@abhiruwijesinghe2677
@abhiruwijesinghe2677 2 жыл бұрын
When I execute the #prodcution constraint in the 7:14, I got this error Conversion from constraint to expression is available only for discrete constraints, foldy phone production >= 500 is not discrete Can you please help me? #NicholasRenotte
@jorgeperea5095
@jorgeperea5095 Жыл бұрын
Hi, I'm getting this error message could someone help me? DOcplexException: Cannot solve model: no CPLEX runtime found.
@GSBhargav94
@GSBhargav94 Жыл бұрын
I get the same error, were you able to solve this ?
@zeynepbaykan7277
@zeynepbaykan7277 Жыл бұрын
The video is very understandable but when i run the code, i get an error which is: DOcplexException: Model did not solve successfully Maybe you can help me?
@TejasGaga
@TejasGaga 2 жыл бұрын
sir, the code gets stopped at sol=m.solve ()..ask for CPLEX.module..after pip install in google colab still norlt running..kindly help
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
Won't run in Colab as there isn't a CPLEX environment.
@adammusa426
@adammusa426 Жыл бұрын
Pls can you do for integer programming, pls I need it asap. It urgent.
@behrouzChannel
@behrouzChannel 3 жыл бұрын
Nicholas I've got a question , I'll be glad if you guide me , Can I pass a data sciences course like Coursera's courses instead of a University degree to find a job in Europe or USA ?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
No problemo, the US market is VERY competitive and you'll likely being going up against people with advanced tertiary degrees (Masters and PdDs). If you're going to rely on Coursera courses only then you need a way to stand out so I'd suggest building an AMAZING portfolio. It'll be easier to score a DS role in Europe with that approach however.
@behrouzChannel
@behrouzChannel 3 жыл бұрын
@@NicholasRenotte amazing guidance thank you so much 🌷
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
@@behrouzChannel no problems, you're most welcome!
@ankitarya7492
@ankitarya7492 3 жыл бұрын
Can we do optimization or constraint satisfaction if our input data is timestamps like job duration and it's start stop time and we need to assign resource to do that job.?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Heya @Armored Flash, from what I've seen the way to handle this is to treat time as a constant (t) and stage resources using time from t. E.g. The plumber needs to start at t+60. Check this out: ibmdecisionoptimization.github.io/docplex-doc/mp/nurses_scheduling.html
@ankitarya7492
@ankitarya7492 3 жыл бұрын
@@NicholasRenotte I'm referring to something like rail crew scheduling where you have time table for rails and you need to create crew duties to optimize number of resources that'll operate rails.
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
@@ankitarya7492 yep, check out the Nurse Scheduling example I gave. You could repurpose that for rail crew scheduling!
@user-or7ji5hv8y
@user-or7ji5hv8y 3 жыл бұрын
I'm not sure if docplex is still working properly, since I got an error when running m.solve(), DOcplexException: Cannot solve model: no CPLEX runtime found.
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Heya @C, are you running it in Watson Studio? The CPLEX API is natively enabled from WS. You would have to install it separately if you wanted to do it locally.
@xknubbe
@xknubbe 3 жыл бұрын
Hey, I am the same problem... I am running it on google collab, is there a workaround?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
@@xknubbe nope, gotta do it with a CPLEX runtime!
@SSS0401
@SSS0401 3 жыл бұрын
Unable to read your code - font too small on Gallaxy tablet
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Heyyy thanks for the heads up @Virgil Stokes, I've been zooming in on the more recent videos, can you let me know if it's better on this one kzfaq.info/get/bejne/kLujlKyAubDafWg.html Also, I just uploaded the Notebook to GitHub if you wanted to take a look: github.com/nicknochnack/LinearProgrammingBasics
@merin_here_am_i
@merin_here_am_i 2 жыл бұрын
Awesome video... Can you please do optimization with cplex python API?
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
Checked this out? kzfaq.info/get/bejne/e-CYra2q2p2bqWw.html
@user-or7ji5hv8y
@user-or7ji5hv8y 3 жыл бұрын
Is docplex better than Scipy? Just wondering what the pros and cons are...
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Heya @C, docplex is based on CPLEX which is a super fast API. I tend to use it a lot for work in enterprise solutions. I haven't dealt too much with Scipy but from what I know, CPLEX scales ridiculously well, particularly if you have a large number of variables and constraints.
@13kriztian
@13kriztian 3 жыл бұрын
Very helpful
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Heya @Christian, glad you found it useful!! 🙏
@saltsea9499
@saltsea9499 Жыл бұрын
for those who need it with pycharm. settings, project, python interpreter, + to install cplex package
@davidcorbett2170
@davidcorbett2170 6 ай бұрын
you're a legend, tysm
@raedokal
@raedokal Жыл бұрын
Love it
@hninpannphyu8567
@hninpannphyu8567 3 жыл бұрын
Hi, Thanks for the great tutorial. How can we implement the maximum flow problem with docplex. For instances, E =Arcs, (i,j) , x[i,j]=binary variable, 1 if i is linked to j, o otherwise. mdl.sum(x[i,j] for (i,j) in E)-mdl.sum(x[j,i] for (j,i) in E)==1 if i=source mdl.sum(x[i,j] for (i,j) in E)-mdl.sum(x[j,i] for (j,i) in E)==-1 if i==destination mdl.sum(x[i,j] for (i,j) in E)-mdl.sum(x[j,i] for (j,i) in E)==0 otherwise. Can you guide me the example code in python docplex Model for the above example?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Check this out: ibmdecisionoptimization.github.io/tutorials/html/Beyond_Linear_Programming.html
@hninpannphyu8567
@hninpannphyu8567 3 жыл бұрын
@@NicholasRenotte Thanks a lot it is really helpful. :D
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
@@hninpannphyu8567 anytime!! GL
@virgeliushendrawantaraland683
@virgeliushendrawantaraland683 2 жыл бұрын
thankyou ma bro
@kharthigeyan
@kharthigeyan 3 жыл бұрын
Why not use minizinc for this?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Possibly, I haven't actually done a lot with minizinc!
@cong1393
@cong1393 3 жыл бұрын
Minizinc doesn't work with Python as easily as ILOG/DOcplex. When it come time to deploy the model to the cloud to expose an API, say to use it in your website or mobile app, Minizinc has no easy way of doing it. It's great to learn about constraint programming, but pretty meh when it comes to operationalise the model. Plus, ILOG's got multi-objective optimisation, pretty basic compared to MATLAB, but it's there.
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Thanks for sharing @@cong1393!
@behrouzChannel
@behrouzChannel 3 жыл бұрын
It seems helpuf but I can't see the codes , wish you could zoom in the screen
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Hey @Behrouz, my bad, code is here: github.com/nicknochnack/LinearProgrammingBasics
@behrouzChannel
@behrouzChannel 3 жыл бұрын
@@NicholasRenotte thanks a lot Nicholas
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
@@behrouzChannel anytime!
@killerDNA1001
@killerDNA1001 3 жыл бұрын
and also when i run m.solve() i get a error saying "Cannot solve model: no CPLEX runtime found." Please help me this is kinda urgent
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Let's dig into it a little, are you running this from IBM Cloud? CPLEX would be pre-configured there for you! 😊
@killerDNA1001
@killerDNA1001 3 жыл бұрын
@@NicholasRenotte thank you mate i figured this out now when i use it in IBM Watson Studio it works perfectly
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
@@killerDNA1001 YESSS! I'm curious, what type of LP problems are you working on!?
@dominicscott7367
@dominicscott7367 3 жыл бұрын
@@NicholasRenotte Hey is there a way to solve this error on pycharm?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
@@dominicscott7367 you have to have CPLEX installed on your local machine in order to run it in Pycharm.
@folran5422
@folran5422 3 жыл бұрын
I don't see how this problem is so complex as to warrant such a model. It's quite simple, really: A FoldyPhone is $900 in 1.5h = $600 in 1h. A TinyPhone is $1100 in 2h = $550 in 1h. *Obviously* you're gonna want to make as many FoldyPhones as possible, since they make more money per hour! How is this complex? To answer the question, just plug in the minimum number for TinyPhones: 2999.5 - 200 * 2 = 2599.5 hours left for making FoldyPhones 2599.5 / 1.5 = 1733 FoldyPhones we can make with the remaining time
@simonknights7619
@simonknights7619 3 жыл бұрын
I dont have ibm watson. Trying to replicate in jupyter but throwing an error at the last line (anaconda on w10 pc. I did pip install cplex ok) Is anyone able to help please? --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in ----> 1 sol.display() AttributeError: 'NoneType' object has no attribute 'display'
@simonknights7619
@simonknights7619 3 жыл бұрын
Scrap that I think I fixed by adding sol = m.solution
@vatsid
@vatsid 2 жыл бұрын
Run pip install cplex You need cplex as a separate package installed
@ashleysami1640
@ashleysami1640 4 жыл бұрын
What. I can do that already.
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Hmmm....but can you really @Ashley Sami?
@musedegefe5906
@musedegefe5906 Ай бұрын
Clinical!
@franciscozorrilla8440
@franciscozorrilla8440 2 жыл бұрын
i think its do cplex not doc plex :)
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
HAHAHAHAHA, I am an idiot. Thanks a million @Francisco, that makes a lot more sense 😅
@rahmadewikartikasari6449
@rahmadewikartikasari6449 3 жыл бұрын
Good day! What a helpful video. I'm trying to learn data science using python these days. And I tried using optimization method to solve McDonald's Nutrition data set. But i found an error when running the prob.solve code. 'PulpSolverError: Pulp: Error while executing glpsol.exe' appeared when I run the prob.solve() But I still can't find the solution to solve this problem. Can you help me to solve it? Thanks
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Awesome @rahma ika, what do you get when you run pulp.pulpTestAll() This SO thread might help? stackoverflow.com/questions/34764209/pulp-solvers-pulpsolvererror-pulp-cannot-execute-glpsol-exe
@rahmadewikartikasari6449
@rahmadewikartikasari6449 3 жыл бұрын
@@NicholasRenotte hi! Thank you for taking time to help me. I've tried to run the pulp.pulpTestAll() code, and it said that module pulp.pulp has no attribute 'pulpTestAll' And i tried what's written in the thread, but nothing's worked for me.
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
@@rahmadewikartikasari6449 can you share your code, I can try to test it on my machine? Github link?
@rahmadewikartikasari6449
@rahmadewikartikasari6449 3 жыл бұрын
Dear @@NicholasRenotte , here is the github link github.com/Rahmadewiks/Mcd-Nutrition.git i hope you find out what made it error.
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Heya @Rahma, I'm getting a bunch of other errors when I test the model. Quick check, what type of machine are you running this on and what version of Python?
@mehmetemincifci
@mehmetemincifci Жыл бұрын
ibm solver not python
@MehmetTanriver
@MehmetTanriver 2 жыл бұрын
Dont read
@sidasdf
@sidasdf 3 жыл бұрын
Unfortunate I was hoping I would actually be able to learn the process to optimize, not use some external library to do it for me.
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Oh my bad! Might add something on opt from scratch in the pipeline!
@donaldoconner5172
@donaldoconner5172 10 күн бұрын
Don't try to kill God's sons again.
PuLP Tutorial: Linear Programming in Python
19:24
Mohammad T. Irfan
Рет қаралды 13 М.
SciPy Beginner's Guide for Optimization
11:03
APMonitor.com
Рет қаралды 294 М.
MISS CIRCLE STUDENTS BULLY ME!
00:12
Andreas Eskander
Рет қаралды 21 МЛН
Doing This Instead Of Studying.. 😳
00:12
Jojo Sim
Рет қаралды 26 МЛН
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 57 МЛН
The Art of Linear Programming
18:56
Tom S
Рет қаралды 646 М.
Linear Programming (Optimization) 2 Examples Minimize & Maximize
15:08
Mario's Math Tutoring
Рет қаралды 528 М.
Intro to Linear Programming
14:23
Dr. Trefor Bazett
Рет қаралды 182 М.
Optimization in Python: Pyomo and Gurobipy Workshop - Brent Austgen - UT Austin INFORMS
1:11:46
INFORMS Student Chapter - UT Austin
Рет қаралды 40 М.
Optimize with Python
38:59
APMonitor.com
Рет қаралды 13 М.
15. Linear Programming: LP, reductions, Simplex
1:22:27
MIT OpenCourseWare
Рет қаралды 194 М.
MISS CIRCLE STUDENTS BULLY ME!
00:12
Andreas Eskander
Рет қаралды 21 МЛН