-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,462 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_subdirectory(api) | ||
add_subdirectory(ortoolsImpl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
set(PROJ optim_api) | ||
|
||
set(SRC_API | ||
include/antares/solver/modeler/api/mipVariable.h | ||
include/antares/solver/modeler/api/mipSolution.h | ||
include/antares/solver/modeler/api/mipConstraint.h | ||
|
||
include/antares/solver/modeler/api/hasBounds.h | ||
include/antares/solver/modeler/api/hasName.h | ||
|
||
include/antares/solver/modeler/api/linearProblem.h | ||
include/antares/solver/modeler/api/linearProblemData.h | ||
include/antares/solver/modeler/api/linearProblemFiller.h | ||
include/antares/solver/modeler/api/linearProblemBuilder.h | ||
|
||
linearProblemData.cpp | ||
) | ||
|
||
add_library(${PROJ} ${SRC_API}) | ||
add_library(Antares::${PROJ} ALIAS ${PROJ}) | ||
|
||
set_target_properties(${PROJ} PROPERTIES LINKER_LANGUAGE CXX) | ||
|
||
target_include_directories(${PROJ} | ||
PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
) |
42 changes: 42 additions & 0 deletions
42
src/solver/modeler/api/include/antares/solver/modeler/api/hasBounds.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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 | ||
|
||
namespace Antares::Solver::Modeler::Api | ||
{ | ||
|
||
/// Used to handle bounds for IMipVariable and IMipConstraint | ||
class IHasBounds | ||
{ | ||
public: | ||
virtual ~IHasBounds() = default; | ||
|
||
virtual void setLb(double lb) = 0; | ||
virtual void setUb(double ub) = 0; | ||
|
||
virtual void setBounds(double lb, double ub) = 0; | ||
|
||
virtual double getLb() const = 0; | ||
virtual double getUb() const = 0; | ||
}; | ||
|
||
} // namespace Antares::Solver::Modeler::Api |
37 changes: 37 additions & 0 deletions
37
src/solver/modeler/api/include/antares/solver/modeler/api/hasName.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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::Modeler::Api | ||
{ | ||
|
||
/// Inherited by IMipVariable and IMipConstraint | ||
class IHasName | ||
{ | ||
public: | ||
virtual ~IHasName() = default; | ||
virtual const std::string& getName() const = 0; | ||
}; | ||
|
||
} // namespace Antares::Solver::Modeler::Api |
71 changes: 71 additions & 0 deletions
71
src/solver/modeler/api/include/antares/solver/modeler/api/linearProblem.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* 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 <string> | ||
|
||
#include "mipConstraint.h" | ||
#include "mipSolution.h" | ||
#include "mipVariable.h" | ||
|
||
/// Namespace for the classes related to the linear problem API | ||
namespace Antares::Solver::Modeler::Api | ||
{ | ||
|
||
/** | ||
* Linear Problem | ||
* This class is aimed at creating and manipulating variables/constraints | ||
* Also used to to control the objective, maximization or minimization, and to solve the problem | ||
*/ | ||
class ILinearProblem | ||
{ | ||
public: | ||
virtual ~ILinearProblem() = default; | ||
|
||
/// Create a continuous variable | ||
virtual IMipVariable* addNumVariable(double lb, double ub, const std::string& name) = 0; | ||
/// Create a integer variable | ||
virtual IMipVariable* addIntVariable(double lb, double ub, const std::string& name) = 0; | ||
virtual IMipVariable* getVariable(const std::string& name) const = 0; | ||
|
||
/// Add a bounded constraint to the problem | ||
virtual IMipConstraint* addConstraint(double lb, double ub, const std::string& name) = 0; | ||
virtual IMipConstraint* getConstraint(const std::string& name) const = 0; | ||
|
||
/// Set the objective coefficient for a given variable | ||
virtual void setObjectiveCoefficient(IMipVariable* var, double coefficient) = 0; | ||
virtual double getObjectiveCoefficient(const IMipVariable* var) const = 0; | ||
|
||
/// Sets the optimization direction to minimize | ||
virtual void setMinimization() = 0; | ||
/// Sets the optimization direction to maximize | ||
virtual void setMaximization() = 0; | ||
|
||
virtual bool isMinimization() const = 0; | ||
virtual bool isMaximization() const = 0; | ||
|
||
/// Solve the problem, returns a IMipSolution | ||
virtual IMipSolution* solve(bool verboseSolver) = 0; | ||
}; | ||
|
||
} // namespace Antares::Solver::Modeler::Api |
40 changes: 40 additions & 0 deletions
40
src/solver/modeler/api/include/antares/solver/modeler/api/linearProblemBuilder.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <vector> | ||
|
||
#include "linearProblemFiller.h" | ||
#include "mipSolution.h" | ||
|
||
namespace Antares::Solver::Modeler::Api | ||
{ | ||
|
||
class LinearProblemBuilder | ||
{ | ||
public: | ||
virtual void LinearProblemBuilder(std::vector<LinearProblemFiller*> fillers) = 0; | ||
virtual void build(LinearProblemData* data) = 0; | ||
virtual MipSolution* solve() = 0; | ||
}; | ||
|
||
} // namespace Antares::Solver::Modeler::Api |
47 changes: 47 additions & 0 deletions
47
src/solver/modeler/api/include/antares/solver/modeler/api/linearProblemData.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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 <string> | ||
#include <vector> | ||
|
||
namespace Antares::Solver::Modeler::Api | ||
{ | ||
|
||
class LinearProblemData | ||
{ | ||
public: | ||
unsigned getTimeResolutionInMinutes(); | ||
bool hasScalarData(const std::string& key); | ||
double getScalarData(const std::string& key, unsigned scenario); | ||
bool hasTimedData(const std::string& key); | ||
const std::vector<double>& getTimedData(const std::string& key, unsigned scenario); | ||
|
||
private: | ||
std::vector<int> timeStamps_; | ||
unsigned timeResolutionInMinutes_; | ||
std::map<std::string, std::vector<double>> scalarData_; | ||
std::map<std::string, std::vector<std::vector<double>>> timedData_; | ||
}; | ||
|
||
} // namespace Antares::Solver::Modeler::Api |
38 changes: 38 additions & 0 deletions
38
src/solver/modeler/api/include/antares/solver/modeler/api/linearProblemFiller.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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 <antares/solver/modeler/api/linearProblem.h> | ||
#include <antares/solver/modeler/api/linearProblemData.h> | ||
|
||
namespace Antares::Solver::Modeler::Api | ||
{ | ||
|
||
class LinearProblemFiller | ||
{ | ||
public: | ||
virtual void addVariables(LinearProblem* problem, LinearProblemData* data) = 0; | ||
virtual void addConstraints(LinearProblem* problem, LinearProblemData* data) = 0; | ||
virtual void addObjectiveCoefficients(LinearProblem* problem, LinearProblemData* data) = 0; | ||
}; | ||
|
||
} // namespace Antares::Solver::Modeler::Api |
37 changes: 37 additions & 0 deletions
37
src/solver/modeler/api/include/antares/solver/modeler/api/mipConstraint.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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 "mipVariable.h" | ||
|
||
namespace Antares::Solver::Modeler::Api | ||
{ | ||
|
||
class IMipConstraint: public IHasBounds, public IHasName | ||
{ | ||
public: | ||
virtual void setCoefficient(IMipVariable* var, double coefficient) = 0; | ||
|
||
virtual double getCoefficient(IMipVariable* var) = 0; | ||
}; | ||
|
||
} // namespace Antares::Solver::Modeler::Api |
Oops, something went wrong.