problem with yalmip in simulink

29 views
Skip to first unread message

Ali Ah

unread,
Jul 16, 2025, 9:36:01 AMJul 16
to YALMIP
Hi
Dear Prof.Johan Löfberg , i have a problem with Deepc simulation using yalmip in simulink.
it keeps solving more than once at each sampling time(Ts = 0.1) and so it takes a very long time(solver is called a 1000 times at 1 sampling time).
i'd very much appreciate it , if you could guide me with this problem.
i also use the line 
set_param(gcb,'SampleTime','0.1');
before simulation in simulink.
run data collection file first ,run the simple line of code above and then open and run the simulink file
deepc_slow.m
discrete_data_collection.m
simulink_deepc.slx

Johan Löfberg

unread,
Jul 16, 2025, 10:00:35 AMJul 16
to YALMIP
Have you read this first https://yalmip.github.io/example/simulink/

Ali Ah

unread,
Jul 16, 2025, 10:28:48 AMJul 16
to YALMIP
yes i have read the link , i tried to follow it's instructions (especially the last one about the persistent optimizer) , i have checked the solver and it does solve manually with no errors . the problem is that it solves more than once at a sampling time

Johan Löfberg

unread,
Jul 16, 2025, 11:24:52 AMJul 16
to YALMIP
I think it is that you have an algebraic loop in the model, so simulink will solve the nonlinear system of equations at every sample instant, which thus means evaluating the function until it is solved. You will have to get rid of this algebraic loop

Ali Ah

unread,
Jul 16, 2025, 5:50:23 PMJul 16
to YALMIP
Hi
Dear Prof.Johan Löfberg thank you so much for providing me with this answer , i deleted the algebraic loop and instead recorded the controller output inside the controller (persistent)
and checked it and it's working beautifully . your guess was correct!

Reply all
Reply to author
Forward
0 new messages