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

[OptApp] Small fix for QNBB #12262

Merged
merged 6 commits into from Apr 18, 2024
Merged

[OptApp] Small fix for QNBB #12262

merged 6 commits into from Apr 18, 2024

Conversation

Igarizza
Copy link
Member

@Igarizza Igarizza commented Apr 9, 2024

📝 Description
Changes the QNBB max step comparison logic for QNBB to avoid small step size estimations.

Copy link
Member

@sunethwarna sunethwarna left a comment

Choose a reason for hiding this comment

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

Minor comments only. Nice :) thanks @Igarizza :)

Comment on lines +64 to 81
def test_L2_max(self):
param = Kratos.Parameters("""{
"type" : "l2_norm",
"max_iter" : 2,
"tolerance" : 1e-4
}""")
algorithm_data = ComponentDataView("algorithm", self.optimization_problem)
convergence_criterium = CreateConvergenceCriteria(param, self.optimization_problem)
search_direction = KratosOA.CollectiveExpression([Kratos.Expression.ElementExpression(self.model_part)])
KratosOA.CollectiveExpressionIO.Read(search_direction, KratosOA.CollectiveExpressionIO.PropertiesVariable(Kratos.DENSITY))
algorithm_data.GetBufferedData()["search_direction"] = search_direction
self.assertFalse(convergence_criterium.IsConverged())
self.optimization_problem.AdvanceStep()
algorithm_data.GetBufferedData()["search_direction"] = search_direction
self.assertFalse(convergence_criterium.IsConverged())
self.optimization_problem.AdvanceStep()
algorithm_data.GetBufferedData()["search_direction"] = search_direction
self.assertTrue(convergence_criterium.IsConverged())
Copy link
Member

Choose a reason for hiding this comment

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

I would add a test for max_iter as well

Copy link
Member Author

@Igarizza Igarizza Apr 17, 2024

Choose a reason for hiding this comment

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

It is a test for max iter, other one without max in the test name, it tests the expected behavior of conv. criteria

Comment on lines +146 to +161
def test_TargetValue_max(self):
param = Kratos.Parameters("""{
"type" : "target_value",
"max_iter" : 2,
"target_value" : 0.001
}""")
algorithm_data = ComponentDataView("algorithm", self.optimization_problem)
convergence_criterium = CreateConvergenceCriteria(param, self.optimization_problem)
algorithm_data.GetBufferedData()["std_obj_value"] = 1
self.assertFalse(convergence_criterium.IsConverged())
self.optimization_problem.AdvanceStep()
algorithm_data.GetBufferedData()["std_obj_value"] = 0.1
self.assertFalse(convergence_criterium.IsConverged())
self.optimization_problem.AdvanceStep()
algorithm_data.GetBufferedData()["std_obj_value"] = 0.01
self.assertTrue(convergence_criterium.IsConverged())
Copy link
Member

Choose a reason for hiding this comment

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

I would add a test for max_iter

Copy link
Member Author

Choose a reason for hiding this comment

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

It is a test for max iter

…/algorithm_momentum_relaxed_gradient_projection.py

Co-authored-by: Suneth Warnakulasuriya <suneth.warna@gmail.com>
@Igarizza
Copy link
Member Author

@sunethwarna FSI application fails=(

Copy link
Member

@sunethwarna sunethwarna left a comment

Choose a reason for hiding this comment

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

Thanks @Igarizza

@Igarizza Igarizza merged commit 6d9da85 into master Apr 18, 2024
11 checks passed
@Igarizza Igarizza deleted the optapp/fixQNBB branch April 18, 2024 07:33
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.

None yet

2 participants