Solved

How to delete all elements from a set prior to each execution

  • 8 September 2020
  • 1 reply
  • 45 views

Hi,

as the title indicates I’d like to delete all elements from a set prior to each execution. Otherwhise elements from the previous execution are messing up my results. Basically I have a set that will only contain elements under a certain condition, but if it doesn’t it still keeps the elements from the previous execution right now. I tried to fix this by calling empty MySet in the MainExecution, MainInitialization or  PostMainInitialization procedures. This just gives me an error saying “The defined domain set “MySet” cannot be emptied”. I don’t quite understand what’s causing the issue here since the set should already be defined, especially when PostMainInitialization gets run after the initialization completed. Can anyone help me out with this?

Thank you!

 

 

icon

Best answer by Gertjan 9 September 2020, 14:52

If it’s defined, you cannot change it (it will be determined automatically on the conditions stated). If you like a set that is changeable by user or code, you should not give it a definition but keep it empty at the start (and fill it via a procedural statement or the UI), or give it initial data which it will receive upon startup of the project.

So e.g. the reply I gave you at  https://community.aimms.com/developers-math-or-programming-39/how-to-define-a-set-as-empty-under-a-certain-condition-713?postid=1908#post1908 is about a defined set. Hence, it cannot be changed via a procedural statement (it will be auto-updated). 

 

View original

1 reply

Userlevel 6

If it’s defined, you cannot change it (it will be determined automatically on the conditions stated). If you like a set that is changeable by user or code, you should not give it a definition but keep it empty at the start (and fill it via a procedural statement or the UI), or give it initial data which it will receive upon startup of the project.

So e.g. the reply I gave you at  https://community.aimms.com/developers-math-or-programming-39/how-to-define-a-set-as-empty-under-a-certain-condition-713?postid=1908#post1908 is about a defined set. Hence, it cannot be changed via a procedural statement (it will be auto-updated). 

 

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator