API - Issues when iterating in optimization algorithm

API - Issues when iterating in optimization algorithm

pedrormbraga
Explorer Explorer
1,579 Views
8 Replies
Message 1 of 9

API - Issues when iterating in optimization algorithm

pedrormbraga
Explorer
Explorer

Hi everyone,

 

I'm developing an algorithm to perform a structural optimization on a RSA steel structure model. It changes the geometry of the structure and its bar sections while iterating hundreds of times until it reaches an weight optimized solution which fill the established design requirements.

 

Unfortunately after 7-8 min of execution (~150 iterations) RSA crashes and suddenly closes without showing any dialog message. It doesn't seems to be related to lack of memory. I am iterating in a for loop and it is crashing each time in a different iteration, so I think it is also not related to a condition of a specific iteration.

 

I would like to know if anybody has any tips and advice on how to implement such kind of iterative algorithm using RSA API in a more efficient manner.

 

I am developing the algorithm in C# as an addin with its own dll. I am already using the RobotApplication.Interactive flag set to "0". I am not using the cache to modify the geometry when iterating since it seems not to be possible to edit existing nodes coordinates with cache.

 

Any help would be very welcome. Thanks in advance.

0 Likes
1,580 Views
8 Replies
  • API
Replies (8)
Message 2 of 9

pedrormbraga
Explorer
Explorer

I realized there is a pattern, the crash always occurs when it is executing one between the methods below:

 

1)  robapp.Project.CalcEngine.Calculate();

 

2)  bar.SetLabel(IRobotLabelType.I_LT_BAR_SECTION, bar_result.NewSection);

 

 

0 Likes
Message 3 of 9

Stephane.kapetanovic
Mentor
Mentor

Use timers to make sure that the sections are recorded when you start the calculations. Augment your code to include predictive convergence of iterations rather than linear front-end computation. Test the usefulness of try / catch blocks to know the contexts in which errors occur. Do unit tests. Use the refresh commands whenever possible. After a few iterations save your file. etc.

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
Message 4 of 9

pedrormbraga
Explorer
Explorer

Hi @Stephane.kapetanovic . Thank you for your answer.

As you suggested, I tried to put timers between and after the bar sections assignments to make sure them were recorded before to start the calculations but it didn't work.

 

Save the file after a few iterations and try / catch blocks didn't work either. It doesn't catches any error, RSA suddenly closes without triggering anything.

 

What refresh commands could I use along the code execution?

I searched in the forum and in the API documentation and the only method I found for this purpose is the robapp.Project.ViewMngr.Refresh(), but I think it is only to refresh the display view, so it is not the case, right? Anyway I tried to use it but it was also unsuccessful.

 

I am not sure if I properly understand what you mean by "augment your code to include predictive convergence of iterations rather than linear front-end computation", could you make it clearer?

 

My algorithm script perform basically the following steps:

 

1) Change geometry assigning new values to some nodes coordinates;

2) Calculate with robapp.Project.CalcEngine.Calculate();

3) Save the extreme values of tension and compression forces in a dictionary in which the keys are the bar names (each "name" is a design group);

4) Define new sections for each design group that fill my customized design requirements and save it in the mentioned dictionary;

5) Assign the new sections to the bars in RSA model using bar.SetLabel(IRobotLabelType.I_LT_BAR_SECTION, bar_result.NewSection);

6) Perform calculations and check if it's necessary to change any section again until there is no longer needed any bar section change - while loop;

7) Calculate the structure self-weight and store it;

8 ) Repeat all the steps above for each new geometry.

 

It is crashing when it is calculating about ~350 models.

Set the flag robapp.Preferences.Multiprocessing = true apparently helps to achieve a higher iteration number but stills crashing.

 

Thank you very much, any help is of great value.

0 Likes
Message 5 of 9

Stephane.kapetanovic
Mentor
Mentor

Now that you've explained how it works, I wanted to say that you can record the displacement of the nodes and the effect it has on stress, sizing, etc. Then it must be possible to remove some iterations in advance or to modify the calculation step. Make a code which takes into account a progression on the basis of the result rather than testing all the positions one by one. The idea is not to exceed 350. Just an idea.

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
Message 6 of 9

pedrormbraga
Explorer
Explorer

@Stephane.kapetanovic 

Now I got your point.

 

But actually this optimization procedure is only a proof-of-concept using a for loop to change the geometry and optimize a small benchmark problem - a 25-bar truss.

 

In fact I am intending to implement a Genetic Algorithm to optimize a real transmission tower, which is a much more complex problem, composed by hundreds of bars. So I must actually run thousands of iterations in a bigger model. Therefore I think to reduce the iterations number would be a workaround to make my POC works but it won't be a solution to the real issue.

 

I want to find a way to keep RSA stable when I am executing the GA and performing thousands of geometry changes and calculations on the model. Is it possible to do it effectively through the API? Is there any suggestions on how to succeed?

 

Thanks!

 

 

 

0 Likes
Message 7 of 9

Stephane.kapetanovic
Mentor
Mentor

Please contact the technical team. I suspect that the API may be overloaded with data, or that an internal error due to data refresh or asynchronism is causing an inconsistency. If you cannot resolve the internal issue, the best option would be to limit the number of iterations. I have several programs coded in this way, either using the Excel Solver with VBA or by controlling a decrement/increment variable within a target range, with linked queries in C#.

When the program creates a long-running task, it is sometimes preferable not to persist with the same Robot instance. In such cases, you should close the instance and restart it at the appropriate moment.

in the case of trussed towers, unlike multi-storey gantries, it is possible to limit your study to the capable normal force of being deduced from the buckling length, even if it means carrying out the a posteriori calculation for the redefined mesh, loads and wind actions. It means that you have to make categories of bars that having similar tension/compression.

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
0 Likes
Message 8 of 9

pedrormbraga
Explorer
Explorer

Thanks for helping. I'm taking all suggestions into consideration.

I'm also contacting the technical team and will post the solution here if I get any.

Message 9 of 9

reinardputra23tw
Explorer
Explorer

Hi Braga, can you share the program code as im also developing an automation program however im kind'a facing similar problem here. Thank you in advance.

0 Likes