https://github.com/atraplet/highs4j
HiGHS Solver for Java
https://github.com/atraplet/highs4j
convex-optimization interior-point-method java linear-programming mixed-integer-programming operations-research optimization optimization-algorithms quadratic-programming simplex-algorithm
Last synced: about 1 month ago
JSON representation
HiGHS Solver for Java
- Host: GitHub
- URL: https://github.com/atraplet/highs4j
- Owner: atraplet
- License: apache-2.0
- Created: 2024-12-06T12:02:08.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-12-24T11:35:48.000Z (2 months ago)
- Last Synced: 2025-12-26T02:09:04.583Z (2 months ago)
- Topics: convex-optimization, interior-point-method, java, linear-programming, mixed-integer-programming, operations-research, optimization, optimization-algorithms, quadratic-programming, simplex-algorithm
- Language: Java
- Homepage:
- Size: 226 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Notice: NOTICE
Awesome Lists containing this project
README
# HiGHS Solver for Java
*Work in progress*
[](https://github.com/atraplet/highs4j/actions/workflows/build.yml)
[](https://codecov.io/github/atraplet/highs4j)
[](https://central.sonatype.com/artifact/com.ustermetrics/highs4j)
[](https://github.com/atraplet/highs4j/blob/master/LICENSE)
*This library requires JDK 23 as it depends on
Java's [Foreign Function and Memory (FFM) API](https://docs.oracle.com/en/java/javase/23/core/foreign-function-and-memory-api.html).*
highs4j (HiGHS Solver for Java) is a Java library that provides an interface from the Java programming language to
the native open source mathematical programming solver [HiGHS](https://ergo-code.github.io/HiGHS). It invokes the solver
through
Java's [Foreign Function and Memory (FFM) API](https://docs.oracle.com/en/java/javase/23/core/foreign-function-and-memory-api.html).
## Usage
### Dependency
Add the latest version from [Maven Central](https://central.sonatype.com/artifact/com.ustermetrics/highs4j) to
your `pom.xml`
```
com.ustermetrics
highs4j
x.y.z
```
### Native Library
Either add the latest version of [highs4j-native](https://github.com/atraplet/highs4j-native)
from [Maven Central](https://central.sonatype.com/artifact/com.ustermetrics/highs4j-native) to
your `pom.xml`
```
com.ustermetrics
highs4j-native
x.y.z
runtime
```
or install the native solver on the machine and add the location to the `java.library.path`. highs4j dynamically
loads the native solver.
### Run Code
Since highs4j invokes some restricted methods of the FFM API,
use `--enable-native-access=com.ustermetrics.highs4j` or `--enable-native-access=ALL-UNNAMED` (if you are not using
the Java Platform Module System) to avoid warnings from the Java runtime.
## Build
### Java bindings
The directory `./bindings` contains the files and scripts needed to generate the Java bindings. The actual bindings are
under `./src/main/java` in the package `com.ustermetrics.highs4j.bindings`.
The scripts depend on the [jextract](https://jdk.java.net/jextract/) tool, which mechanically generates Java bindings
from native library headers.
The bindings are generated in two steps: First, `./bindings/generate_includes.sh` generates the dumps of the included
symbols in the `includes.txt` file. Replace absolute platform dependent path with relative platform independent path in
the comments. Remove unused includes. Second, `./bindings/generate_bindings.sh` generates the actual Java bindings.
Add `NativeLoader.loadLibrary.` Remove platform dependent layout constants and make the code platform independent.
## Release
Update the version in the `pom.xml`, create a tag, and push it by running
```
export VERSION=X.Y.Z
git checkout --detach HEAD
sed -i -E "s/[0-9]+\-SNAPSHOT<\/version>/$VERSION<\/version>/g" pom.xml
git commit -m "v$VERSION" pom.xml
git tag v$VERSION
git push origin v$VERSION
```
This will trigger the upload of the package to Maven Central via GitHub Actions.
Then, go to the GitHub repository [releases page](https://github.com/atraplet/highs4j/releases) and update the
release.
## Credits
This project is based on the native open source mathematical programming
solver [HiGHS](https://ergo-code.github.io/HiGHS), which is developed and maintained by Julian Hall, Ivet Galabova, Qi
Huangfu, Leona Gottwald, Michael Feldmeier, and other contributors. For details see https://ergo-code.github.io/HiGHS
and https://github.com/ERGO-Code/HiGHS.