Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
01d221d
feat(solver): add a first version of the Resilient LF with Reactiv Li…
YoannAnezin Jun 4, 2025
484983f
feat(solver): Implementation of the Resilient LF with Reactiv Limits …
YoannAnezin Jun 6, 2025
f064e0a
feat(solver): Implementation of the Resilient LF with Reactiv Limits …
YoannAnezin Jun 25, 2025
2d9ab15
feat(solver): First jacobienne implementation & tests
YoannAnezin Jul 24, 2025
4486c4c
feat(solver): Tests with and without jacobienne for the ReactiveLimit…
YoannAnezin Aug 12, 2025
e7b8bea
feat(solver): Corrections
YoannAnezin Aug 12, 2025
1c16806
feat(solver): Corrections
YoannAnezin Aug 13, 2025
35731ba
feat(solver): Tests with jacobienne
YoannAnezin Aug 14, 2025
a16425b
Change voltage upper limit to 5
YoannAnezin Aug 21, 2025
45403a4
feat(solver): Scaling P, Q slack variables and tests with jacobienne
YoannAnezin Aug 21, 2025
d0d8a38
feat(solver): Scaling P, Q slack variables and tests with jacobienne
YoannAnezin Aug 26, 2025
48b712e
feat(solver): Balance obj weights and get best feasible solution
YoannAnezin Aug 26, 2025
4e0d7c9
feat(solver): Implementation of the Resilient LF with Reactiv Limits …
YoannAnezin Jun 25, 2025
b6a37b0
feat(solver): First jacobienne implementation & tests
YoannAnezin Jul 24, 2025
ddb4c13
feat(solver): Tests with and without jacobienne for the ReactiveLimit…
YoannAnezin Aug 12, 2025
edd3edf
feat(solver): Corrections
YoannAnezin Aug 12, 2025
5f6fc52
feat(solver): Scaling P, Q slack variables and tests with jacobienne
YoannAnezin Aug 26, 2025
2f55079
feat(solver): WIP
YoannAnezin Aug 28, 2025
068f9d8
feat(solver): WIP Time computing optimization
YoannAnezin Sep 8, 2025
61af302
feat(solver): WIP Add Logs' writter and pertubation tests
YoannAnezin Sep 15, 2025
793ad64
feat(solver): Correction of checker and considering only Q equation w…
YoannAnezin Sep 19, 2025
7ef9e5d
feat(solver): Correction of checker and considering only Q equation w…
YoannAnezin Sep 23, 2025
bc4294c
feat(solver): Add time spent in solver class
YoannAnezin Sep 24, 2025
190c3bc
Some modif.
p-arvy Sep 26, 2025
42dce3f
Add modif for paper
p-arvy Oct 2, 2025
1ff61db
feat(solver): Correction checker (Remote Controle)
YoannAnezin Oct 8, 2025
40954c4
feat(solver): Small correction
YoannAnezin Oct 8, 2025
2f154fc
feat(solver): Remote Voltage Control
YoannAnezin Oct 9, 2025
73c8def
Add feastolabs in Knitro parameters
p-arvy Oct 8, 2025
29b8982
wip
p-arvy Oct 13, 2025
ddf8ca8
wip (for paper)
p-arvy Oct 20, 2025
4ad0011
feat(solver): Corrections
YoannAnezin Oct 13, 2025
c127988
WIP Comments
YoannAnezin Oct 31, 2025
d530124
Clean
p-arvy Dec 15, 2025
887590c
Clean
p-arvy Dec 15, 2025
a20324b
Rename solver
p-arvy Dec 15, 2025
bb102f7
wip
p-arvy Dec 15, 2025
091824f
wip
p-arvy Dec 15, 2025
7d121cc
wip
p-arvy Dec 15, 2025
24b87d6
wip
p-arvy Dec 15, 2025
47f9f05
wip: refactor objective function
p-arvy Dec 15, 2025
39ac8e1
wip: refactor jacobian
p-arvy Dec 15, 2025
bffe067
feat(test): remove tests on IEEE 118 and 300 networks
amakhen Dec 18, 2025
175de57
refactor(test): create factory method and remove duplicated code
amakhen Dec 18, 2025
4eb75b4
refactor(test): reuse code for finite differences convergence tests a…
amakhen Dec 18, 2025
005788b
feat(solver): draft for fuse relaxed and reactive-limits solvers
amakhen Jan 6, 2026
9f2c62b
fix(solver): make nonlinear coeffs array global to track correct equa…
amakhen Jan 7, 2026
892edeb
fix(solver): add build sparse jacobian override in use reactive limit…
amakhen Jan 7, 2026
73a9a3a
fix(solver): respect checkstyle guidelines
amakhen Jan 7, 2026
5917916
wip
p-arvy Jan 9, 2026
b2e36c7
refactor log switches and add equation
p-arvy Jan 9, 2026
c35b86f
wip
p-arvy Jan 9, 2026
eeae428
wip: continue to refactor setupConstraints
p-arvy Jan 9, 2026
0669a69
wip: clean
p-arvy Jan 9, 2026
078715c
wip: modification that might break jacobian evaluation
p-arvy Jan 9, 2026
4f95144
wip: add comments
p-arvy Jan 9, 2026
d048ca9
wip: update solver constructor
p-arvy Jan 12, 2026
69871a0
wip: small clean
p-arvy Jan 12, 2026
34277e3
Fix cherry pick and rollback knitro version for now
p-arvy Jan 12, 2026
0f2e4e8
remove macos for now
p-arvy Jan 12, 2026
9430f25
rollback CI for now
p-arvy Jan 12, 2026
ccfbee0
improve quality
p-arvy Jan 12, 2026
5971152
test the capricious CI
p-arvy Jan 12, 2026
e97be2e
forced submission to the capricious CI
p-arvy Jan 12, 2026
cf5b13d
refactor num variables in solvers
p-arvy Jan 13, 2026
0fe6cd7
small clean
p-arvy Jan 13, 2026
d432acb
rollback final attribute
p-arvy Jan 13, 2026
b8c097e
feat(solver): mutualize gradient callback code for reactive limits so…
amakhen Jan 13, 2026
d2e9189
fix(solver): remove checkstyle violation
amakhen Jan 13, 2026
b69d905
feat(solver): remove code duplication in build sparse matrix in use r…
amakhen Jan 13, 2026
05dbb0a
feat(solver): launch error when trying to run exact dense jacobian mo…
amakhen Jan 13, 2026
141a270
refactor(solver): use power base from powsybl library
amakhen Jan 13, 2026
91a2262
refactor(solver): remove redundant variable
amakhen Jan 13, 2026
5e6006c
refactor(solver): add some comments + clean up
amakhen Jan 13, 2026
5ba6336
clean TU
p-arvy Jan 16, 2026
296886d
rollback CI and knitro 15.1
p-arvy Jan 16, 2026
4e60066
Small refactor
p-arvy Jan 16, 2026
b89efb7
update CI
p-arvy Jan 16, 2026
56e2973
fix TU
p-arvy Jan 20, 2026
b60299a
Deactivate use reactive limits outerloop
p-arvy Jan 20, 2026
349b8cf
Add exception when solver is used with useReactiveLimits LoadFlowPara…
p-arvy Jan 20, 2026
32e9e7d
clean
p-arvy Jan 20, 2026
67ce806
Update readme
p-arvy Jan 20, 2026
8d08ee6
Update README
p-arvy Jan 20, 2026
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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ LoadFlow.run(network, parameters);
## Features

