Skip to content

Commit

Permalink
Add support for creating x0 with linear equality constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
schmoelder committed Jan 9, 2024
1 parent 419081a commit 658221f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CADETProcess/optimization/optimizationProblem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2691,6 +2691,13 @@ def compute_negative_log_likelihood(self, x):
simplify=simplify,
)

if self.n_linear_equality_constraints > 0:
problem = hopsy.add_equality_constraints(
problem,
self.Aeq,
self.beq
)

return problem

def create_initial_values(
Expand Down
8 changes: 1 addition & 7 deletions CADETProcess/optimization/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,7 @@ def optimize(
if reinit_cache:
self.optimization_problem.setup_cache()

if x0 is None:
if optimization_problem.n_linear_equality_constraints > 0:
raise CADETProcessError(
"x0 should be set by the user if linear equality "
"constraints are specified."
)
else:
if x0 is not None:
x0check = np.array(x0, ndmin=2)
for x in x0check:
if not optimization_problem.check_bounds(x):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ install_requires =
pathos>=0.2.8
addict==2.3
cadet-python>=0.14
hopsy>=1.3.0
hopsy>=1.4.0
pymoo>=0.6
numba>=0.55.1
diskcache>=5.4.0
Expand Down

0 comments on commit 658221f

Please sign in to comment.