Skip to content

Commit

Permalink
Removed unused members and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cvanaret committed Dec 14, 2024
1 parent 3809304 commit 93dd7c7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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<double>& 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;
Expand All @@ -95,4 +64,4 @@ namespace uno {

void InequalityConstrainedMethod::postprocess_iterate(const OptimizationProblem& /*problem*/, Iterate& /*iterate*/) {
}
} // namespace
} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,17 +30,7 @@ namespace uno {

protected:
Vector<double> initial_point{};
std::vector<double> direction_lower_bounds{};
std::vector<double> direction_upper_bounds{};
std::vector<double> linearized_constraints_lower_bounds{};
std::vector<double> linearized_constraints_upper_bounds{};

SparseVector<double> objective_gradient; /*!< Sparse Jacobian of the objective */
std::vector<double> constraints; /*!< Constraint values (size \f$m)\f$ */
RectangularMatrix<double> 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<double>& current_constraints);
static void compute_dual_displacements(const Multipliers& current_multipliers, Multipliers& direction_multipliers);
};
} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 93dd7c7

Please sign in to comment.