diff --git a/src/solver/systemParser/converter.cpp b/src/solver/systemParser/converter.cpp index e044c10689..af64207ce3 100644 --- a/src/solver/systemParser/converter.cpp +++ b/src/solver/systemParser/converter.cpp @@ -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(model_builder.withId(modelId).build()); SystemModel::ComponentBuilder component_builder; /* std::map parameters; */ @@ -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(); diff --git a/src/tests/src/solver/modelParser/testSystemParser.cpp b/src/tests/src/solver/modelParser/testSystemParser.cpp index 7c28d952b1..1cf6866462 100644 --- a/src/tests/src/solver/modelParser/testSystemParser.cpp +++ b/src/tests/src/solver/modelParser/testSystemParser.cpp @@ -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); */