Skip to content

Commit

Permalink
Bump Knitro to 14.2.0
Browse files Browse the repository at this point in the history
Signed-off-by: Damien Jeandemange <damien.jeandemange@artelys.com>
  • Loading branch information
jeandemanged committed Dec 20, 2024
1 parent 6c5c205 commit 61b5c2b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 32 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
wget -nv -O knitro.tar.gz --user "$KNITRO_DOWNLOAD_USER" --password "$KNITRO_DOWNLOAD_PASSWORD" "$KNITRO_LINUX_URL"
mkdir -p $RUNNER_TEMP/knitro
tar xzf knitro.tar.gz -C $RUNNER_TEMP/knitro
echo "KNITRODIR=$RUNNER_TEMP/knitro/knitro-14.1.0-Linux64" >> "$GITHUB_ENV"
echo "KNITRODIR=$RUNNER_TEMP/knitro/knitro-14.2.0-Linux64" >> "$GITHUB_ENV"
env:
KNITRO_DOWNLOAD_USER: ${{ secrets.KNITRO_DOWNLOAD_USER }}
KNITRO_DOWNLOAD_PASSWORD: ${{ secrets.KNITRO_DOWNLOAD_PASSWORD }}
Expand All @@ -35,7 +35,7 @@ jobs:
run: |
C:\msys64\usr\bin\wget.exe -nv -O knitro.zip --user "$env:KNITRO_DOWNLOAD_USER" --password "$env:KNITRO_DOWNLOAD_PASSWORD" "$env:KNITRO_WINDOWS_URL"
7z x -y knitro.zip -oC:\knitro
echo "KNITRODIR=C:\knitro\knitro-14.1.0-Win64" >> "$env:GITHUB_ENV"
echo "KNITRODIR=C:\knitro\knitro-14.2.0-Win64" >> "$env:GITHUB_ENV"
env:
KNITRO_DOWNLOAD_USER: ${{ secrets.KNITRO_DOWNLOAD_USER }}
KNITRO_DOWNLOAD_PASSWORD: ${{ secrets.KNITRO_DOWNLOAD_PASSWORD }}
Expand All @@ -53,15 +53,15 @@ jobs:
- name: Build with Maven (Ubuntu)
if: matrix.os != 'windows-latest'
run: |
./mvnw install:install-file -Dfile="$KNITRODIR/examples/Java/lib/Knitro-Interfaces-2.5-KN_14.1.0.jar" -DgroupId=com.artelys -DartifactId=knitro-interfaces -Dversion=14.1.0 -Dpackaging=jar -DgeneratePom=true
./mvnw install:install-file -Dfile="$KNITRODIR/examples/Java/lib/Knitro-Interfaces-2.5-KN_14.2.0.jar" -DgroupId=com.artelys -DartifactId=knitro-interfaces -Dversion=14.2.0 -Dpackaging=jar -DgeneratePom=true
./mvnw --batch-mode -Pjacoco install
env:
ARTELYS_LICENSE: ${{ secrets.ARTELYS_LICENSE }}

- name: Build with Maven (Windows)
if: matrix.os == 'windows-latest'
run: |
call mvnw.cmd install:install-file -Dfile="%KNITRODIR%\examples\Java\lib\Knitro-Interfaces-2.5-KN_14.1.0.jar" -DgroupId=com.artelys -DartifactId=knitro-interfaces -Dversion=14.1.0 -Dpackaging=jar -DgeneratePom=true
call mvnw.cmd install:install-file -Dfile="%KNITRODIR%\examples\Java\lib\Knitro-Interfaces-2.5-KN_14.2.0.jar" -DgroupId=com.artelys -DartifactId=knitro-interfaces -Dversion=14.2.0 -Dpackaging=jar -DgeneratePom=true
mvnw.cmd --batch-mode install
shell: cmd
env:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/snapshot-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
wget -nv -O knitro.tar.gz --user "$KNITRO_DOWNLOAD_USER" --password "$KNITRO_DOWNLOAD_PASSWORD" "$KNITRO_LINUX_URL"
mkdir -p $RUNNER_TEMP/knitro
tar xzf knitro.tar.gz -C $RUNNER_TEMP/knitro
echo "KNITRODIR=$RUNNER_TEMP/knitro/knitro-14.1.0-Linux64" >> "$GITHUB_ENV"
echo "KNITRODIR=$RUNNER_TEMP/knitro/knitro-14.2.0-Linux64" >> "$GITHUB_ENV"
env:
KNITRO_DOWNLOAD_USER: ${{ secrets.KNITRO_DOWNLOAD_USER }}
KNITRO_DOWNLOAD_PASSWORD: ${{ secrets.KNITRO_DOWNLOAD_PASSWORD }}
Expand All @@ -35,7 +35,7 @@ jobs:
run: |
C:\msys64\usr\bin\wget.exe -nv -O knitro.zip --user "$env:KNITRO_DOWNLOAD_USER" --password "$env:KNITRO_DOWNLOAD_PASSWORD" "$env:KNITRO_WINDOWS_URL"
7z x -y knitro.zip -oC:\knitro
echo "KNITRODIR=C:\knitro\knitro-14.1.0-Win64" >> "$env:GITHUB_ENV"
echo "KNITRODIR=C:\knitro\knitro-14.2.0-Win64" >> "$env:GITHUB_ENV"
env:
KNITRO_DOWNLOAD_USER: ${{ secrets.KNITRO_DOWNLOAD_USER }}
KNITRO_DOWNLOAD_PASSWORD: ${{ secrets.KNITRO_DOWNLOAD_PASSWORD }}
Expand Down Expand Up @@ -110,15 +110,15 @@ jobs:
- name: Build with Maven (Ubuntu)
if: matrix.os != 'windows-latest'
run: |
./mvnw install:install-file -Dfile="$KNITRODIR/examples/Java/lib/Knitro-Interfaces-2.5-KN_14.1.0.jar" -DgroupId=com.artelys -DartifactId=knitro-interfaces -Dversion=14.1.0 -Dpackaging=jar -DgeneratePom=true
./mvnw install:install-file -Dfile="$KNITRODIR/examples/Java/lib/Knitro-Interfaces-2.5-KN_14.2.0.jar" -DgroupId=com.artelys -DartifactId=knitro-interfaces -Dversion=14.2.0 -Dpackaging=jar -DgeneratePom=true
./mvnw --batch-mode -Pjacoco install
env:
ARTELYS_LICENSE: ${{ secrets.ARTELYS_LICENSE }}

