-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mip objective file, getter for mipvariable
- Loading branch information
Showing
9 changed files
with
147 additions
and
22 deletions.
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
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
49 changes: 49 additions & 0 deletions
49
src/solver/optim/ortoolsImpl/include/antares/solver/optim/ortoolsImpl/mipObjective.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,49 @@ | ||
/* | ||
* 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 <ortools/linear_solver/linear_solver.h> | ||
|
||
#include <antares/solver/optim/api/mipObjective.h> | ||
#include <antares/solver/optim/api/mipVariable.h> | ||
|
||
namespace Antares::Solver::Optim::OrtoolsImpl | ||
{ | ||
|
||
class OrtoolsMipObjective final: public virtual Api::MipObjective | ||
{ | ||
public: | ||
OrtoolsMipObjective(operations_research::MPObjective* objective); | ||
~OrtoolsMipObjective() = default; | ||
|
||
void setCoefficient(Api::MipVariable* var, double coefficient) override; | ||
|
||
void setMaximization() override; | ||
void setMinimization() override; | ||
|
||
double getCoefficient(Api::MipVariable* var) override; | ||
|
||
bool getMaximization() override; | ||
bool getMinimization() override; | ||
|
||
operations_research::MPObjective* objective_; | ||
}; | ||
|
||
} // namespace Antares::Solver::Optim::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
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,64 @@ | ||
/* | ||
* 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/>. | ||
*/ | ||
|
||
#include <antares/solver/optim/ortoolsImpl/mipObjective.h> | ||
#include <antares/solver/optim/ortoolsImpl/mipVariable.h> | ||
|
||
namespace Antares::Solver::Optim::OrtoolsImpl | ||
{ | ||
|
||
OrtoolsMipObjective::OrtoolsMipObjective(operations_research::MPObjective* objective): | ||
objective_(objective) | ||
{} | ||
|
||
void OrtoolsMipObjective::setCoefficient(Api::MipVariable* var, double coefficient) | ||
{ | ||
auto* mpvar = dynamic_cast<OrtoolsMipVariable*>(var); | ||
objective_->SetCoefficient(mpvar->get(), coefficient); | ||
} | ||
|
||
void OrtoolsMipObjective::setMaximization() | ||
{ | ||
objective_->SetMaximization(); | ||
} | ||
|
||
void OrtoolsMipObjective::setMinimization() | ||
{ | ||
objective_->SetMinimization(); | ||
} | ||
|
||
double OrtoolsMipObjective::getCoefficient(Api::MipVariable* var) | ||
{ | ||
auto* mpvar = dynamic_cast<OrtoolsMipVariable*>(var); | ||
return objective_->GetCoefficient(mpvar->get()); | ||
} | ||
|
||
bool OrtoolsMipObjective::getMaximization() | ||
{ | ||
return objective_->maximization(); | ||
} | ||
|
||
bool OrtoolsMipObjective::getMinimization() | ||
{ | ||
return objective_->minimization(); | ||
} | ||
|
||
} // namespace Antares::Solver::Optim::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
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