How to improve your diet and save money with Python
59 views
Formal Metadata
Title 
How to improve your diet and save money with Python

Title of Series  
Part Number 
35

Number of Parts 
169

Author 

License 
CC Attribution  NonCommercial  ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and noncommercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license. 
DOI  
Publisher 
EuroPython

Release Date 
2016

Language 
English

Production Place 
Bilbao, Euskadi, Spain

Content Metadata
Subject Area  
Abstract 
Zuria Bauer/Daniel Domene López  How to improve your diet and save money with Python Optimization in Python (also known as mathematical programming) can be performed by minimization (or maximization) of an objective function within a model that can include discrete variables subject to a set of constrains. At this talk, chemical engineering students of the University of Alicante will introduce the audience to the possibilities of optimization, presenting Pyomo and showing real world examples such as how to improve your diet and save money at fast food restaurants.  Process optimization in industry has become essential in order to maximize the resources available and reduce energy consumption. Optimization problems become interesting when dealing with restrictions (linear or nonlinear) and integer variables (modeling the discrete decisions). Python ecosystem presents different libraries to solve optimization problems, some of them are CVXOpt, CVXPy, PulP, OpenOpt, or Pyomo. Among them, Pyomo results interesting because:  It can be used for Mathematical modeling in Python similarly to AMPL (and GAMS)  It communicates with the main solvers used in this field such as GLPK, Gurobi, CPLEX, CBC and PICO  It's free and open source Python library (BSD license), being developed by Sandia National Laboratories, USA.  It supports Python 3 and it is easy to install. The talk will be divided in three parts: 1. Introduction to Mathematical Programming/Optimization (15 min): visual introduction to optimization concepts including restrictions and non linearties (linear Programming, Nonlinear Programming, ILP, MIP, MINLP). 2. Introduction to the Pyomo sintax and a quick note for the installation (20 min): showing how to improve their diet and save money when ordering food in fast food restaurants. 3. Optimization problems in engineering (10 min): showing more advanced optimization examples that include decision variables.

Keywords 
EuroPython 2016
EP 2016
EuroPython Conference

