Skip to content

Plot constraint violations of eoms with inequalities #464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Peter230655
Copy link
Contributor

@Peter230655 Peter230655 commented May 8, 2025

I changed along the lines discussed in #488, which it should fix.
I tested every combination/permutation I could think of.

When subplots=True I changed the numbering of the eoms, now starting with Eq 0 (before Eq 1). Reason is that like this the user can easily see his eom_bounds key matching the label on the respective plot.

I disregard the case of one eom only.
I cannot imagine a situation that opty gets only one eom, and this eom has bounds.
Of course, easy to add if useful.
Update: I will add it to avoid exceptions.

@Peter230655 Peter230655 changed the title Constraint violations inequalities Plot constraint violations of eoms with inequalities May 8, 2025
@Peter230655
Copy link
Contributor Author

Peter230655 commented May 9, 2025

Again, I tested all combinations I could think of.

- 0 otherwise.

If only one eom is given and and eom bounds are given, then
``subplots`` is set to ``True``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subplots should only be set to true or false by the user.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also "eom" is not a word.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subplots should only be set to true or false by the user.

If only one equation of motion is given, subplots really does not make sense.
I set it to True in the program to simplify the 'logical flow' if only one eom is given.

Copy link
Contributor Author

@Peter230655 Peter230655 May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also "eom" is not a word.

I changed this sentence to: If only one equation od motion is given and eom_bounds are given, the value of the equation of motion will be plotted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the minimum, whether the output is an array of axes or a single axis matters also.

Copy link
Contributor Author

@Peter230655 Peter230655 May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the minimum, whether the output is an array of axes or a single axis matters also.

I believe this was taken care of earlier, It worked with my one-eom example, but I have to double check.
Update: it seems to work with one eom and no instance constraints.

@Neville-N
Copy link

I believe it would be clearer if the plot_constraint_violations function plotted only the violations, even when the subplots argument is set to True.

@Peter230655
Copy link
Contributor Author

Peter230655 commented Jun 2, 2025

I don't want to beat a dead horse, but I just thought of this:
Say your are not very sure of the values of a, b in a < eom_i < b, so you make a good guess.
Say, it turns out that you selected a much too small, and b much too large. With the present method you could see this and adjust them.
Would this adjusting speed up opty \ Ipopt, as the search space becomes smaller`?
If this is true, it may be worth giving an additional optional keyword, if not I will change it as we discussed.
@moorepants: I do not want to be pushy, but I think, this plotting method is useful. If you want to release the next opty version before July or so, please let me know whether this thoguht above is uselful or not. Then I can finish it.
Thanks!

@Peter230655
Copy link
Contributor Author

Peter230655 commented Jun 14, 2025

The violations of the inequality constraints are shown, as discussed during the recent hackathon.
I added an optional keyword show_range, default is False. If True and if subplots is True, its shows the range of the bounded eoms.
My reason:
Maybe in a < eom_i < b, a is set way too small, and b way too large. withshow_range == True this will be visible. Making a larger and b smaller reduces the size of the search space for Ipopt and may make it faster.
If this reasoning is wrong, the key word should be removed.

I tested it with one eom only, too (plot_betts_10_7). For the main tests I used plot_car_one_racecourse_smooth, where there are many eom_bounds available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants