Skip to content
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
17fdbb2
Add setObjectiveOffset
JasonMarechal25 Oct 30, 2025
6ce6190
Offset fail
JasonMarechal25 Oct 30, 2025
ef1d0b6
Not implemented in sirius
JasonMarechal25 Oct 30, 2025
7ac83b7
Only param ok
JasonMarechal25 Oct 31, 2025
c22bec2
Var in time OK
JasonMarechal25 Oct 31, 2025
5dd8b88
Time dependent offset fail
JasonMarechal25 Oct 31, 2025
3d802d0
Time dependent offset unsupported
JasonMarechal25 Oct 31, 2025
44e4152
Time dependent offset unsupported
JasonMarechal25 Oct 31, 2025
040366b
Refacto
JasonMarechal25 Oct 31, 2025
c48aeaf
Delta double comparaison
JasonMarechal25 Nov 3, 2025
0f188c0
Default highs for cucumber
JasonMarechal25 Nov 3, 2025
579c9cb
Merge branch 'develop' into feature/set_offset
JasonMarechal25 Nov 4, 2025
1090878
Use highs by default in tests
JasonMarechal25 Nov 10, 2025
fa98604
Merge remote-tracking branch 'origin/develop' into feature/set_offset
JasonMarechal25 Nov 10, 2025
691baf2
Fix merge
JasonMarechal25 Nov 10, 2025
e5df6ac
Fix merge
JasonMarechal25 Nov 10, 2025
3c47266
Merge branch 'develop' into feature/set_offset
JasonMarechal25 Nov 10, 2025
3dd1b98
Highs default
JasonMarechal25 Nov 10, 2025
8246d0e
Fix update offset
JasonMarechal25 Nov 12, 2025
1926e89
Slight improvement
JasonMarechal25 Nov 12, 2025
eee5d5f
Fix unit tests
JasonMarechal25 Nov 12, 2025
5a63ba5
Add message to error
JasonMarechal25 Nov 12, 2025
a167d65
Improve log when simulation tables don't match
JasonMarechal25 Nov 12, 2025
6596e2d
Improve log
JasonMarechal25 Nov 12, 2025
af51a70
Proper offset computation
JasonMarechal25 Nov 17, 2025
01577d2
Test description
JasonMarechal25 Nov 17, 2025
746626c
Test pass
JasonMarechal25 Nov 17, 2025
3786a08
Handle N studies
JasonMarechal25 Nov 17, 2025
cc34597
Split test suites
JasonMarechal25 Nov 17, 2025
0ef6b40
style: More explicit tests
JasonMarechal25 Nov 17, 2025
89c51e5
style: Remove intermediate variable
JasonMarechal25 Nov 17, 2025
fc7d6db
style: Declare reference outside loop
JasonMarechal25 Nov 17, 2025
cd277d4
Merge branch 'develop' into feature/set_offset
JasonMarechal25 Nov 17, 2025
7edd830
style: Format
JasonMarechal25 Nov 17, 2025
a5f5db5
test: Objective offset varying in scenario
JasonMarechal25 Nov 17, 2025
8c4feb6
test: Objective offset varying in time and scenario
JasonMarechal25 Nov 17, 2025
9c34d75
test: Objective offset and variable varying in time and scenario
JasonMarechal25 Nov 17, 2025
86e30cc
Objective offset : proposal for small improvement (#3241)
guilpier-code Nov 18, 2025
7a7276f
test: Proper objective offset for several expression
JasonMarechal25 Nov 18, 2025
14dc9cc
test: Proper objective offset for several objectives
JasonMarechal25 Nov 18, 2025
f50ad73
fix: Proper objective offset for several objectives
JasonMarechal25 Nov 18, 2025
7385d07
chore: Split large test suite
JasonMarechal25 Nov 25, 2025
9396db9
feat: Time dependent objective is not supported
JasonMarechal25 Nov 25, 2025
cfeedb7
test: add-node helper
JasonMarechal25 Nov 25, 2025
477cbd5
doc: Update expression documentation
JasonMarechal25 Nov 25, 2025
256e535
Merge branch 'develop' into feature/time_dep_obj
JasonMarechal25 Nov 25, 2025
bd9a060
feat: Time dependent objective is not supported
JasonMarechal25 Nov 25, 2025
4aafeaa
feat: Objective offset
JasonMarechal25 Nov 25, 2025
946b95d
Merge remote-tracking branch 'origin/feature/time_dep_obj' into featu…
JasonMarechal25 Nov 26, 2025
aa95227
fix: build post rebase
JasonMarechal25 Nov 26, 2025
8368e33
wip
JasonMarechal25 Nov 26, 2025
3c7715b
fix: proper offset for multiple time steps
JasonMarechal25 Nov 27, 2025
480a4f5
Merge remote-tracking branch 'origin/develop' into feature/set_offset
JasonMarechal25 Nov 27, 2025
d83a1ff
fix: build after merge
JasonMarechal25 Nov 27, 2025
be9e7d7
feat: setObjectiveOffset API
JasonMarechal25 Oct 30, 2025
f0e9b7f
feat: Don't throw error when using setObjectiveOffset with Sirius
JasonMarechal25 Nov 18, 2025
4932b40
refactor: improve design setObjectiveOffset
JasonMarechal25 Nov 21, 2025
549192b
feat: Don't throw error when using setObjectiveOffset with Sirius
JasonMarechal25 Nov 18, 2025
086e6df
refactor: improve design setObjectiveOffset
JasonMarechal25 Nov 21, 2025
d43e9ec
Merge branch 'feature/non_blocking_offset' into feature/set_offset
JasonMarechal25 Nov 27, 2025
83136e0
fix: Remove unused import
JasonMarechal25 Nov 27, 2025
49b1e19
refactor: more descriptive parameter name
JasonMarechal25 Nov 28, 2025
4a5d655
refactor: more descriptive class name
JasonMarechal25 Nov 28, 2025
a07e8ba
doc: method doc
JasonMarechal25 Nov 28, 2025
36b00a6
Merge branch 'feature/non_blocking_offset' into feature/set_offset
JasonMarechal25 Nov 28, 2025
cd56ace
refactor: use Objective() value
JasonMarechal25 Dec 1, 2025
295c8af
wip
JasonMarechal25 Dec 1, 2025
05a1def
wip
JasonMarechal25 Dec 1, 2025
bcb1979
Merge remote-tracking branch 'origin/develop' into feature/set_offset
JasonMarechal25 Dec 1, 2025
6b2def5
fix: build after merge
JasonMarechal25 Dec 1, 2025
d49902c
fix: properly handle objective offset for value
JasonMarechal25 Dec 1, 2025
01489fb
chore: update ortools to 9.14
JasonMarechal25 Dec 1, 2025
e9638d5
chore: update ortools to 9.13-rte1.2
JasonMarechal25 Dec 1, 2025
ae56b7f
chore: update ortools to 9.13-rte1.2
JasonMarechal25 Dec 1, 2025
2e4f083
Revert "refactor: use Objective() value"
JasonMarechal25 Dec 3, 2025
9c994dc
chore: update ortools to 9.13-rte1.3
JasonMarechal25 Dec 4, 2025
1f642a1
chore: bump registry
JasonMarechal25 Dec 4, 2025
9597205
fix
JasonMarechal25 Dec 4, 2025
9c89bf8
Merge remote-tracking branch 'origin/develop' into feature/set_offset
JasonMarechal25 Dec 5, 2025
40e2cd3
fix: build
JasonMarechal25 Dec 5, 2025
335a8c9
fix: build TIMESERIE -> TIMESERIES
JasonMarechal25 Dec 5, 2025
55b03dc
Revert "Revert "refactor: use Objective() value""
JasonMarechal25 Dec 5, 2025
9f38df6
Revert "Revert "Revert "refactor: use Objective() value"""
JasonMarechal25 Dec 5, 2025
07bfb75
Merge branch 'develop' into feature/set_offset
JasonMarechal25 Dec 8, 2025
b373401
fix: return proper objective value
JasonMarechal25 Dec 8, 2025
f098b60
tests: test on getObjectiveValue
JasonMarechal25 Dec 8, 2025
fc2003d
fix: remove unused header
JasonMarechal25 Dec 8, 2025
d6e0b98
refactor: cleaner
JasonMarechal25 Dec 10, 2025
25e22e8
Merge branch 'develop' into feature/set_offset
JasonMarechal25 Dec 10, 2025
7fdc23f
fix: unit tests after rebase
JasonMarechal25 Dec 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class ILinearProblem
virtual void setObjectiveCoefficient(IMipVariable* var, double coefficient) = 0;
virtual double getObjectiveCoefficient(const IMipVariable* var) const = 0;

virtual void setObjectiveOffset(double offset) = 0;
virtual double getObjectiveOffset() const = 0;

/// Sets the optimization direction to minimize
virtual void setMinimization() = 0;
/// Sets the optimization direction to maximize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class OrtoolsLinearProblem: public LinearProblemApi::ILinearProblem
void setObjectiveCoefficient(LinearProblemApi::IMipVariable* var, double coefficient) override;
double getObjectiveCoefficient(const LinearProblemApi::IMipVariable* var) const override;

void setObjectiveOffset(double offset) override;
double getObjectiveOffset() const override;

void setMinimization() override;
void setMaximization() override;

Expand Down
10 changes: 10 additions & 0 deletions src/optimisation/linear-problem-mpsolver-impl/linearProblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ double OrtoolsLinearProblem::getObjectiveCoefficient(
return objective_->GetCoefficient(getMpVar(var));
}

void OrtoolsLinearProblem::setObjectiveOffset(double offset)
{
objective_->SetOffset(offset);
}

double OrtoolsLinearProblem::getObjectiveOffset() const
{
return objective_->offset();
}

void OrtoolsLinearProblem::setMinimization()
{
objective_->SetMinimization();
Expand Down
31 changes: 25 additions & 6 deletions src/solver/optim-model-filler/ComponentFiller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
#include <antares/expressions/nodes/ExpressionsNodes.h>
#include <antares/expressions/visitors/EvalVisitor.h>
#include <antares/solver/optim-model-filler/ComponentFiller.h>
#include "antares/exception/InvalidArgumentError.hpp"
#include "antares/exception/RuntimeError.hpp"
#include "antares/expressions/visitors/TimeIndexVisitor.h"
#include "antares/logs/logs.h"

namespace
{
Expand Down Expand Up @@ -284,12 +287,12 @@ void ComponentFiller::addVariables(const LinearProblemApi::FillContext& ctx)
return;
}

Expressions::Visitors::EvalVisitor evaluator(optimEntityContainer_, ctx, component_);
Visitors::EvalVisitor evaluator(optimEntityContainer_, ctx, component_);
auto valueOrDefault = [&evaluator](const auto& node, double defaultValue)
{
if (node.Empty())
{
return Expressions::Visitors::EvaluationResult(defaultValue);
return Visitors::EvaluationResult(defaultValue);
}
return evaluator.dispatch(node.RootNode());
};
Expand Down Expand Up @@ -336,7 +339,7 @@ void ComponentFiller::addVariables(const LinearProblemApi::FillContext& ctx)
}

void ComponentFiller::addStaticConstraint(const LinearConstraint& linear_constraint,
const std::string& constraint_id)
const std::string& constraint_id) const
{
auto* ct = optimEntityContainer_.Problem().addConstraint(linear_constraint.lb[0],
linear_constraint.ub[0],
Expand All @@ -353,7 +356,7 @@ void ComponentFiller::addStaticConstraint(const LinearConstraint& linear_constra

void ComponentFiller::addTimeDependentConstraints(const LinearConstraint& linear_constraints,
const std::string& constraint_id,
const LinearProblemApi::FillContext& ctx)
const LinearProblemApi::FillContext& ctx) const
{
auto& pb = optimEntityContainer_.Problem();
const auto dims = getDimensions(ctx);
Expand Down Expand Up @@ -409,6 +412,19 @@ void ComponentFiller::addConstraints(const LinearProblemApi::FillContext& ctx)
}
}

namespace
{
/*
* Given objective ax + b, x being a time dependent variable and b a parameter. b is the offset.
* Problems are a_1*x_1+b + a_2*x_2+b + ... + a_n*x_n+b
* => offset = n*b
*/
double updateOffset(double initialValue, double offset)
{
return initialValue + offset;
}
} // namespace

void ComponentFiller::addObjectives(const LinearProblemApi::FillContext& ctx)
{
auto* model = component_.getModel();
Expand All @@ -420,27 +436,30 @@ void ComponentFiller::addObjectives(const LinearProblemApi::FillContext& ctx)
[&](const auto& objective)
{ return AreLocationsCompatible(objective.location(), targetLocation_); });

auto& pb = optimEntityContainer_.Problem();
for (const auto& objective: model->Objectives() | locationFilter)
{
const auto linearExpression = visitor.visitMergeDuplicates(
objective.expression().RootNode());

auto& pb = optimEntityContainer_.Problem();
double objectiveOffset = 0.0;
for (const auto& expr: linearExpression)
{
for (const auto& [index, value]: expr)
{
pb.setObjectiveCoefficient(solverVariables[static_cast<std::size_t>(index)].get(),
value);
}
objectiveOffset = updateOffset(objectiveOffset, expr.constant());
}
pb.setObjectiveOffset(objectiveOffset);
}
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

When iterating over multiple objectives, pb.setObjectiveOffset(objectiveOffset) at line 455 will overwrite any offset set by previous objectives in the loop. If multiple objectives are intended to be supported, their offsets should be accumulated rather than overwritten. Consider either:

  1. Accumulating the offset across objectives: Store a total offset outside the loop and add to it
  2. Adding documentation that only one objective per component is expected
  3. Add a check that ensures only one objective exists

Note: The same issue exists for objective coefficients (line 450-451), suggesting this may be an existing design limitation rather than a new bug, but it should be clarified.

Copilot uses AI. Check for mistakes.
}

TimeIndex ComponentFiller::getConstraintTimeIndex(const Nodes::Node* node,
const Component& component) const
{
Expressions::Visitors::TimeIndexVisitor timeIndexVisitor(optimEntityContainer_, component);
Visitors::TimeIndexVisitor timeIndexVisitor(optimEntityContainer_, component);
return timeIndexVisitor.dispatch(node);
}
} // namespace Antares::Optimisation
Loading
Loading