diff --git a/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/InequalityConstrainedMethod.cpp b/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/InequalityConstrainedMethod.cpp index a5d1c06c..13c09647 100644 --- a/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/InequalityConstrainedMethod.cpp +++ b/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/InequalityConstrainedMethod.cpp @@ -10,17 +10,10 @@ #include "symbolic/VectorView.hpp" namespace uno { - InequalityConstrainedMethod::InequalityConstrainedMethod(const std::string& hessian_model, size_t number_variables, size_t number_constraints, + InequalityConstrainedMethod::InequalityConstrainedMethod(const std::string& hessian_model, size_t number_variables, size_t number_hessian_nonzeros, bool convexify, const Options& options): InequalityHandlingMethod(hessian_model, number_variables, number_hessian_nonzeros, convexify, options), - initial_point(number_variables), - direction_lower_bounds(number_variables), - direction_upper_bounds(number_variables), - linearized_constraints_lower_bounds(number_constraints), - linearized_constraints_upper_bounds(number_constraints), - objective_gradient(number_variables), - constraints(number_constraints), - constraint_jacobian(number_constraints, number_variables) { + initial_point(number_variables) { } void InequalityConstrainedMethod::initialize_statistics(Statistics& statistics, const Options& options) { @@ -52,30 +45,6 @@ namespace uno { // do nothing } - void InequalityConstrainedMethod::set_direction_bounds(const OptimizationProblem& problem, const Iterate& current_iterate) { - // bounds of original variables intersected with trust region - for (size_t variable_index: Range(problem.get_number_original_variables())) { - this->direction_lower_bounds[variable_index] = std::max(-this->trust_region_radius, - problem.variable_lower_bound(variable_index) - current_iterate.primals[variable_index]); - this->direction_upper_bounds[variable_index] = std::min(this->trust_region_radius, - problem.variable_upper_bound(variable_index) - current_iterate.primals[variable_index]); - } - // bounds of additional variables (no trust region!) - for (size_t variable_index: Range(problem.get_number_original_variables(), problem.number_variables)) { - this->direction_lower_bounds[variable_index] = problem.variable_lower_bound(variable_index) - current_iterate.primals[variable_index]; - this->direction_upper_bounds[variable_index] = problem.variable_upper_bound(variable_index) - current_iterate.primals[variable_index]; - } - } - - void InequalityConstrainedMethod::set_linearized_constraint_bounds(const OptimizationProblem& problem, const std::vector& current_constraints) { - for (size_t constraint_index: Range(problem.number_constraints)) { - this->linearized_constraints_lower_bounds[constraint_index] = problem.constraint_lower_bound(constraint_index) - - current_constraints[constraint_index]; - this->linearized_constraints_upper_bounds[constraint_index] = problem.constraint_upper_bound(constraint_index) - - current_constraints[constraint_index]; - } - } - void InequalityConstrainedMethod::compute_dual_displacements(const Multipliers& current_multipliers, Multipliers& direction_multipliers) { // compute dual *displacements* (active-set methods usually compute the new duals, not the displacements) view(direction_multipliers.constraints, 0, current_multipliers.constraints.size()) -= current_multipliers.constraints; @@ -95,4 +64,4 @@ namespace uno { void InequalityConstrainedMethod::postprocess_iterate(const OptimizationProblem& /*problem*/, Iterate& /*iterate*/) { } -} // namespace +} // namespace \ No newline at end of file diff --git a/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/InequalityConstrainedMethod.hpp b/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/InequalityConstrainedMethod.hpp index 7549d8b5..872c73ef 100644 --- a/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/InequalityConstrainedMethod.hpp +++ b/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/InequalityConstrainedMethod.hpp @@ -12,8 +12,8 @@ namespace uno { class InequalityConstrainedMethod : public InequalityHandlingMethod { public: - InequalityConstrainedMethod(const std::string& hessian_model, size_t number_variables, size_t number_constraints, - size_t number_hessian_nonzeros, bool convexify, const Options& options); + InequalityConstrainedMethod(const std::string& hessian_model, size_t number_variables, size_t number_hessian_nonzeros, bool convexify, + const Options& options); ~InequalityConstrainedMethod() override = default; void initialize_statistics(Statistics& statistics, const Options& options) override; @@ -30,17 +30,7 @@ namespace uno { protected: Vector initial_point{}; - std::vector direction_lower_bounds{}; - std::vector direction_upper_bounds{}; - std::vector linearized_constraints_lower_bounds{}; - std::vector linearized_constraints_upper_bounds{}; - SparseVector objective_gradient; /*!< Sparse Jacobian of the objective */ - std::vector constraints; /*!< Constraint values (size \f$m)\f$ */ - RectangularMatrix constraint_jacobian; /*!< Sparse Jacobian of the constraints */ - - void set_direction_bounds(const OptimizationProblem& problem, const Iterate& current_iterate); - void set_linearized_constraint_bounds(const OptimizationProblem& problem, const std::vector& current_constraints); static void compute_dual_displacements(const Multipliers& current_multipliers, Multipliers& direction_multipliers); }; } // namespace diff --git a/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/LPMethod.cpp b/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/LPMethod.cpp index 6e2b2a6c..4743053b 100644 --- a/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/LPMethod.cpp +++ b/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/LPMethod.cpp @@ -13,9 +13,8 @@ namespace uno { LPMethod::LPMethod(size_t number_variables, size_t number_constraints, size_t number_objective_gradient_nonzeros, size_t number_jacobian_nonzeros, const Options& options) : - InequalityConstrainedMethod("zero", number_variables, number_constraints, 0, false, options), - solver(LPSolverFactory::create(number_variables, number_constraints, - number_objective_gradient_nonzeros, number_jacobian_nonzeros, options)) { + InequalityConstrainedMethod("zero", number_variables, 0, false, options), + solver(LPSolverFactory::create(number_variables, number_constraints, number_objective_gradient_nonzeros, number_jacobian_nonzeros, options)) { } LPMethod::~LPMethod() { } diff --git a/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/QPMethod.cpp b/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/QPMethod.cpp index 0ec934dd..bd8d8b15 100644 --- a/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/QPMethod.cpp +++ b/uno/ingredients/inequality_handling_methods/inequality_constrained_methods/QPMethod.cpp @@ -17,7 +17,7 @@ namespace uno { QPMethod::QPMethod(size_t number_variables, size_t number_constraints, size_t number_objective_gradient_nonzeros, size_t number_jacobian_nonzeros, size_t number_hessian_nonzeros, const Options& options) : - InequalityConstrainedMethod(options.get_string("hessian_model"), number_variables, number_constraints, number_hessian_nonzeros, + InequalityConstrainedMethod(options.get_string("hessian_model"), number_variables, number_hessian_nonzeros, options.get_string("globalization_mechanism") != "TR" || options.get_bool("convexify_QP"), options), enforce_linear_constraints_at_initial_iterate(options.get_bool("enforce_linear_constraints")), // maximum number of Hessian nonzeros = number nonzeros + possible diagonal inertia correction