Menu

Update the userparam at each time step

Kexianshen
2020-06-16
2020-06-17
  • Kexianshen

    Kexianshen - 2020-06-16

    Hello,

    I read the section 5.1.2 and 5.1.3 of the documentation and realize the only way to update the userparam is to initialize the grampc at each time step. I can not use the function grampc_setparam_real_vector because userparam does not belong to the GRAMPC parameter structure. Doing initialization of GRAMPC in each time step seems time-consuming. Do I miss something important in the documentation? Looking forward to your reply.

    Thank you.

     
  • Andreas Völz

    Andreas Völz - 2020-06-16

    Dear Kexianshen,

    from reading sections 5.1.2 and 5.1.3 in the documentation, I infer that your are using GRAMPC directly in C. In this case, note that the grampc structure only stores a pointer to userparam, which is then passed on to each of the problem functions (ffct, dfdx_vec, dfdu_vec, lfct, ...). The user is responsible for memory allocation and deallocation of whatever is behind userparam, for example an array of doubles or a struct with multiple fields. This means that you can simply modify and update the indiviual entries of userparam (even within the problem functions) without having to call a grampc_set...-function or calling grampc_init again.

    Please ask if you need further help.

    Best regards,
    Andreas Völz

     
  • Kexianshen

    Kexianshen - 2020-06-17

    Thanks Andreas, I get it.

    At the very beginning, I was trying to generate C code from simulink models. The problem is that my system tlc does not support non-inlined S-functions. So I leave data ports in simulink models, and directly use GRAMPC after code generation. And then I will learn to write the tlc file to inline the S-functions.

    Best regards,
    Kexian

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.