00:00
Programmer (hardware)
Computer animation
Uniform resource name
Element (mathematics)
Selforganization
Personal area network
Student's ttest
Twitter
Twitter
Chisquared distribution
01:30
Point (geometry)
Domain name
Computer programming
Computer file
State of matter
List of unsolved problems in mathematics
Spiral
Computer font
Distance
Theory
Mathematical morphology
Medical imaging
Core dump
Videoconferencing
Ideal (ethics)
Authorization
Task (computing)
Physical system
Area
Addition
Product (category theory)
Graph (mathematics)
Matching (graph theory)
Trail
Information
Optimization problem
Chemical equation
Moment (mathematics)
Line (geometry)
Evolute
Limit (category theory)
Functional (mathematics)
Demoscene
Tangent
Arithmetic mean
Computer animation
Personal digital assistant
Hausdorff dimension
Right angle
Object (grammar)
Data type
Form (programming)
07:30
Point (geometry)
Threedimensional space
Computer programming
Scientific modelling
1 (number)
Dynamical system
Parameter (computer programming)
Inequality (mathematics)
Tracing (software)
Automatic differentiation
Inference
Maxima and minima
Sign (mathematics)
Mathematics
Linear programming
Physical system
Form (programming)
Series (mathematics)
Convex function
Constraint (mathematics)
Graph (mathematics)
File format
Sampling (statistics)
Volume (thermodynamics)
Instance (computer science)
Line (geometry)
Statute
Functional (mathematics)
Arithmetic mean
Computer animation
Nonlinear system
Personal digital assistant
Convex set
Mixed reality
Figurate number
Data type
Digitizing
Row (database)
12:45
Latin square
Multiplication sign
Scientific modelling
List of unsolved problems in mathematics
Parameter (computer programming)
Mereology
Food energy
Maxima and minima
Video game
Bit rate
Linker (computing)
Computer configuration
Core dump
Office suite
Position operator
Metropolitan area network
Email
Constraint (mathematics)
Product (category theory)
Sampling (statistics)
Infinity
Computer
Variable (mathematics)
Functional (mathematics)
Flow separation
Normal (geometry)
Right angle
Data type
Resultant
Computer programming
Server (computing)
Implementation
Service (economics)
Line (geometry)
Skewness
Online help
Hand fan
Number
Population density
Internetworking
Linear programming
Data structure
Subtraction
Mathematical optimization
Graph (mathematics)
Information
Copyright infringement
Cellular automaton
Mathematical analysis
Planning
Line (geometry)
Set (mathematics)
Computer animation
Integrated development environment
Personal digital assistant
Object (grammar)
Units of measurement
20:41
Point (geometry)
Domain name
Constraint (mathematics)
Autocovariance
Multiplication sign
Scientific modelling
Real number
Coma Berenices
Bit
Distance
Food energy
Emulation
Data mining
Maxima and minima
Arithmetic mean
Video game
Computer animation
Personal digital assistant
Hausdorff dimension
Ranking
Mathematical optimization
22:39
Computer virus
Satellite
Point (geometry)
Computer programming
Domain name
Observational study
Multiplication sign
Real number
Nichtnewtonsche Flüssigkeit
Water vapor
Mereology
Food energy
Maxima and minima
Goodness of fit
Video game
Bit rate
Conjugate gradient method
Internetworking
Energy level
Process (computing)
Data structure
Conditionalaccess module
Skalarproduktraum
Subtraction
Mathematical optimization
Product (category theory)
Spacetime
Constraint (mathematics)
Theory of relativity
Element (mathematics)
Expression
Interior (topology)
Sampling (statistics)
Sound effect
Staff (military)
Functional (mathematics)
Maxima and minima
Arithmetic mean
Message passing
Computer animation
Integrated development environment
Personal digital assistant
Universe (mathematics)
Equation
Selforganization
Object (grammar)
Mathematical optimization
Data type
00:02
welcome all but here have many elements 3 I with me 103 who they consider my but give them some balls all and right the higher 1 my name to reality is that we have a students from the University of Alicante we have those obdurately engineering students so when a programmer and said if you say something and can't feel free to send to request to talk and that's another thing you can find what communication and go in wanted have which I will also post and Twitter and something about and we'll or both of the canvas of cattle which is a nonprofit organization by University and 1 something that might be about personalities in is lost with interactive which is in the welfare actually don't like them so much and well we probably science 2004 to use we are beginning to this that something about it at all and we're actually going engineers and we'll reactors and distillation columns but I don't think you know our march to making that there is a lot to
01:31
be interesting for you so we're thinking what is everything and 1 of his the feet and well everyone of us wants to eat the most obeying the minimum money so got all of us have the objective now Somerset will to to be healthy so we are going to show you how we can that you've faced with minimum cost but having nutritional concerns that you want to have and what not I'm going to let you have done in this going to tell you something more about the the theory of status optimization problem that think of
02:24
and they're knowing that is would to the other so different but initiation deals with financial moment all matching of seals of given functional and willing to some constant using big data problem and this problem was not in there and is for the case where when the listening and wanted to minimize the cost of fooled by the their shoulders and some balanced it on this 1 this is that the ideal you an example imagine we more of the problem and that problem until the person that and that is that the is the common goal to have fast food establishments and tools the we are it's culture and we want to achieve mean and of course we want not so what by or product and when you look to the system and you can choose some products like for has like harmonious this is not always available may mean an end to the old mathematical problems and you know eats from half a prior on natal about processes the and with the addition of all Bush's by the spiral and the deletion Mason awful there is always a final cost that we want to do is to minimize this cost set it to us but constraints on nutritional constant so this is so a mathematical from and we are to optimize the these using by but France and we have to see some core instead of of of of musician and I with my professor from me at the very beginning and I want to show you in the its so what is a linear function and then only of somebody that if he had this is linear function is very and and while this technology in evolution of ECE it's not happening something which would be come from the you can perform the same 3 threedimensional and this is something that knowing some will that like the scene in 3 dimensions the what it is more or less than 1 this morning there is you have something like this and this is a somewhere you can calculate the tangent all here the body of the domain so this means that the users that this morphology right hand for a sample mean that this of the useful telephones and you can also calculate the tangent so this is an known of an area function the is important the will of also in 3 D instruments images it's more fun and that's the authorities and limits of funds and many dimensions using data at the end of the video function will solve the problem and you can it in my case he's ready and is even so what about calculate lady that make others so you have hundreds from some this is so complicated you but be sure that they don't have any state so uh glutamate would prefer between that graph it's up some some some nonnative fonts are you personally the season function and when it ends in ING appointees is completely 0 isn't that difficult task I I mean in this case you only have 1 point 1 billion and is lowest balance so essentially and the columns you'll have more than 1 point have the reason that I didn't have you have more than 1 minimum distance the lowest anybody fully functional and many more and you have live in England that they look at this is so going and why is this important when a when you're solving this type of program but do not actually know the value of folded falling in your in your functions so each native land you have a fullcolor Montaigne and you only have information of the original so it could be possible that these data files and going out when you have a economy that you're not being there the last line in Milan well and what these
07:35
are convex and no common ones this 2nd in the mountains you choose any 2 points in their work and you'll trace and the line between these 2 points the reference and only on the Palestinian have had a convex function if not the government and this at the same and also the threedimensional convex and nonconvex forms so this sometimes called and took them what is satisfied and 1 strand is are functionally searches is the sign and anyone imagine we have these functions decided on of the function and always going this is the graph underlying meaning if we have no any constant a to point is that that was a lot of for that so we don't have a different type of uh let the user the constant that's means that a builtin volume must be In fact our restrictions so the solution for this problem using their red point this is the ultimate and as you can see a B and point a little I mean inside these arrests itself you don't have inequality constraints that I will you to search your ultimate employing all and the rest is not our and their their season in the case against you can and should do about the point at all the data in a way the constraint and of course you have right the optimum blowing these little and in 1 of the functions so it's an investor and you can tell the other case you are only handled terrorists they optimum point and then there constant so your solution is is really a point even as many all of the statutes idea from uh of the role and meaning of death but this is just a problem and this is the better solutions for this case because you are a constant and this is something of course you have no more than land and any constraint you can the format of there's a sits to find the minimum and the necessary the red point using point of course of these regions but if I did not should be at home with person that we should realize that a lot people to because you have some leads the you and there will be so you write in that allow to deal only can this solution is found as I look at meaning moral can maximum but not the best solution and when most of the figure skating realm where residents say think you'll there's records when and the to these the musician problems can be divided by using these ADS create some of the generated inference another instance you and ask well it's highly unionized some Armenia and I would have been using models that means that you can do shows for sample I only 1 digit dynamic meaning is like what was still that Huffman problem by no viable ideas on so we can have a linear programming problem in there was linear programming problems and non linear programming problem and among the old mixing in the nonlinear programming problem and each 1 of these type of problems have may know a single so or sample we use this simply accelerating to solve linear programming and it is fully so we want well young model can be defined mathematically as some of the series of problems they have problem and as you can see it there are only let you but don't be afraid by your more this all that abstract model because we both data and there was this animal if affirmative systems congress more than the more ways you put that's value of the parameters of political system in the problem because not a tool change and
12:48
and the well then they optimization could be solved through last solid has already has some of the implementation of the mind of only so we define and some of these so it could be that yourself from forming a programming with you deal with OK by what's on the sample for missing there in a linear programming we use violence and seek cigarette is fantastic with and then we can use this all these services throughout the body and so that directly millenium and we that's these are the kind of computer and we did that supports formulation and analysis useful Latin and mathematical problem some of their unveiled plans name of course by young they might interesting because of all their from ways of individual and seen by and this is where and it's get with think about there's even now White by by you well why not mean that biomarkers of resources in has also owing to reason and has a history of and this is the only part of their life in several minutes positive things if the imitation of heart rate said of his time that we worry is and more right so when they become so everything by a more we have to to thank my we stand uh for his help building the con the stateful and finally the results in a conference thank you use it as and freestanding you only have to tag these uh link and you have to stand this summer received by the because they have implemented histories but it's not a problem you want to list them that assault prominent mixing the millionaire parameter that use and to solve nonlinear programming to use people that the cell line and many stars some estimated like mail server where there is different than it was it's only for solving the mentality me see some problem and it's only that is in full by information click the link and the what the the the phoneme that thing name that program the
15:54
that were still for but not very good at all we didn't show you that you will not understand where I'm going to show you know 7 identified in usually the practical part of this so now we're going to prove and well all of problem is that the like to that explained before but again we have 2 cases of those cases so we set all 1984 phosphatase right here and we want to minimize the occurrence but the the healthiest way so we have a lot of constraints we have to be in the size of function options and while that have to be the optimum solution for Sarah Hall I did I actually I'm not good it with quite like the environment and this stuff but I was searching the Internet and when I find a lot of data about the could daily nutrients you should be that what you can see here 4 different women men and children that want to shoot today it's the know someone does that but what using this I have done the problem of so that 1st we need you acquire and say we are everything but it's like is conventional piracy just the 1 and then I like to data them I have to say the data the and not to delivery of everything could be real fiction and you say is not a data and we have I you will choose the bullets In this paper we have only because and then on there it was too late if you want and we set the current will be all constraints values it means in this case we half calories should go and from doing things and some of this stuff in our set of maximum minimum values I want in my diet so for solving this problem 1st we need to improve the model type of problem using a linear problem and the abstract model so we said the sets the the sets of the data are used to get the modeling and in this case we all the products and the nutrients with their paramaters which are data depends on sets I have said before Our of halfclosed nutrients and maximum and minimum of each nutrients said which called was moved to found to 0 and infinity and then we have the variables will be in this case number of servings what we're going to take object of Internet's science the coast of very and it's the the new structure of object function all constraints is there a I think the most difficult part of the 2 because you have to 1 what you're going to doing which are you are more to this problem that and this is very easy well of maximum minimum nothing more in solving the problems that's what I give the answers so I have a solution you see you have 1 solution would scrape we have often to model means we have 3 6 9 euros and while he finished everything done and the solution does for us which but it's not shown more solution in 1 on the it's 1 what the density and he gives the answer makes in this case we get you can lead 1 big mac and you optimize like die not everything planning and what made you core speaker and and not at all but only under the Monday only number on your office to say here is the that's normal graph of what we've gone big mac and you see this black 1 is the documents in 1 means the but this type of thing to have a lot of sold a lot of parts what if you want to eat healthy you go there and debate in the parade not
20:43
dimension to show you something very different always like this problem so that that we can always think of what we can do even more with the diet problems and the within well now we're going to do a bit of certain means how much calories honey in 1 the what URIs in his life while I do this in into said well I do that let's see
21:14
and what we're doing the same thing we do their involvement of Y and we get a data which you will not find that there incidentally McDonald's what's happening well then it is all that it's an abstract model we said was set 4 parameters but in this time you say it's not the nutrients we're going to set a maximum and minimum distance cost 0 and point here is in this case the venerable focusing and objective function that the covariance but more the maximum usage mining is very special and very easy you see that the when you want to me as I to them in the size and we maximize we maximize its you don't have to to do anything more and what all constraints now it will be on the coast and the solution with that is you can eat will mean 2006 from 90 kcal for 5 years so you isn't that what you should do 1 day what what think it's respectable point here as the solution is the you should these 3 hamburgers for 1 year for 9 and warned that it's real domain ranks you wouldn't need few
22:43
now I'm sorry for if we are to make engineers and we laugh reactive and installation domains now you going to see the problem we so normally and will last problem all examples in this case element we sold chemical engineering tend industrial problems so we have to or well you get a proper product and to minimize always environment mental impact was deal with a lot of the products of the light that says to make it easy for you when all products what we can do possible the reactor to at the inner product which will be here in this case and then we can separated water from the outer with distillation and we'll get whiskey and walked but we have do with 2 types of reactors will help but then continues remains about reactive it's what to do in know you put to water and and stop the reaction and then could boiling water on it continues it will be there how much time you want to and installation the same you have but reacted with his policies I think it's on the Simpsons captured in yeah they explode thing but you can do in In short times would time for continued and what that's not why I'm going to show you 1 the simplest structure would half everyone to get it to and then to say we have to waste to got to do we have reactants will have a lot of distillation columns and while we get scientists to say here's what we can do with the minimum environment impact and while we have a lot of reactions everyone is interested in in the I don't think he wouldn't doubt that but here we interesting fact we have to start and this is the 1st time you see them this out and you have to imagine that it was like 2 situations we have situation 1 which is why we have to do this 1 because and every product will be this they are all in this situation not going to happen we have we over in everything is 0 so this part is not existing anymore and it's the hardest quantity with that environment which given what if everyone's interested you can come to me and said it was displayed in you have to do it so now we are going to be introduced by binary virus With this everyone I think what binary our will is the 1 0 well it's exist for it didn't exist so optimizing offline objection using this time it's not a lovely little problem this time we have a real expression with everything my staff and I wanted to show you the because it could be very very that's all themselves what we should do it so you say can use it for everything to go to mcdonalds ought to make you all reactor home and satellite in a whiskey you what you will say you can use everything of this for you only to this end and last but not least we have to sit here and I mean I said before because we are popular part of users on nonprofit organization from the university of encounter which encourage genital engineers to use programming case we actually did learn to program study and what we have to to think of what to say is the 2 and have to say looks to or teachers from Navarro and ruin brief which of updates to justice and hope you enjoyed space and it hi and I wanted to know if you
27:15
know what are the methods for optimization that using said you more or any of the tools that you calling from it like you see the data that we I think that people were and this is the Newtonian at that come the conjugate gradient what kind of method of precision is don't put to the minimum it's normally it's an iterative way saying he he tries every thing and wants to change how the solution will fit everything would normally just seems very some problems what the before washing the you have I 129 equations you have 2 of because the solutions of it's every of them so sometimes it will be a good solution would you get that sometimes not say to play living with we normally use guns and how you will see the characters on there actually that they give very similar to the same solution which is a problem because of resource that stuff like that but we don't know the want to and yet the article it of the 1 thank you very much for the talk with the optimization of calories fall 5 euros did you have any constraints as in non toxic level of salt effect so you can use life those calories so it's just happened to have no constraints on highways looking at that in I've seen an Internet that you should lead to problems of books sold at which is the river of I think it's a lot more than it was looking at it and if you I think if you need that much of calories of sold today when you go to the hospital in the next so it will be I think you can be blocked much for only 1 then you would like to do for you at the end of the month 1 and the all the the 2 thousand 600 calories yet the problem goods from have the look of salt and sugar and that's to what should have been you but the you will have problems later maybe and know maybe not you and you should try we should try to hit the life of me please send me a message tried to be hi thank you for the talk i in the question why can't you drink this was is with was basically drink and drive you know why did that there is a was the waste thundering . 4 if you want to play around buy found that's all that's in this and that's the case that have to study of boat distillation you have a lot of types of different outcomes I think in this case and you have to see that there are some types you can get it from it say not what extracting and not in the water so maybe you yeah In the knowledge that you would use and only and everything we got in the stomach and bearing production you don't should lead difficulties that well I didn't implemented it could so does that mean if you waste water with risk you could you know that at so that OK actually relations this lecture questions and it is it it is it possible to have the 2 objectives of the implemented now the patrician constraints as constraints that but can they be 2 objectives which are somehow weighted that you can say well that you can compromise between the nutritional value and and money spent so it's it's fine if the nutrition value is is not quite as high if if you were saved to euro on the 1 1 and if you have a final deal the if there uh exists knowledge using this technique for sample the fuel and that's the mean of me say no costs and they may even 10 that's what quantities that a different so you have to use their and I did on all take using these is that but yes you could do do it by using only the the this is on the floor when I did this question this is 1 liter would come to the colonists point into what we will be using when you want do it this is that you can on transform 1 function objective and rates this point have to function you only have to to do what I'm dealing with you know what do which normally we don't the distinction 45 minutes was living costs and the reason that she's so so we can have our review and