The plant, I want to control, have some delays on some states and inputs. Is it possible to model it in GRAMPC ? If so, How do you think I should setup the equations in the prob_fct in order to take into account those delays ?
I was thinking of adding new states to the problem in order to model these delays, however since problem formulation is continuous, it does not make sense, isn't it ?
Best regards,
Pierre
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
can you give some more details on your problem formulation? Or can you state a simplified optimization problem that exhibits the same structure? I guess that one of the issues will be that you have to access past state and controls. The trick could be to pass the grampc-pointer via userparam to the problem functions, then you can interpolate arbitrary states using grampc->rws->x and grampc->rws->u. However, more details would be helpful.
Regards,
Andreas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your answer,
A simplified model would be :
dx(t)/dt=Ax(t)+Bu(t-Ts),
If I understand correctly, in this case, the trick would be to use the previous control value uprev as :
grampc.rws.u=[uprev, grampc.rw.u(1:end-1)]
and then at the end of the optimization process take grampc.rws.u( length(uprev)+1 ) as the next input ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yes, something like that could work. In this case, you interpret grampc.rws.u as a new control v(t) = u(t-Ts) instead of u(t). This requires that the first elements of grampc.rws.u are not changed during the optimization, which can be achieved by setting dldu and dfdu_vec to 0 for t < Ts. After the optimization, you have to use v(Ts) = u(0) as input (interpolate grampc.rws.u at t=Ts). I think you would not even have to adjust grampc.rws.u if the option ShiftControl is activated.
Regards,
Andreas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Andreas,
Thank you for your answer,
Even with dfdu and dldu set to zero for t < Tdelay ( I checked with Visual studio), the first elements of grampc.rws.u and grampc.rws.gradu were varying, which is surprising.
So I went in "grampc_run.c" to change how u was updated, line 138 setting the value of " alpha * gradu[igrampc->param->Nu + j] " to zero when i < delay_size.
The results are pretty good for the linear system, however it might not be the proper way to do it.
Regards,
Pierre
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think I know why it didn't work. As described in the GRAMPC manual, the functions ffct, dfdx_vec, dfdu_vec get the global time t_0+t as argument, whereas the functions lfct, dldx, dldx get the prediction time t. Thus testing t < Tdelay in dfdu_vec is essentially t0+t < Tdelay. You have to pass the current time step t0 via userparam to the problem function dfdu_vec and use the condition t-t0 < Tdelay. Could you test this approach and report your results?
Thanks,
Andreas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone,
The plant, I want to control, have some delays on some states and inputs. Is it possible to model it in GRAMPC ? If so, How do you think I should setup the equations in the prob_fct in order to take into account those delays ?
I was thinking of adding new states to the problem in order to model these delays, however since problem formulation is continuous, it does not make sense, isn't it ?
Best regards,
Pierre
Hello Pierre,
can you give some more details on your problem formulation? Or can you state a simplified optimization problem that exhibits the same structure? I guess that one of the issues will be that you have to access past state and controls. The trick could be to pass the grampc-pointer via userparam to the problem functions, then you can interpolate arbitrary states using grampc->rws->x and grampc->rws->u. However, more details would be helpful.
Regards,
Andreas
Thank you for your answer,
A simplified model would be :
dx(t)/dt=Ax(t)+Bu(t-Ts),
If I understand correctly, in this case, the trick would be to use the previous control value uprev as :
grampc.rws.u=[uprev, grampc.rw.u(1:end-1)]
and then at the end of the optimization process take grampc.rws.u( length(uprev)+1 ) as the next input ?
Hello Pierre,
yes, something like that could work. In this case, you interpret grampc.rws.u as a new control v(t) = u(t-Ts) instead of u(t). This requires that the first elements of grampc.rws.u are not changed during the optimization, which can be achieved by setting dldu and dfdu_vec to 0 for t < Ts. After the optimization, you have to use v(Ts) = u(0) as input (interpolate grampc.rws.u at t=Ts). I think you would not even have to adjust grampc.rws.u if the option ShiftControl is activated.
Regards,
Andreas
Hello Andreas,
Thank you for your answer,
Even with dfdu and dldu set to zero for t < Tdelay ( I checked with Visual studio), the first elements of grampc.rws.u and grampc.rws.gradu were varying, which is surprising.
So I went in "grampc_run.c" to change how u was updated, line 138 setting the value of " alpha * gradu[igrampc->param->Nu + j] " to zero when i < delay_size.
The results are pretty good for the linear system, however it might not be the proper way to do it.
Regards,
Pierre
Hello Pierre,
it should be possible to achieve your goal without changing the code of GRAMPC itself. Which settings for Nhor, Thor, dt, and Tdelay did you use?
Regards,
Andreas
You are right, I will try to find another way.
I used : dt=0.01,
Thor=0.5,
Nhor=51
Tdelay=0.05
Thank you for your help
Hello Pierre,
I think I know why it didn't work. As described in the GRAMPC manual, the functions ffct, dfdx_vec, dfdu_vec get the global time t_0+t as argument, whereas the functions lfct, dldx, dldx get the prediction time t. Thus testing t < Tdelay in dfdu_vec is essentially t0+t < Tdelay. You have to pass the current time step t0 via userparam to the problem function dfdu_vec and use the condition t-t0 < Tdelay. Could you test this approach and report your results?
Thanks,
Andreas
Hello Andreas,
I did as you said, and it worked.
Thank you very much,
Pierre