Economic Model Predictive Control
Вставка
- Опубліковано 7 бер 2018
- Set up and solve the commercial fishing economic optimal control problem. Create a program to optimize and display the results. The commercial fishing optimal control problem has an integral objective function. The population of fish x is influenced by how many fish are removed each year that depends on u. The objective is to maximize the revenue from fishing over a 10 year time period. If there is overfishing (high u) then the returns for subsequent years are reduced and the fish population does not recover. This optimal control problem finds the optimal extraction profile to maximize the commercial fishing profit. See apmonitor.com/do/index.php/Mai... for source code in MATLAB and Python.
- Наука та технологія
What if I want to change one of the constraints after some time period has passed? What I'm trying to do is to include demand shocks by changing the functional form of the demand equation after some time t.
You can define an input Parameter that has a different demand at every time point or a step in value.
Thanks for the video.
Why is the maximum fishing rate not sustained for longer to achieve a higher profit? There are still fish remaining after 10 years?
If they started max fishing earlier then the decreased fish population would have less reproduction and decrease the profits for the final years. Try fixing a different fishing profile and observe the objective value. For example, try max fishing the entire time horizon and the profit is lower. The interesting thing about this case study is that sustainability is also the most profitable solution.
Thank you.@@apm
Hello again APMonitor, great tutorial as always.
I have a question though; is there any way to set variables to being strictly integers.
For example, if I want my manipulated variable to range between [1,2,3,..,n], or even my controlled variable.
I cant seem to find any settings within the GEKKO variable-functions. Does anyone have any suggestions?
Sure, just set the parameter to integer=True when you define the MV. Here is some additional help on using Integer variables: apmonitor.com/do/index.php/Main/DiscreteVariables You'll also need to switch to the APOPT solver with m.options.SOLVER = 1.
@@apm Brilliant, and thank you for such quick and informational answers!
Some more questions for when you have time and will to answer them:
1. The option for SOLVER = 3 worked for me as well. It says in the GEKKO docu that option 1 is for simulation, and I am actually trying to control something with an "integer" input (option 3 actually gives a higher final "score" for me). Am I missing something about the mechanics of these solvers?
2. As I am trying to control something in discrete steps, is there any function other than dt() that ought to be used instead to describe a state transition x(k+1) = g(x(k),u(k))? Or is it just to define the "m.time"-vector accordingly?
Really looking forward to your answers :)
@@Aquelzor yes, IMODE=1 is for steady-state simulation. It means that you need to have the same number of variables and equations and all of the derivative .dt() values are set to zero. If you have an integer decision variable then you'll need IMODE=3 so that you can optimize the inputs to give a better objective function value. Here is additional information on IMODE: apmonitor.com/wiki/index.php/Main/OptionApmImode
The SOLVER parameter is different than IMODE. If the solver finds a solution, all solvers should give the same answer, unless integer variables are involved. If there are integer variables then SOLVER=1 will give a worse objective because it is enforcing integer values while the other solvers may report non-integer values. Here is additional information on the SOLVERS: apmonitor.com/wiki/index.php/Main/OptionApmSolver
The m.time vector is used to determine where you want to calculate solutions. If you have a discrete linear time-invariant model, then you can use a discrete state space model as shown here: www.apmonitor.com/wiki/index.php/Apps/DiscreteStateSpace If you have a model with continuous derivative values then you shouldn't need the discrete state-space model. The collocation method is used to turn the continuous form into a form that can be solved at discrete time points: apmonitor.com/do/index.php/Main/OrthogonalCollocation
Can I ask a silly question?
Most of ur tutorials are about linear or nonlinear optimization methodologies.
How about heuristic algorigthm(ex: partical swarm, genetic algorithm optimization)?
These methods are also about optimization solutions, but they seems seldom been used in ur tutorial.
Can I ask why? Hoping u can answer my question.
Big thanks~!
I'm teaching the Dynamic Optimization course right now (apmonitor.com/do) so most of the problems are related to the content that is taught. I also teach an optimization course where we cover some of the topics that you mentioned. Here is the chapter on Genetic Algorithms: apmonitor.com/me575/index.php/Main/GeneticAlgorithms and here is content on simulated Annealing: apmonitor.com/me575/index.php/Main/SimAnnealHW - there are lots of other examples as well. There are PDF book chapters that give a broader treatment of optimization methods. Regarding model predictive control, genetic algorithm or particle swarm methods are sometimes too slow for real-time implementation so I favor gradient based methods that are fast but also only find local solutions. Genetic algorithms or particle swarm methods are nice for situations where you have more time (such as offline) or when you know that your problem is non-convex and you need a global solution method.
Very thanks for your reply!!
You Clearly solve my doubt.
Big thanks again~!
You can sell this solution to some company or government? Or what are you going to do with it?
Most large companies and advanced governments perform these types of optimization and modeling analyses. It helps determine policy and investment. This is a very simple example and the ones used in practice are very detailed and complicated but the same principles apply.
How can we handle the case with two controls say u_1 and u_2, two state space and do we still define the bounds of the control in the same way?
Here is an example with MIMO control. apmonitor.com/do/index.php/Main/TCLabF and a simple example: apmonitor.com/wiki/index.php/Apps/LinearStateSpace (see Gekko example at the end).
@@apm ok. Thanks a lot
In the matlab dwonload file what is defined by s and a in fishing.m
s is the server address and a is the application name
@@apm while running this code i get error in python IDLE as 'GEKKO' object has no attribute 'equation' how do i fix that sir?
This Gekko error is showing up in python3.6.4 and for python 3.9.0 it is showing module matplotlib is missing and after perofrming pip install it isnt getting setup
@@swapnilchandra759 try it with a capital E instead: m.Equation()
@@swapnilchandra759 here is information on how to install packages such as matplotlib: apmonitor.com/pdc/index.php/Main/InstallPython