- name: Build with Maven (Windows)
if: matrix.os == 'windows-latest'
run: |
call mvnw.cmd install:install-file -Dfile="%KNITRODIR%\examples\Java\lib\Knitro-Interfaces-2.5-KN_14.1.0.jar" -DgroupId=com.artelys -DartifactId=knitro-interfaces -Dversion=14.1.0 -Dpackaging=jar -DgeneratePom=true
call mvnw.cmd install:install-file -Dfile="%KNITRODIR%\examples\Java\lib\Knitro-Interfaces-2.5-KN_14.2.0.jar" -DgroupId=com.artelys -DartifactId=knitro-interfaces -Dversion=14.2.0 -Dpackaging=jar -DgeneratePom=true
mvnw.cmd --batch-mode install
shell: cmd
env:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Knitro Java bindings require a private JAR file that must be installed locally,
Use the following command:

```bash
./mvnw install:install-file -Dfile="$KNITRODIR/examples/Java/lib/Knitro-Interfaces-2.5-KN_14.1.0.jar" -DgroupId=com.artelys -DartifactId=knitro-interfaces -Dversion=14.1.0 -Dpackaging=jar -DgeneratePom=true
./mvnw install:install-file -Dfile="$KNITRODIR/examples/Java/lib/Knitro-Interfaces-2.5-KN_14.2.0.jar" -DgroupId=com.artelys -DartifactId=knitro-interfaces -Dversion=14.2.0 -Dpackaging=jar -DgeneratePom=true
```

### Running a Load Flow with Knitro Solver
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<java.version>17</java.version>
<powsybl-core.version>6.6.0</powsybl-core.version>
<powsybl-open-loadflow.version>1.14.1</powsybl-open-loadflow.version>
<knitro-interfaces.version>14.1.0</knitro-interfaces.version>
<knitro-interfaces.version>14.2.0</knitro-interfaces.version>
<bridj.version>0.7.0</bridj.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,27 +535,6 @@ private void setSolverParameters(KNSolver solver) throws KNException {
solver.setParam(KNConstants.KN_PARAM_MAXIT, knitroParameters.getMaxIterations());
}

/**
* Temporary to workaround Knitro finalization issue - FIXME on Knitro v14.2 release which will have the proper fix
*/
@SuppressWarnings({"java:S1113", "java:S1874", "java:S5738"})
public static class FinalizeSafeSolver extends KNSolver implements AutoCloseable {

public FinalizeSafeSolver(KNBaseProblem problem) throws KNException {
super(problem);
}

@Override
protected void finalize() {
// no-op.
}

@Override
public void close() {
this.KNFree();
}
}

@Override
public AcSolverResult run(VoltageInitializer voltageInitializer, ReportNode reportNode) {
int nbIter;
Expand All @@ -569,7 +548,7 @@ public AcSolverResult run(VoltageInitializer voltageInitializer, ReportNode repo
throw new PowsyblException("Exception while trying to build Knitro Problem", e);
}

try (FinalizeSafeSolver solver = new FinalizeSafeSolver(instance)) {
try (KNSolver solver = new KNSolver(instance)) {
// Initialize problem
solver.initProblem();

Expand Down

0 comments on commit 61b5c2b

Please sign in to comment.