[New user]: per iteration hook or callback

70 views
Skip to first unread message

a-jp

unread,
Apr 7, 2022, 7:40:01 AM4/7/22
to Pyomo Forum
Hi,
Using Pyomo with ipopt.  Would it be possible, every iteration, before any objective or constraint is solved, to call a user defined function?  Is there any example if so?  It's important that I can perform this before any work is done, each iteration, including the first iteration. I would like the function to be passed the current status of model.  

I would equally be interested in a post-completed iteration hook, but the above is explicitly for a pre-iteration hook.

Thanks,
Andy

a-jp

unread,
May 13, 2022, 11:53:07 AM5/13/22
to Pyomo Forum
It would be good to get confirmation that this can't be done, so I can try to refactor my design?

Michael Bynum

unread,
May 13, 2022, 11:57:47 AM5/13/22
to Pyomo Forum
There are examples of using callbacks with cyipopt here:


Michael

a-jp

unread,
May 13, 2022, 12:09:49 PM5/13/22
to Pyomo Forum
thanks, that's really helpful.  Based only on the name and the comments 'intermediate_callback' seems to be for once the work for each iteration as been completed it is called, I need to perform some setup each iteration, and cache complex and expensive functions into an array, is there a callback that can be performed before the iteration begins and before any constraints or objectives are solved for that iteration?
Thanks,
Andy

a-jp

unread,
May 18, 2022, 5:11:06 AM5/18/22
to Pyomo Forum
Hi Michael,

I wondered if you had any more thoughts about a callback approach/function that I could use at the start of each ipopt iteration rather than at the end?
thanks
Andy
Reply all
Reply to author
Forward
0 new messages