Skip to content

Conversation

@JasonMarechal25
Copy link
Contributor

@JasonMarechal25 JasonMarechal25 commented Oct 31, 2025

Specification: objectiveOffset Calculation

Overview

The objectiveOffset represents the constant term in a linear programming objective function. For an objective function of the form Σ(aᵢ·xᵢ) + b, where xᵢ are decision variables with coefficients aᵢ, the offset corresponds to the constant term b.

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 = 0
  • param × x → offset = 0
  • x(t) over n time steps → offset = 0

2. Literal Constants

Offset = constant value

  • x + 10 → offset = 10

3. 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 n is the number of time steps)

  • Variable over 10 time steps with constant offset 10 → total offset = 100
Time-varying parameter

Offset = Σₜ param(t) (sum over all time steps in the optimization horizon)

  • param = [10, 11, 12] over 3 time steps → offset = 33

5. Scenario Dependency

Offset = value for the selected scenario

Parameters varying only by scenario contribute their value from the selected scenario's time series.

  • Parameter with 3 scenarios [15, 25, 35], scenario 2 selected → offset = 35

6. Time AND Scenario Dependency

Offset = Σₜ param(t, s) (sum over all time steps for the selected scenario)

  • Parameter in selected scenario with values [15, 25, 35] over 3 time steps → offset = 75

7. Multiple Scenario Groups

When different model elements use different scenario groups:

  • Each element selects its time series from its own scenario group independently
  • Offsets from different elements accumulate
  • Only parameters (constant terms) contribute to the offset
  • Variables never contribute to the offset, even when using different scenario groups

Example:

  • Variable x using scenarioX with values [11, 22, 33]
  • Parameter using scenarioY with values [3, 6, 9] over 3 time steps
  • Variable contribution: 0 (variables don't affect offset)
  • Parameter contribution: 3 + 6 + 9 = 18
  • Total offset: 18

@JasonMarechal25 JasonMarechal25 marked this pull request as draft November 17, 2025 09:03
Comment on lines 418 to 430
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];
}
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed better : d6e0b98 (#3207)

@JasonMarechal25 JasonMarechal25 merged commit 5c8004e into develop Dec 10, 2025
8 checks passed
@JasonMarechal25 JasonMarechal25 deleted the feature/set_offset branch December 10, 2025 13:32
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants