Antares Simulator
Power System Simulator
linearProblem.h
1 /*
2  * Copyright 2007-2025, RTE (https://www.rte-france.com)
3  * See AUTHORS.txt
4  * SPDX-License-Identifier: MPL-2.0
5  * This file is part of Antares-Simulator,
6  * Adequacy and Performance assessment for interconnected energy networks.
7  *
8  * Antares_Simulator is free software: you can redistribute it and/or modify
9  * it under the terms of the Mozilla Public Licence 2.0 as published by
10  * the Mozilla Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Antares_Simulator is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * Mozilla Public Licence 2.0 for more details.
17  *
18  * You should have received a copy of the Mozilla Public Licence 2.0
19  * along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20  */
21 
22 #pragma once
23 
24 #include <memory>
25 #include <string>
26 
27 #include "mipConstraint.h"
28 #include "mipSolution.h"
29 #include "mipVariable.h"
30 
33 {
34 
41 {
42 public:
43  virtual ~ILinearProblem() = default;
44 
46  virtual IMipVariable* addNumVariable(double lb, double ub, const std::string& name) = 0;
47 
49  virtual IMipVariable* addIntVariable(double lb, double ub, const std::string& name) = 0;
50 
52  virtual IMipVariable* addVariable(double lb, double ub, bool integer, const std::string& name)
53  = 0;
54 
55  // Variables observers
56  [[nodiscard]] virtual const std::vector<std::unique_ptr<IMipVariable>>& getVariables() const
57  = 0;
58  [[nodiscard]] virtual IMipVariable* getVariable(std::size_t index) const = 0;
59  [[nodiscard]] virtual IMipVariable* lookupVariable(const std::string& name) const = 0;
60  [[nodiscard]] virtual int variableCount() const = 0;
61 
63  virtual IMipConstraint* addConstraint(double lb, double ub, const std::string& name) = 0;
64 
65  // Constraints observers
66  [[nodiscard]] virtual const std::vector<std::unique_ptr<IMipConstraint>>& getConstraints() const
67  = 0;
68  [[nodiscard]] virtual IMipConstraint* getConstraint(std::size_t index) const = 0;
69  [[nodiscard]] virtual LinearProblemApi::IMipConstraint* lookupConstraint(
70  const std::string& name) const
71  = 0;
72  [[nodiscard]] virtual int constraintCount() const = 0;
73 
75  virtual void setObjectiveCoefficient(IMipVariable* var, double coefficient) = 0;
76  virtual double getObjectiveCoefficient(const IMipVariable* var) const = 0;
77 
78  virtual void setObjectiveOffset(double objectiveOffset) = 0;
79  virtual double getObjectiveOffset() const = 0;
80 
82  virtual void setMinimization() = 0;
84  virtual void setMaximization() = 0;
85 
86  [[nodiscard]] virtual bool isMinimization() const = 0;
87  [[nodiscard]] virtual bool isMaximization() const = 0;
88 
90  virtual IMipSolution* solve(bool verboseSolver) = 0;
91 
92  // Definition of infinity
93  [[nodiscard]] virtual double infinity() const = 0;
94  virtual bool isLP() const = 0;
95 
96  virtual double objectiveValue() const = 0;
97 };
98 
99 } // namespace Antares::Optimisation::LinearProblemApi
virtual void setObjectiveCoefficient(IMipVariable *var, double coefficient)=0
Set the objective coefficient for a given variable.
virtual void setMaximization()=0
Sets the optimization direction to maximize.
virtual void setMinimization()=0
Sets the optimization direction to minimize.
virtual IMipVariable * addIntVariable(double lb, double ub, const std::string &name)=0
Create a integer variable.
virtual IMipVariable * addNumVariable(double lb, double ub, const std::string &name)=0
Create a continuous variable.
virtual IMipConstraint * addConstraint(double lb, double ub, const std::string &name)=0
Add a bounded constraint to the problem.
virtual IMipVariable * addVariable(double lb, double ub, bool integer, const std::string &name)=0
Create a continuous or integer variable.
virtual IMipSolution * solve(bool verboseSolver)=0
Solve the problem, returns a IMipSolution.
Namespace for the classes related to the linear problem API.
Definition: SimulationTableGenerator.h:41