The Knitro solver is used as a substitute for the **inner loop calculations** in the load flow process.
The **outer loops** such as distributed slack, reactive limits, etc... operate identically as when using the Newton-Raphson method.
The **outer loops** such as distributed slack, voltage monitoring, etc... operate identically as when using the Newton-Raphson method.
Note that for the reactive limits outer loop case, it is run in the standard way only when the selected Knitro solver does not directly integrate reactive
limits into the optimization model (cf [Knitro Parameters](#knitro-parameters)).

### Configuration

Expand All @@ -175,6 +177,11 @@ parameters.addExtension(KnitroLoadFlowParameters.class, knitroLoadFlowParameters
- **Knitro Solver Types**:
- `STANDARD (default)` : the constraint satisfaction problem formulation and a direct substitute to the Newton-Raphson solver.
- `RELAXED` : the optimisation problem formulation relaxing satisfaction problem.
- `USE_REACTIVE_LIMITS` : the optimization problem formulation relaxing satisfaction problem and integrating reactive limits in constraints.
Note that using this solver requires disabling the `useReactiveLimits` parameter in `LoadFlowParameters`, for compatibility reasons with the way outer
loops are launched in Open-Load-Flow. Doing so, the Open-Load-Flow checks that disable voltage control when the reactive power bounds are not sufficiently
large (see [OLF documentation](https://powsybl.readthedocs.io/projects/powsybl-open-loadflow/en/latest/loadflow/parameters.html)) are not performed, which may explain some of the differences in results between the Newton–Raphson solver and the Knitro solver.
This will be addressed in a near future.
- Use `setKnitroSolverType` in the `KnitroLoadFlowParameters` extension.

2. **Voltage Bounds**:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* - Initialization and definition of variable bounds for the optimization problem.
* - Definition of constraints (including those evaluated via callbacks in {@link KnitroCallbacks}).
* - Representation of the constraint Jacobian for the problem.
* This class can be extended to customize any of these features (e.g., in {@link RelaxedKnitroSolver.RelaxedKnitroProblem}).
* This class can be extended to customize any of these features (e.g., in {@link AbstractRelaxedKnitroSolver.AbstractRelaxedKnitroProblem}).
* For example, if you modify the optimization problem, you may also need to update the initialization of additional variables.
*
* @author Jeanne Archambault {@literal <jeanne.archambault at artelys.com>}
Expand All @@ -51,27 +51,35 @@ public abstract class AbstractKnitroProblem extends KNProblem {
protected final int numberOfPowerFlowVariables;
protected List<Equation<AcVariableType, AcEquationType>> activeConstraints = new ArrayList<>();
protected final List<Integer> nonlinearConstraintIndexes = new ArrayList<>();
protected final int numTotalVariables;

protected AbstractKnitroProblem(LfNetwork network, EquationSystem<AcVariableType, AcEquationType> equationSystem,
TargetVector<AcVariableType, AcEquationType> targetVector, JacobianMatrix<AcVariableType, AcEquationType> jacobianMatrix,
KnitroSolverParameters knitroParameters, int numTotalVariables) {
super(numTotalVariables, equationSystem.getIndex().getSortedEquationsToSolve().size());
KnitroSolverParameters knitroParameters) {
this(network, equationSystem, targetVector, jacobianMatrix, knitroParameters, 0, 0);
}

protected AbstractKnitroProblem(LfNetwork network, EquationSystem<AcVariableType, AcEquationType> equationSystem,
TargetVector<AcVariableType, AcEquationType> targetVector, JacobianMatrix<AcVariableType, AcEquationType> jacobianMatrix,
KnitroSolverParameters knitroParameters, int numAdditionalVariables, int numAdditionalConstraints) {
super(equationSystem.getIndex().getSortedVariablesToFind().size() + numAdditionalVariables,
equationSystem.getIndex().getSortedEquationsToSolve().size() + numAdditionalConstraints);
this.numberOfPowerFlowVariables = equationSystem.getIndex().getSortedVariablesToFind().size();
this.numTotalVariables = numberOfPowerFlowVariables + numAdditionalVariables;
this.network = network;
this.equationSystem = equationSystem;
this.targetVector = targetVector;
this.jacobianMatrix = jacobianMatrix;
this.knitroParameters = knitroParameters;
this.numberOfPowerFlowVariables = equationSystem.getIndex().getSortedVariablesToFind().size();
}

/**
* Initializes variables (types, bounds, initial values).
* Can be overridden by subclasses to add additional variables (e.g., slack variables).
*
* @param voltageInitializer The voltage initializer to use.
* @param numTotalVariables Total number of variables including any additional ones.
*/
protected void initializeVariables(VoltageInitializer voltageInitializer, int numTotalVariables) throws KNException {
protected void initializeVariables(VoltageInitializer voltageInitializer) throws KNException {
List<Integer> variableTypes = new ArrayList<>(Collections.nCopies(numTotalVariables, KNConstants.KN_VARTYPE_CONTINUOUS));
List<Double> lowerBounds = new ArrayList<>(Collections.nCopies(numTotalVariables, -KNConstants.KN_INFINITY));
List<Double> upperBounds = new ArrayList<>(Collections.nCopies(numTotalVariables, KNConstants.KN_INFINITY));
Expand All @@ -95,7 +103,10 @@ protected void initializeVariables(VoltageInitializer voltageInitializer, int nu
}

// Allow subclasses to modify bounds and initial values (e.g., for slack variables)
initializeCustomizedVariables(lowerBounds, upperBounds, initialValues, numTotalVariables);
initializeCustomizedVariables(lowerBounds, upperBounds, initialValues);

// Set up scaling factors
setUpScalingFactors();

setVarLoBnds(lowerBounds);
setVarUpBnds(upperBounds);
Expand All @@ -110,10 +121,18 @@ protected void initializeVariables(VoltageInitializer voltageInitializer, int nu
* @param lowerBounds Lower bounds list to modify.
* @param upperBounds Upper bounds list to modify.
* @param initialValues Initial values list to modify.
* @param numTotalVariables Total number of variables.
*/
protected void initializeCustomizedVariables(List<Double> lowerBounds, List<Double> upperBounds,
List<Double> initialValues, int numTotalVariables) {
List<Double> initialValues) {
// no customization by default
}

/**
* Allows subclasses to utilize scaling.
* Default implementation does nothing.
*
*/
protected void setUpScalingFactors() throws KNException {
// no customization by default
}

Expand All @@ -131,7 +150,7 @@ protected void setupConstraints() throws KNException {
NonLinearExternalSolverUtils solverUtils = new NonLinearExternalSolverUtils();

// add linear constraints and fill the list of non-linear constraints
addLinearConstraints(activeConstraints, solverUtils, nonlinearConstraintIndexes);
addLinearConstraints(activeConstraints, solverUtils);

// pass to Knitro the indexes of non-linear constraints, that will be evaluated in the callback function
setMainCallbackCstIndexes(nonlinearConstraintIndexes);
Expand All @@ -145,14 +164,12 @@ protected void setupConstraints() throws KNException {
*
* @param sortedEquationsToSolve Sorted list of equations to solve.
* @param solverUtils Utilities to extract linear constraints.
* @param nonLinearConstraintIds Output list of indices of non-linear constraints.
*/
protected void addLinearConstraints(List<Equation<AcVariableType, AcEquationType>> sortedEquationsToSolve,
NonLinearExternalSolverUtils solverUtils,
List<Integer> nonLinearConstraintIds) {
NonLinearExternalSolverUtils solverUtils) {

for (int equationId = 0; equationId < sortedEquationsToSolve.size(); equationId++) {
addConstraint(equationId, sortedEquationsToSolve, solverUtils, nonLinearConstraintIds);
addConstraint(equationId, sortedEquationsToSolve, solverUtils);
}
}

Expand All @@ -163,10 +180,9 @@ protected void addLinearConstraints(List<Equation<AcVariableType, AcEquationType
* @param equationId Index of the equation in the list.
* @param sortedEquationsToSolve List of all equations to solve.
* @param solverUtils Utilities to extract linear constraint components.
* @param nonLinearConstraintIds Output list of non-linear constraint indices.
*/
protected void addConstraint(int equationId, List<Equation<AcVariableType, AcEquationType>> sortedEquationsToSolve,
NonLinearExternalSolverUtils solverUtils, List<Integer> nonLinearConstraintIds) {
NonLinearExternalSolverUtils solverUtils) {

Equation<AcVariableType, AcEquationType> equation = sortedEquationsToSolve.get(equationId);
AcEquationType equationType = equation.getType();
Expand All @@ -190,7 +206,7 @@ protected void addConstraint(int equationId, List<Equation<AcVariableType, AcEqu
throw new PowsyblException("Failed to process linear constraint for equation #" + equationId, e);
}
} else {
nonLinearConstraintIds.add(equationId);
nonlinearConstraintIndexes.add(equationId);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* - Configuration of the external Knitro solver.
* - Creation of the optimization problem (extending {@link AbstractKnitroProblem}).
* - Processing of the obtained solution.
* This class can be extended to add custom behavior to any of these features (e.g., in {@link RelaxedKnitroSolver}).
* This class can be extended to add custom behavior to any of these features (e.g., in {@link AbstractRelaxedKnitroSolver}).
* For example, if you modify the optimization problem, you may also need to update the solution-processing logic.
*
* @author Pierre Arvy {@literal <pierre.arvy at artelys.com>}
Expand Down
Loading