diff --git a/CADETProcess/optimization/optimizationProblem.py b/CADETProcess/optimization/optimizationProblem.py index 9f98bc3b..831f4426 100644 --- a/CADETProcess/optimization/optimizationProblem.py +++ b/CADETProcess/optimization/optimizationProblem.py @@ -2722,7 +2722,9 @@ def get_chebyshev_center(self, include_dependent_variables=True): # !!! Additional checks in place to handle PolyRound.round() # removing "small" dimensions. # Bug reported, Check for future release! - chebyshev_orig = hopsy.compute_chebyshev_center(problem)[:, 0] + chebyshev_orig = hopsy.compute_chebyshev_center( + problem, original_space=True + )[:, 0] try: problem_rounded = hopsy.round(problem) @@ -2730,7 +2732,9 @@ def get_chebyshev_center(self, include_dependent_variables=True): problem_rounded = problem if problem_rounded.A.shape[1] == problem.A.shape[1]: - chebyshev_rounded = hopsy.compute_chebyshev_center(problem_rounded)[:, 0] + chebyshev_rounded = hopsy.compute_chebyshev_center( + problem_rounded, original_space=True + )[:, 0] if np.all(np.greater(chebyshev_rounded, self.lower_bounds)): problem = problem_rounded diff --git a/tests/test_optimization_problem.py b/tests/test_optimization_problem.py index 362ef6da..90abc391 100644 --- a/tests/test_optimization_problem.py +++ b/tests/test_optimization_problem.py @@ -737,7 +737,7 @@ def test_add_linear_constraints(self): self.optimization_problem.add_linear_constraint('var_0', []) def test_initial_values(self): - x0_chebyshev_expected = [0.2928932, 0.7071068] + x0_chebyshev_expected = [1/3, 2/3] x0_chebyshev = self.optimization_problem.get_chebyshev_center( include_dependent_variables=True ) @@ -847,21 +847,14 @@ def transform(): self.assertEqual(variables_expected, variables) def test_initial_values_without_dependencies(self): - x0_chebyshev_expected = [0.79289322, 0.20710678, 0.5] + x0_chebyshev_expected = [0.75, 0.5, 0.5] x0_chebyshev = self.optimization_problem.get_chebyshev_center( include_dependent_variables=False ) np.testing.assert_almost_equal(x0_chebyshev, x0_chebyshev_expected) - variables_expected = [ - 0.7928932188134523, - 0.2071067811865475, - 0.2071067811865475, - 0.4999999999999999 - ] - variables = self.optimization_problem.get_dependent_values( - x0_chebyshev - ) + variables_expected = [0.75, 0.5 , 0.5 , 0.5] + variables = self.optimization_problem.get_dependent_values(x0_chebyshev) np.testing.assert_almost_equal(variables, variables_expected) self.assertTrue( @@ -914,18 +907,14 @@ def test_initial_values_without_dependencies(self): np.testing.assert_almost_equal(x0_seed_10_random, x0_seed_10_expected) def test_initial_values(self): - x0_chebyshev_expected = [0.79289322, 0.20710678, 0.2071068, 0.5] + x0_chebyshev_expected = [0.75, 0.5, 0.5, 0.5] x0_chebyshev = self.optimization_problem.get_chebyshev_center( include_dependent_variables=True ) np.testing.assert_almost_equal(x0_chebyshev, x0_chebyshev_expected) - independent_variables_expected = [ - 0.7928932188134523, - 0.2071067811865475, - 0.4999999999999999 - ] + independent_variables_expected = [0.75, 0.5, 0.5] independent_variables = self.optimization_problem.get_independent_values( x0_chebyshev )