|
| 1 | +from __future__ import annotations |
| 2 | + |
1 | 3 | import subprocess |
2 | 4 | import shutil |
3 | 5 | import yaml |
4 | 6 |
|
| 7 | +import opengen as og |
5 | 8 | import opengen.config as og_cfg |
6 | 9 | import opengen.definitions as og_dfn |
7 | 10 | import opengen.constraints as og_cstr |
@@ -43,10 +46,10 @@ class OpEnOptimizerBuilder: |
43 | 46 | """ |
44 | 47 |
|
45 | 48 | def __init__(self, |
46 | | - problem, |
47 | | - metadata=og_cfg.OptimizerMeta(), |
48 | | - build_configuration=og_cfg.BuildConfiguration(), |
49 | | - solver_configuration=og_cfg.SolverConfiguration()): |
| 49 | + problem: og.builder.Problem, |
| 50 | + metadata: og_cfg.OptimizerMeta =og_cfg.OptimizerMeta(), |
| 51 | + build_configuration: og_cfg.BuildConfiguration =og_cfg.BuildConfiguration(), |
| 52 | + solver_configuration: og_cfg.SolverConfiguration=og_cfg.SolverConfiguration()): |
50 | 53 | """Constructor of OpEnOptimizerBuilder |
51 | 54 |
|
52 | 55 | :param problem: instance of :class:`~opengen.builder.problem.Problem` |
@@ -645,6 +648,15 @@ def __initialize(self): |
645 | 648 |
|
646 | 649 | def __check_user_provided_parameters(self): |
647 | 650 | self.__logger.info("Checking user parameters") |
| 651 | + |
| 652 | + # Check constraints dimensions |
| 653 | + dim_constraints = self.__problem.constraints.dimension() |
| 654 | + dim_decision_variables = self.__problem.dim_decision_variables() |
| 655 | + if dim_constraints is not None and dim_decision_variables != dim_constraints: |
| 656 | + raise ValueError(f"Inconsistent dimensions - decision variables: {dim_decision_variables}", |
| 657 | + f"set of constraints: {dim_constraints}") |
| 658 | + |
| 659 | + # Preconditioning... |
648 | 660 | if self.__solver_config.preconditioning: |
649 | 661 | # Preconditioning is not allowed when we have general ALM-type constraints of the form |
650 | 662 | # F1(u, p) in C, unless C is {0} or an orthant (special case of rectangle). |
|
0 commit comments