Skip to content
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

Successive constraints method #1989

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

HenKlei
Copy link
Member

@HenKlei HenKlei commented Mar 16, 2023

Since @sdrave was complaining about the missing successive constraints method for a few times now, I started implementing something in that direction. However, this is far from being finished at the moment.

@HenKlei HenKlei added the pr:new-feature Introduces a new feature label Mar 16, 2023
@HenKlei HenKlei added this to the 2023.1 milestone Mar 16, 2023
@HenKlei HenKlei self-assigned this Mar 16, 2023
@sdrave
Copy link
Member

sdrave commented Mar 22, 2023

Seems like I should complain more often ... Maybe we can discuss things offline next week?

@HenKlei
Copy link
Member Author

HenKlei commented Mar 23, 2023

Seems like I should complain more often ... Maybe we can discuss things offline next week?

Yes of course, let's discuss this next week.

@pmli pmli modified the milestones: 2023.1, 2023.2 May 9, 2023
@sdrave sdrave removed the autoupdate label May 12, 2023
@HenKlei HenKlei force-pushed the successive-constraints-method branch from 55a155b to 61d1f23 Compare July 13, 2023 07:32
@HenKlei
Copy link
Member Author

HenKlei commented Oct 19, 2023

@sdrave Do you think you will have time to discuss and look into this before the release?

@pmli pmli modified the milestones: 2023.2, 2024.1 Nov 2, 2023
@sdrave sdrave modified the milestones: 2023.2, 2024.1 Nov 24, 2023
@HenKlei
Copy link
Member Author

HenKlei commented Feb 13, 2024

Note to myself: Use pyMOR's eigs-method instead of numpy. Done.

@HenKlei HenKlei force-pushed the successive-constraints-method branch from 61d1f23 to 1c0bcd7 Compare February 27, 2024 14:28
@HenKlei HenKlei force-pushed the successive-constraints-method branch from 15ac296 to 65ab174 Compare February 29, 2024 16:42
@HenKlei HenKlei marked this pull request as ready for review February 29, 2024 16:42
@HenKlei HenKlei requested a review from sdrave February 29, 2024 16:42
@HenKlei
Copy link
Member Author

HenKlei commented Apr 27, 2024

It would be great if you could take a look at this @sdrave when you find time.

@HenKlei
Copy link
Member Author

HenKlei commented Apr 27, 2024

The pipelines are failing due to a very old scipy version (1.5.4) where the 'highs' method (which is now the default) was not available as solver of a linear program in scipy. 'simplex' would be a method that is supported in probably all versions but is considered legacy in current versions. So maybe also not the best option to use that one as default.

How about pinning scipy to >=1.7.0?

@sdrave
Copy link
Member

sdrave commented May 6, 2024

The pipelines are failing due to a very old scipy version (1.5.4) where the 'highs' method (which is now the default) was not available as solver of a linear program in scipy. 'simplex' would be a method that is supported in probably all versions but is considered legacy in current versions. So maybe also not the best option to use that one as default.

How about pinning scipy to >=1.7.0?

Debian oldstable has 1.6.0. I think that should be enough as well? Any reasons to require 1.7?

Copy link
Member

@sdrave sdrave left a comment

Choose a reason for hiding this comment

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

Hi @HenKlei, I think the code generally looks nice.

My biggest concern is that you have to solve the same eigenproblems ('SM') for both the upper and lower bound functional (and the upper bound functional does not allow passing the solutions via __init__). I wonder whether it makes more sense to refactor the code into an algorithms.scm module, with a function which instantiates both functionals. That would be somewhat less elegant, but would avoid significant offline costs.

Further remarks:

  • Have you considered also implementing the greedy algorithm from the paper? Should be fairly straightforward.
  • I have never looked into this personally, but how does the situation look like for inf-sup stable problems? Can we easily support this as well?
  • As already discussed, it would be good to extend the demo/add another demo to validate the performance of the method (only looking at the coercivity constants).

Parameters
----------
operator
|LincombOperator| for which to provide a lower bound on the coercivity constant.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
|LincombOperator| for which to provide a lower bound on the coercivity constant.
|LincombOperator| for which to provide a upper bound on the coercivity constant.

def __init__(self, operator, constraint_parameters,
method='highs', options={}, M=None, bounds=None, coercivity_constants=None):
from pymor.operators.constructions import LincombOperator
assert isinstance(operator, LincombOperator)
Copy link
Member

Choose a reason for hiding this comment

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

Also check that all of operator.operators are non-parametric and linear.

for f in operator.coefficients)

if self.M is not None:
self.M = min(self.M, len(self.constraint_parameters))
Copy link
Member

Choose a reason for hiding this comment

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

Maybe output a warning if M is clipped?

|LincombOperator| for which to provide a lower bound on the coercivity constant.
constraint_parameters
List of |Parameters| used to construct the constraints.
method
Copy link
Member

Choose a reason for hiding this comment

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

@defaults?

If `None`, all parameters from `constraint_parameters` are used.
bounds
Either `None` or a list of tuples containing lower and upper bounds
for the design variables.
Copy link
Member

Choose a reason for hiding this comment

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

Explain what design variables means in this context.

self.logger.info('Computing coercivity constants for parameters by solving eigenvalue problems ...')
self.coercivity_constants = []
for mu in constraint_parameters:
fixed_parameter_op = FixedParameterOperator(operator, mu=mu)
Copy link
Member

Choose a reason for hiding this comment

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

Why not

Suggested change
fixed_parameter_op = FixedParameterOperator(operator, mu=mu)
fixed_parameter_op = operator.assemble(mu)

_, indices = self.kdtree.query(mu.to_numpy(), k=self.M)
selected_parameters = [self.constraint_parameters[i] for i in list(indices)]
else:
indices = list(range(len(self.constraint_parameters)))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
indices = list(range(len(self.constraint_parameters)))
indices = np.arange(len(self.constraint_parameters))

?


def __init__(self, operator, constraint_parameters):
from pymor.operators.constructions import FixedParameterOperator, LincombOperator
assert isinstance(operator, LincombOperator)
Copy link
Member

Choose a reason for hiding this comment

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

See above.

self.minimizers = []
from pymor.algorithms.eigs import eigs
for mu in self.constraint_parameters:
fixed_parameter_op = FixedParameterOperator(operator, mu=mu)
Copy link
Member

Choose a reason for hiding this comment

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

See above.

# select reduction algorithm with error estimator
#################################################
bounds = None
coercivity_constants = None
Copy link
Member

Choose a reason for hiding this comment

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

Why do you put this here?

@HenKlei
Copy link
Member Author

HenKlei commented May 7, 2024

The pipelines are failing due to a very old scipy version (1.5.4) where the 'highs' method (which is now the default) was not available as solver of a linear program in scipy. 'simplex' would be a method that is supported in probably all versions but is considered legacy in current versions. So maybe also not the best option to use that one as default.
How about pinning scipy to >=1.7.0?

Debian oldstable has 1.6.0. I think that should be enough as well? Any reasons to require 1.7?

You're right, 1.6.0 would be sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:new-feature Introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants