Commit 07e4a342 authored by Jorn Baayen's avatar Jorn Baayen

GoalProgrammingMixin: Fix bug that prevented path goals from being marked as critical.

parent 8f819939
......@@ -640,7 +640,7 @@ class GoalProgrammingMixin(OptimizationProblem):
if goal.critical:
if not goal.has_target_bounds:
raise Exception("Minimization goals cannot be critical")
epsilon = 0.0
epsilon = np.zeros(len(self.times()))
epsilon = MX.sym('path_eps_{}_{}'.format(i, j))
......@@ -307,6 +307,37 @@ class TestProblemPathGoalsMixed(TestProblemPathGoals):
return [TestGoalMinU()]
class PathGoal1Critical(Goal):
def function(self, optimization_problem, ensemble_member):
return optimization_problem.state('x')
function_range = (-1e1, 1e1)
priority = 1
target_min = 0.0
critical = True
class TestGoalLowerUCritical(Goal):
def function(self, optimization_problem, ensemble_member):
return optimization_problem.integral('u', ensemble_member=ensemble_member)
function_range = (-1e1, 1e1)
priority = 3
target_min = 1e-6
critical = True
class TestProblemPathGoalsMixedCritical(TestProblemPathGoals):
def path_goals(self):
return [PathGoal1Critical(), PathGoal2()]
def goals(self):
return [TestGoalLowerUCritical()]
class TestGoalProgrammingPathGoalsMixed(TestGoalProgrammingPathGoals):
def setUp(self):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment