diff --git a/src/solver/CMakeLists.txt b/src/solver/CMakeLists.txt index 37d0f4c003..28b51b11bd 100644 --- a/src/solver/CMakeLists.txt +++ b/src/solver/CMakeLists.txt @@ -21,6 +21,7 @@ add_subdirectory(utils) add_subdirectory(variable) add_subdirectory(modeler) add_subdirectory(expressions) +add_subdirectory(libModelObject) # # Resource file for Windows diff --git a/src/solver/libModelObject/CMakeLists.txt b/src/solver/libModelObject/CMakeLists.txt new file mode 100644 index 0000000000..ce2ae94d35 --- /dev/null +++ b/src/solver/libModelObject/CMakeLists.txt @@ -0,0 +1,32 @@ +project(LibObjectModel) + +set(SRC_model + model.cpp + + include/antares/solver/libObjectModel/library.h + include/antares/solver/libObjectModel/model.h + include/antares/solver/libObjectModel/parameter.h + include/antares/solver/libObjectModel/valueType.h + include/antares/solver/libObjectModel/variable.h + include/antares/solver/libObjectModel/constraint.h + include/antares/solver/libObjectModel/expression.h + include/antares/solver/libObjectModel/port.h + include/antares/solver/libObjectModel/portField.h + include/antares/solver/libObjectModel/portFieldDefinition.h + include/antares/solver/libObjectModel/portType.h +) + +source_group("libObjectModel" FILES ${SRC_model}) +add_library(antares-solver-libObjectModel + ${SRC_model}) + +target_include_directories(antares-solver-libObjectModel + PUBLIC + $ +) +target_link_libraries(antares-solver-libObjectModel + PUBLIC +) +install(DIRECTORY include/antares + DESTINATION "include" +) diff --git a/src/solver/libModelObject/include/antares/solver/libObjectModel/constraint.h b/src/solver/libModelObject/include/antares/solver/libObjectModel/constraint.h new file mode 100644 index 0000000000..fbf28a3a89 --- /dev/null +++ b/src/solver/libModelObject/include/antares/solver/libObjectModel/constraint.h @@ -0,0 +1,43 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ +#pragma once + +#include + +#include "expression.h" +#include "parameter.h" + +namespace Antares::Solver::ObjectModel +{ + +/// A constraint linking variables and parameters of a model together +class Constraint +{ +public: + Constraint(); + ~Constraint() = default; + +private: + std::string name_; + Expression expression_; +}; + +} // namespace Antares::Solver::ObjectModel diff --git a/src/solver/libModelObject/include/antares/solver/libObjectModel/expression.h b/src/solver/libModelObject/include/antares/solver/libObjectModel/expression.h new file mode 100644 index 0000000000..c83165ee09 --- /dev/null +++ b/src/solver/libModelObject/include/antares/solver/libObjectModel/expression.h @@ -0,0 +1,35 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ +#pragma once + +#include + +namespace Antares::Solver::ObjectModel +{ + +class Expression +{ +public: + Expression(); + ~Expression() = default; +}; + +} // namespace Antares::Solver::ObjectModel diff --git a/src/solver/libModelObject/include/antares/solver/libObjectModel/library.h b/src/solver/libModelObject/include/antares/solver/libObjectModel/library.h new file mode 100644 index 0000000000..9752aeb0f0 --- /dev/null +++ b/src/solver/libModelObject/include/antares/solver/libObjectModel/library.h @@ -0,0 +1,46 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ +#pragma once + +#include + +#include "model.h" +#include "portType.h" + +namespace Antares::Solver::ObjectModel +{ + +/// A library is a collection of models +class Library +{ +public: + Library(); + ~Library() = default; + +private: + std::string id_; + std::string description_; + + std::map portTypes_; + std::map models_; +}; + +} // namespace Antares::Solver::ObjectModel diff --git a/src/solver/libModelObject/include/antares/solver/libObjectModel/model.h b/src/solver/libModelObject/include/antares/solver/libObjectModel/model.h new file mode 100644 index 0000000000..0cdeb0bb92 --- /dev/null +++ b/src/solver/libModelObject/include/antares/solver/libObjectModel/model.h @@ -0,0 +1,60 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ +#pragma once + +#include +#include + +#include "constraint.h" +#include "expression.h" +#include "parameter.h" +#include "port.h" +#include "variable.h" + +namespace Antares::Solver::ObjectModel +{ + +/** + * Defines a model that can be referenced by actual components. + * A model defines the behaviour of those components. + */ +class Model +{ +public: + Model(); + ~Model() = default; + + std::vector getConstraints(); + +private: + std::string id_; + Expression objective_; + + std::map parameters_; + std::map variables_; + + std::map constraints_; + std::map bindingConstraints_; + + std::map ports_; +}; + +} // namespace Antares::Solver::ObjectModel diff --git a/src/solver/libModelObject/include/antares/solver/libObjectModel/parameter.h b/src/solver/libModelObject/include/antares/solver/libObjectModel/parameter.h new file mode 100644 index 0000000000..55be8984e0 --- /dev/null +++ b/src/solver/libModelObject/include/antares/solver/libObjectModel/parameter.h @@ -0,0 +1,48 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ +#pragma once + +#include + +#include "valueType.h" + +namespace Antares::Solver::ObjectModel +{ + +/** + * A parameter of the model: a parameter is mainly defined by a name and expected type. + * When the model is instantiated as a component, a value must be provided for + * parameters, either as constant values or timeseries-based values. + */ +class Parameter +{ +public: + Parameter(); + ~Parameter() = default; + +private: + std::string name_; + ValueType type_; + bool timeDependent_ = true; // optional at construction + bool scenarioDependent_ = true; // optional at construction +}; + +} // namespace Antares::Solver::ObjectModel diff --git a/src/solver/libModelObject/include/antares/solver/libObjectModel/port.h b/src/solver/libModelObject/include/antares/solver/libObjectModel/port.h new file mode 100644 index 0000000000..ddf89277cd --- /dev/null +++ b/src/solver/libModelObject/include/antares/solver/libObjectModel/port.h @@ -0,0 +1,41 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ +#pragma once + +#include + +#include "portType.h" + +namespace Antares::Solver::ObjectModel +{ + +class Port +{ +public: + Port(); + ~Port() = default; + +private: + std::string name_; + PortType type_; +}; + +} // namespace Antares::Solver::ObjectModel diff --git a/src/solver/libModelObject/include/antares/solver/libObjectModel/portField.h b/src/solver/libModelObject/include/antares/solver/libObjectModel/portField.h new file mode 100644 index 0000000000..4484f62230 --- /dev/null +++ b/src/solver/libModelObject/include/antares/solver/libObjectModel/portField.h @@ -0,0 +1,34 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ +#pragma once + +#include + +namespace Antares::Solver::ObjectModel +{ + +class PortField +{ +private: + std::string name; +}; + +} // namespace Antares::Solver::ObjectModel diff --git a/src/solver/libModelObject/include/antares/solver/libObjectModel/portFieldDefinition.h b/src/solver/libModelObject/include/antares/solver/libObjectModel/portFieldDefinition.h new file mode 100644 index 0000000000..9e22622d89 --- /dev/null +++ b/src/solver/libModelObject/include/antares/solver/libObjectModel/portFieldDefinition.h @@ -0,0 +1,40 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ +#pragma once + +#include "port.h" +#include "portType.h" + +namespace Antares::Solver::ObjectModel +{ + +class PortFieldDefinition +{ + PortFieldDefinition(); + ~PortFieldDefinition() = default; + +private: + Port port_; + PortField field_; + Expression definition_; +}; + +} // namespace Antares::Solver::ObjectModel diff --git a/src/solver/libModelObject/include/antares/solver/libObjectModel/portType.h b/src/solver/libModelObject/include/antares/solver/libObjectModel/portType.h new file mode 100644 index 0000000000..662cbb7041 --- /dev/null +++ b/src/solver/libModelObject/include/antares/solver/libObjectModel/portType.h @@ -0,0 +1,44 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ +#pragma once + +#include +#include + +#include "portField.h" + +namespace Antares::Solver::ObjectModel +{ + +class PortType +{ +public: + PortType(); + ~PortType() = default; + +private: + std::string id_; + std::string description_; + + std::vector fields_; +}; + +} // namespace Antares::Solver::ObjectModel diff --git a/src/solver/libModelObject/include/antares/solver/libObjectModel/valueType.h b/src/solver/libModelObject/include/antares/solver/libObjectModel/valueType.h new file mode 100644 index 0000000000..feeac17b1e --- /dev/null +++ b/src/solver/libModelObject/include/antares/solver/libObjectModel/valueType.h @@ -0,0 +1,34 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ +#pragma once + +namespace Antares::Solver::ObjectModel +{ + +/// Type of value held by variables or parameters +enum class ValueType +{ + FLOAT, + INTEGER, + BOOL +}; + +} // namespace Antares::Solver::ObjectModel diff --git a/src/solver/libModelObject/include/antares/solver/libObjectModel/variable.h b/src/solver/libModelObject/include/antares/solver/libObjectModel/variable.h new file mode 100644 index 0000000000..51665508ed --- /dev/null +++ b/src/solver/libModelObject/include/antares/solver/libObjectModel/variable.h @@ -0,0 +1,46 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ +#pragma once + +#include + +#include "expression.h" +#include "parameter.h" +#include "valueType.h" + +namespace Antares::Solver::ObjectModel +{ + +/// A decision variable of the model +class Variable +{ +public: + Variable(); + ~Variable() = default; + +private: + std::string name_; + ValueType type_; + Expression lowerBound_; + Expression upperBound_; +}; + +} // namespace Antares::Solver::ObjectModel diff --git a/src/solver/libModelObject/model.cpp b/src/solver/libModelObject/model.cpp new file mode 100644 index 0000000000..19378317f8 --- /dev/null +++ b/src/solver/libModelObject/model.cpp @@ -0,0 +1,32 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ + +#include + +namespace Antares::Solver::ObjectModel +{ + +std::vector getConstraints() +{ + return std::vector(); +} + +} // namespace Antares::Solver::ObjectModel