-
Notifications
You must be signed in to change notification settings - Fork 29
[ANT-4033] Feat: Support setObjectiveOffset #3207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
# Conflicts: # src/solver/optim-model-filler/ComponentFiller.cpp # src/tests/inmemory-modeler/inmemory-modeler.cpp
src/tests/src/solver/optim-model-filler/test_componentFiller.cpp
Outdated
Show resolved
Hide resolved
src/tests/src/solver/optim-model-filler/test_componentFiller.cpp
Outdated
Show resolved
Hide resolved
src/tests/src/solver/optim-model-filler/test_componentFiller.cpp
Outdated
Show resolved
Hide resolved
src/tests/src/solver/optim-model-filler/test_componentFiller.cpp
Outdated
Show resolved
Hide resolved
src/tests/src/solver/optim-model-filler/test_componentFiller.cpp
Outdated
Show resolved
Hide resolved
# Conflicts: # src/optimisation/linear-problem-mpsolver-impl/include/antares/optimisation/linear-problem-mpsolver-impl/linearProblem.h # src/optimisation/linear-problem-mpsolver-impl/linearProblem.cpp # src/solver/optim-model-filler/ReadLinearExpressionVisitor.cpp
This reverts commit cd56ace
std::type_index has no constexpr constructor and can not be returned by constexpr function
This reverts commit 2e4f083
This reverts commit 55b03dc.
...blem-mpsolver-impl/include/antares/optimisation/linear-problem-mpsolver-impl/linearProblem.h
Outdated
Show resolved
Hide resolved
Co-authored-by: Florian Omnès <[email protected]>
| for (const auto& objective: model->Objectives() | locationFilter()) | ||
| { | ||
| const auto root_node = objective.expression().RootNode(); | ||
| const auto linearExpression = visitor.visitMergeDuplicates(root_node); | ||
|
|
||
| const auto variability = getVariability(root_node, component_); | ||
| if (isTimeDependent(variability)) | ||
| { | ||
| throw Error::RuntimeError("Time dependent objectives are not supported in Antares."); | ||
| } | ||
| addStaticObjective(linearExpression); | ||
| objectiveOffset += linearExpression.constant()[0]; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only time independent expressions are accepted in objectives.
To make it even more clear in the code, we could have, inside the loop over objectives :
const auto root_node = objective.expression().RootNode();
const auto variability = getVariability(root_node, component_);
if (isTimeDependent(variability))
{
throw Error::RuntimeError("Time dependent objectives are not supported in Antares.");
}
const auto linearExpression = visitor.visitMergeDuplicates(root_node)[0];
addStaticObjective(linearExpression);
objectiveOffset += linearExpression.constant();Note that, in code above :
- linearExpression is now of type LinearExpression (and no longer of type TimeDependentLinearExpression), so it has 1 dimension (not multiple dimensions).
- addStaticObjective(...) takes a LinearExpression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed better : d6e0b98 (#3207)
|



Specification:
objectiveOffsetCalculationOverview
The
objectiveOffsetrepresents the constant term in a linear programming objective function. For an objective function of the formΣ(aᵢ·xᵢ) + b, wherexᵢare decision variables with coefficientsaᵢ, the offset corresponds to the constant termb.This constant term aggregates all non-variable contributions to the objective value and is computed during the model building phase in
ComponentFiller::addObjectives().Calculation Rules
1. Variables Alone
No offset contribution: Variables and their coefficients do not contribute to the offset, regardless of their time/scenario dependency.
x→ offset = 0param × x→ offset = 0x(t)over n time steps → offset = 02. Literal Constants
Offset = constant value
x + 10→ offset = 103. Parameters as Constant Terms
Offset = parameter value evaluated according to its time/scenario dependency. Parameters represent known values (not optimization variables) and thus contribute to the constant term.
4. Time Dependency
Variable with constant offset
Offset = n × constant_value (where
nis the number of time steps)Time-varying parameter
Offset = Σₜ param(t) (sum over all time steps in the optimization horizon)
param = [10, 11, 12]over 3 time steps → offset = 335. Scenario Dependency
Offset = value for the selected scenario
Parameters varying only by scenario contribute their value from the selected scenario's time series.
[15, 25, 35], scenario 2 selected → offset = 356. Time AND Scenario Dependency
Offset = Σₜ param(t, s) (sum over all time steps for the selected scenario)
[15, 25, 35]over 3 time steps → offset = 757. Multiple Scenario Groups
When different model elements use different scenario groups:
Example:
xusingscenarioXwith values[11, 22, 33]scenarioYwith values[3, 6, 9]over 3 time steps