Skip to content
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

Bump Knitro to 14.2.0 #6

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading