How to clear a workspace written by ToBase block?
How can we clear a workspace created by ToBase blcok?
I made a model where a simulation is iterated by using End block with FromBase and ToBase. It runs without any problem, but when it runs again, FromBase block reads the value that the previous run wrote. I want to start the run from a scratch.
I used clear OML command, but it doesn't work.
Answers
-
Yubuchi-san,
Is it possible to share the model, or a simplified version of it? Generally speaking we use "FromBase" and "ToBase" in optimization models, which purposefully you should not change the values during the iterations.
After the iterations (simulation is finished), if you use 'clear' command you will have the initial values again and you can run it with the desired behavior.
Regards, João.
0 -
João
Thank you for the quick response. I attached the model.
Regards,
Minoru Yubuchi
0 -
Minoru Yubuchi_21921 said:João
Thank you for the quick response. I attached the model.
Regards,
Minoru Yubuchi
Yubuchi-san,
Please correct me if I am wrong, but I guess you would like to reinitialize "Peak" value after each iteration, am I right?
If this is your purpose, you can call 'Peak' variable on From Base block as 'Peak_1' and set its value on Diagram Home:
With this setup above, your matrix Peak_1 will be always 'zeros(N,1)' and your Peak will be changing after each iteration.
Hope it helps you.
Regards, João.
0 -
João,
Thank you but what I want to do is to clear the vector Peak after the iterations (100 in this model) were done, not in each iteration.
If I reboot Activate, the Peak is cleared. I want to clear it without exiting from Activate.
Regards,
Minoru Yubuchi
0 -
Minoru Yubuchi_21921 said:
João,
Thank you but what I want to do is to clear the vector Peak after the iterations (100 in this model) were done, not in each iteration.
If I reboot Activate, the Peak is cleared. I want to clear it without exiting from Activate.
Regards,
Minoru Yubuchi
Yubuchi-san,
Now I got your question. So there are some points to highlight here:
1) You defined "IfThenElse" block based on "N" that is the total number of iterations (100), once this is reached, your model will Stop, as you defined.
2) "Peak" variable is a result of some calculations, hence, this could not be Set to a certain value (with your actual setup of blocks).
Here I would create a logic like: While "__counter__" is smaller to "N" you will calculate "Peak", if it is equal or bigger, you will reinitialize "Peak" (set as zero) and finish your simulation. Below I changed your model with this logic that I mentioned above:Where "u1" is "__counter__" and u2 is "Y". I would suggest you to play with "MatrixExpression" block to create these logics. You can use it creating 'if / else' without the need of writing, as I did above.
Your model is attached, hope it helps you.
Regards, João.
0 -
João,
I am sorry, but your model doesn't work. The VectorScope in my model should create the following plot as a result:
Anyway, for you to understand the problem, please run the demo model, car_max_dist_30sec.scm, twice. The first run start with the values of the 'gear' as follows:
as defined in the dialog of the FromBase block, and then the run ends with the following values:
The problem is that the second run starts with these values, not the values defined in the FromBase as initial values. I want use the initial values set in the FromBase.
Regards,
Minoru yubuchi
0 -
Minoru Yubuchi_21921 said:
João,
I am sorry, but your model doesn't work. The VectorScope in my model should create the following plot as a result:
Anyway, for you to understand the problem, please run the demo model, car_max_dist_30sec.scm, twice. The first run start with the values of the 'gear' as follows:
as defined in the dialog of the FromBase block, and then the run ends with the following values:
The problem is that the second run starts with these values, not the values defined in the FromBase as initial values. I want use the initial values set in the FromBase.
Regards,
Minoru yubuchi
Yubuchi-san,
The easiest way to solve it is: Writing 'clc, clear, close all' on OML Command Window instead of Model diagram, otherwise your first values will come from the last run, as you already saw.
Besided that you can use "Exec OML Script" block, and execute it after you iterations:
Using these two ways that I mentioned above, you can get exactly what you want - reinitialize 'gear' values.
Thanks, João.
0 -
João,
Thank you so much! I could get what I wanted.
Regards,
Minoru Yubuchi
0