Skip to content

Commit

Permalink
shared ptr for model
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Dec 13, 2024
1 parent f70e7b6 commit 157c83a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/solver/systemParser/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static SystemModel::Component createComponent(const SystemParser::Component& c)
{
const auto [libraryId, modelId] = splitLibraryModelString(c.model);
SystemModel::ModelBuilder model_builder;
auto model = model_builder.withId(modelId).build();
auto model = std::make_shared<SystemModel::Model>(model_builder.withId(modelId).build());
SystemModel::ComponentBuilder component_builder;

/* std::map<std::string, double> parameters; */
Expand All @@ -57,7 +57,7 @@ static SystemModel::Component createComponent(const SystemParser::Component& c)
/* } */

auto component = component_builder.withId(c.id)
.withModel(&model)
.withModel(model.get())
.withScenarioGroupId(c.scenarioGroup)
/* .withParameterValues(parameters) */
.build();
Expand Down
1 change: 1 addition & 0 deletions src/tests/src/solver/modelParser/testSystemParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ BOOST_AUTO_TEST_CASE(parse_into_system_model)
BOOST_CHECK_EQUAL(systemModel.Components().size(), 2);
BOOST_CHECK_EQUAL(systemModel.Components().at("N").Id(), "N");
BOOST_CHECK_EQUAL(systemModel.Components().at("G").Id(), "G");
BOOST_CHECK_EQUAL(systemModel.Components().at("G").getModel()->Id(), "generator");

/* BOOST_CHECK_EQUAL(systemModel.Components().at("N").getParameterValue("cost"), 30); */
/* BOOST_CHECK_EQUAL(systemModel.Components().at("N").getParameterValue("generator"), 100); */
Expand Down

0 comments on commit 157c83a

Please sign in to comment.