Skip to content

Commit

Permalink
Modeleur 2.1: Lib for modeling objects [ANT-1877] (#2383)
Browse files Browse the repository at this point in the history
Add basic classes and structures to represent a model library
  • Loading branch information
payetvin authored Sep 30, 2024
1 parent 63a14a8 commit fe29d37
Show file tree
Hide file tree
Showing 14 changed files with 536 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/solver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ add_subdirectory(utils)
add_subdirectory(variable)
add_subdirectory(modeler)
add_subdirectory(expressions)
add_subdirectory(libModelObject)

#
# Resource file for Windows
Expand Down
32 changes: 32 additions & 0 deletions src/solver/libModelObject/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_link_libraries(antares-solver-libObjectModel
PUBLIC
)
install(DIRECTORY include/antares
DESTINATION "include"
)
Original file line number Diff line number Diff line change
@@ -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 <https://opensource.org/license/mpl-2-0/>.
*/
#pragma once

#include <string>

#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
Original file line number Diff line number Diff line change
@@ -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 <https://opensource.org/license/mpl-2-0/>.
*/
#pragma once

#include <string>

namespace Antares::Solver::ObjectModel
{

class Expression
{
public:
Expression();
~Expression() = default;
};

} // namespace Antares::Solver::ObjectModel
Original file line number Diff line number Diff line change
@@ -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 <https://opensource.org/license/mpl-2-0/>.
*/
#pragma once

#include <map>

#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<std::string, PortType> portTypes_;
std::map<std::string, Model> models_;
};

} // namespace Antares::Solver::ObjectModel
Original file line number Diff line number Diff line change
@@ -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 <https://opensource.org/license/mpl-2-0/>.
*/
#pragma once

#include <map>
#include <vector>

#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<Constraint*> getConstraints();

private:
std::string id_;
Expression objective_;

std::map<std::string, Parameter> parameters_;
std::map<std::string, Variable> variables_;

std::map<std::string, Constraint> constraints_;
std::map<std::string, Constraint> bindingConstraints_;

std::map<std::string, Port> ports_;
};

} // namespace Antares::Solver::ObjectModel
Original file line number Diff line number Diff line change
@@ -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 <https://opensource.org/license/mpl-2-0/>.
*/
#pragma once

#include <string>

#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
Original file line number Diff line number Diff line change
@@ -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 <https://opensource.org/license/mpl-2-0/>.
*/
#pragma once

#include <string>

#include "portType.h"

namespace Antares::Solver::ObjectModel
{

class Port
{
public:
Port();
~Port() = default;

private:
std::string name_;
PortType type_;
};

} // namespace Antares::Solver::ObjectModel
Original file line number Diff line number Diff line change
@@ -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 <https://opensource.org/license/mpl-2-0/>.
*/
#pragma once

#include <string>

namespace Antares::Solver::ObjectModel
{

class PortField
{
private:
std::string name;
};

} // namespace Antares::Solver::ObjectModel
Original file line number Diff line number Diff line change
@@ -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 <https://opensource.org/license/mpl-2-0/>.
*/
#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
Loading

0 comments on commit fe29d37

Please sign in to comment.