Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.5b build linear problem from components #2558

Merged
merged 9 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/solver/modeler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ target_link_libraries(modeler-lib
INTERFACE
Antares::loadModelerFiles
Antares::modelerParameters
Antares::optim-model-filler
Antares::modeler_api
# TODO FIXME don't depend on implementations
Antares::modeler-ortools-impl
)

target_link_libraries(antares-modeler
Expand Down
24 changes: 24 additions & 0 deletions src/solver/modeler/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
*/

#include <antares/logs/logs.h>
#include <antares/solver/modeler/api/linearProblemBuilder.h>
#include <antares/solver/modeler/loadFiles/loadFiles.h>
#include <antares/solver/modeler/ortoolsImpl/linearProblem.h>
#include <antares/solver/modeler/parameters/parseModelerParameters.h>
#include <antares/solver/optim-model-filler/ComponentFiller.h>

using namespace Antares;
using namespace Antares::Solver;
Expand Down Expand Up @@ -51,6 +54,27 @@ int main(int argc, const char** argv)
logs.info() << "Libraries loaded";
const auto system = LoadFiles::loadSystem(studyPath, libraries);
logs.info() << "System loaded";

// Fillers, etc.
std::vector<Antares::Solver::Modeler::Api::LinearProblemFiller*> fillers;
// TODO memory
for (auto& [_, component]: system.Components())
{
fillers.push_back(new Antares::Optimization::ComponentFiller(component));
}

Antares::Solver::Modeler::Api::LinearProblemData LP_Data;
Antares::Solver::Modeler::Api::FillContext ctx = {0, 0};
Antares::Solver::Modeler::OrtoolsImpl::OrtoolsLinearProblem pb(false, parameters.solver);
flomnes marked this conversation as resolved.
Show resolved Hide resolved
Antares::Solver::Modeler::Api::LinearProblemBuilder linear_problem_builder(fillers);
linear_problem_builder.build(pb, LP_Data, ctx);
for (auto& filler: fillers)
{
delete filler;
}

logs.info() << "Number of variables: " << pb.variableCount();
logs.info() << "Number of constraints: " << pb.constraintCount();
}
catch (const LoadFiles::ErrorLoadingYaml&)
{
Expand Down
Loading