Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
Addresses #182 . This fixes the bug that IPOPT history files constraint duplicated entries in a hacky way.
Note
It basically checks if the current call is already recorded or not based on
x
values. If the currentx
is identical to the previousx
at which we wrote the history, then we don't write the history.I first wanted to check that based on the type of the call (i.e. constraints or objective), then write the history only when it is an objective (or its gradient) call. This worked fine for cold starts and the code would've been much cleaner, but it is problematic when we parse the history for hot starts.
When we don't record the constraint calls, during the hot start, we need to get info from an adjacent call counter (which is the objective call we recorded at the same
x
). But the problem is that we don't know which adjacent call counter (+1 or -1) we should refer, because we don't know which function (objective or constraints) IPOPT calls first at each iteration. It sometimes calls the objective first, but the other times it calls the constraints first. That's why we have to rely onx
values.Since the code is hacky, it might be better to keep the history file unfixed, but delete the duplicated entries in OptView or somewhere. What do you think @nwu63 @A-Gray-94 ?
Type of change
What types of change is it?
Select the appropriate type(s) that describe this PR
Testing
This is the history file of
test_hs015.py
. It matches what IPOPT claims (12 function and 11 jacobian evaluations). The previous behavior can be found in #238 .Checklist
Put an
x
in the boxes that apply.flake8
andblack
to make sure the code adheres to PEP-8 and is consistently formatted