Hi! Thanks for the video. Your content on MPC has been my guidance to understand this kind of control. I was wondering, this is an example for an open-loop MPC, right? Do you have any example for close-loop? I mean, changing the size of the horizon, applying the first step of control on a simulation of the system, and recompute the trajectory for the next step til the final of the simulation. Thanks!
@apm6 ай бұрын
Sure, here is a complete series of tutorials with an Arduino device for real-time MPC. apmonitor.com/do/index.php/Main/AdvancedTemperatureControl Lab F is linear MPC, the easiest to implement.
@alexrunako37663 жыл бұрын
How is the Weight (Wt) determined? Can we set it ourselves?
@apm3 жыл бұрын
Wt is set with WSPHI / WSPLO (for l1-norm) and WSP (for square error). There is also DCOST for the change penalty. See apmonitor.com/wiki/index.php/Main/OptionDcost and apmonitor.com/do/index.php/Main/ControllerTuning
@andreruizzz10 ай бұрын
Hi John! Can I add a DV with gekko?
@apm10 ай бұрын
Yes, define a parameter with m.Param() and update the value with m.Param() with a constant or an array of values equal in length to m.time for dynamic problems. You can also define it as m.MV() with STATUS off to use the MEAS property to insert at the current time point and let Gekko handle the time shifting.
@apm10 ай бұрын
I recommend the MPC tutorials with the TCLab here: apmonitor.com/do/index.php/Main/AdvancedTemperatureControl See Lab F For an example of linear MPC with the Arduino microcontroller.
@alexrunako37663 жыл бұрын
Hi, can I ask again how is the Time Horizon, Control Horizon, and Prediction Horizon determined by using m.time?
@apm3 жыл бұрын
You can either use m.time or m.options.CTRL_HOR / m.options.PRED_HOR / m.options.CTRL_TIME / m.options.PRED_TIME. I recommend using m.time where there is no "prediction" horizon to calculate a steady state. Instead, use a non-uniform time distribution such as m.time=[0,0.2,0.4,1,2,4,10]. The first time step is the cycle time of the controller. The larger time steps help to reach steady state.
@patrickduhirwenzivugira47293 жыл бұрын
How can I use a trained model (let's say Keras saved model) as the process model?
@apm3 жыл бұрын
Check out this course (see LSTM) apmonitor.com/pds
@patrickduhirwenzivugira47293 жыл бұрын
@@apm Thank you very much. I will check it out
@patrickduhirwenzivugira47293 жыл бұрын
@@apm I have checked the course but couldn't find a solution. I have a model Keras model saved as .h5. Can I use this model to represent the system dynamics instead of an equation?
@dioalifputra85093 жыл бұрын
I have the same problem here
@ahmedtamer95684 жыл бұрын
Hello , can I add a vector to track a trajectory in the obj function instead of a point ? where the size of the vector is Nx1 where N is the prediction horizon
@apm4 жыл бұрын
Yes, just add a p=m.Param([your values]) and then define a new variable y=Var() with objective m.Minimize((y-p)**2). Please post to StackOverflow with tag gekko if you get stuck.
@BADERAK904 жыл бұрын
is it possible to have a custom loss function? instead of l1 or l2?
@apm4 жыл бұрын
Yes, you can use m.Minimize( ) or m.Maximize( ) with any mathematical expression in the ( ).
@BADERAK904 жыл бұрын
APMonitor.com Great! Thank you
@talebbouhamdan79843 жыл бұрын
Thank you for the explanation, what if the system model is discrete how can I declare it?
@apm3 жыл бұрын
Here is a discrete state space model: apmonitor.com/wiki/index.php/Apps/DiscreteStateSpace there is also an ARX model in gekko. Search for arx and sysid in the documentation.
@liminm74512 жыл бұрын
Dear Mr John, I want to use this function according your tutorial but it didn't work : point = [40,20,10,35] traject= [1,30,60,100] for i in range (len(point)): # Controlled Variable v = m.CV(value=0) v.STATUS = 1 # add the SP to the objective v.TAU = 5 # time constant of trajectory m.options.CV_TYPE = 2 # squared error m.options.IMODE = 6 # control v.SP = point[i] # set point v.TR_INIT = traject[i] # set point trajectory # Process model m.Equation(mass*v.dt() == -v*b + K*b*p) m.solve(disp=False) but found : vp.__dict__[o] = data[vp.name][o] KeyError: 'v2' how to solve it ? Thank you
@apm2 жыл бұрын
Please post the question on Stack Overflow with tag [gekko]: stackoverflow.com/questions/tagged/gekko
@유재진-s9f4 жыл бұрын
Can I change the equation which is like 'y = a + bu'?
@apm4 жыл бұрын
Yes, you can change the equation to anything or also have many equations. More information on the Gekko modeling language is here: gekko.readthedocs.io/en/latest/
@유재진-s9f4 жыл бұрын
I just got it ! Thank you so much ! Is it possible to make noise variable which is changed every iteration time in the equation Y = a + bu, a
@apm4 жыл бұрын
Yes, just add it as an input parameter to the model.
@유재진-s9f4 жыл бұрын
What I mean is that I can add the equation just once like thism.Equation(y == a + bu)but I want to change 'a' variable value in order to get every controlled variable results.Thank you.
@apm4 жыл бұрын
@@유재진-s9f maybe this tutorial can help? apmonitor.com/do/index.php/Main/TCLabF It shows how to insert measurements with a.MEAS = number and align the predicted CV with the measured CV. It also shows how to retrieve values when there is a solution. You can add any equation to the model and insert any value each cycle of the controller.
@ibtehajk4 жыл бұрын
Hi,, Can we use 2 manipulated variables?
@apm4 жыл бұрын
Yes, you can use any number of MVs and CVs. Here are a couple MIMO examples: apmonitor.com/do/index.php/Main/TCLabF
@tpsetati5 жыл бұрын
Incredible tutorial! Could I ask, is there a tutorial for real-time MPC?
@apm5 жыл бұрын
Yes, here is linear MPC in real-time: apmonitor.com/do/index.php/Main/TCLabF