-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from cvanaret/refactoring
Refactoring: split all the classes into hpp and cpp
- Loading branch information
Showing
51 changed files
with
1,569 additions
and
1,217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2018-2024 Charlie Vanaret | ||
// Licensed under the MIT license. See LICENSE file in the project directory for details. | ||
|
||
#include "HessianModelFactory.hpp" | ||
#include "HessianModel.hpp" | ||
#include "ConvexifiedHessian.hpp" | ||
#include "ExactHessian.hpp" | ||
#include "ZeroHessian.hpp" | ||
#include "solvers/DirectSymmetricIndefiniteLinearSolver.hpp" | ||
|
||
namespace uno { | ||
std::unique_ptr<HessianModel> HessianModelFactory::create(const std::string& hessian_model, size_t dimension, size_t maximum_number_nonzeros, | ||
bool convexify, const Options& options) { | ||
if (hessian_model == "exact") { | ||
if (convexify) { | ||
return std::make_unique<ConvexifiedHessian>(dimension, maximum_number_nonzeros + dimension, options); | ||
} | ||
else { | ||
return std::make_unique<ExactHessian>(dimension, maximum_number_nonzeros, options); | ||
} | ||
} | ||
else if (hessian_model == "zero") { | ||
return std::make_unique<ZeroHessian>(dimension, options); | ||
} | ||
throw std::invalid_argument("Hessian model " + hessian_model + " does not exist"); | ||
} | ||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2018-2024 Charlie Vanaret | ||
// Licensed under the MIT license. See LICENSE file in the project directory for details. | ||
|
||
#include "BoundRelaxedModel.hpp" | ||
#include "optimization/Iterate.hpp" | ||
#include "options/Options.hpp" | ||
|
||
namespace uno { | ||
BoundRelaxedModel::BoundRelaxedModel(std::unique_ptr<Model> original_model, const Options& options): | ||
Model(original_model->name + " -> bounds relaxed", original_model->number_variables, original_model->number_constraints, | ||
original_model->objective_sign), | ||
model(std::move(original_model)), | ||
relaxation_factor(options.get_double("tolerance")) { | ||
} | ||
|
||
double BoundRelaxedModel::variable_lower_bound(size_t variable_index) const { | ||
const double lower_bound = this->model->variable_lower_bound(variable_index); | ||
return lower_bound - this->relaxation_factor * std::max(1., std::abs(lower_bound)); | ||
} | ||
|
||
double BoundRelaxedModel::variable_upper_bound(size_t variable_index) const { | ||
const double upper_bound = this->model->variable_upper_bound(variable_index); | ||
return upper_bound + this->relaxation_factor * std::max(1., std::abs(upper_bound)); | ||
} | ||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.