You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+33-33Lines changed: 33 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,19 +4,19 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## Project Overview
6
6
7
-
clarabel4j is a Java wrapper around the native [Clarabel](https://clarabel.org)mathematical programming solver, using Java's Foreign Function and Memory (FFM) API. It requires JDK 25+.
7
+
clarabel4j is a Java library providing bindings to the [Clarabel](https://clarabel.org)convex optimization solver via Java's Foreign Function and Memory (FFM) API. Requires JDK 25+.
8
8
9
9
## Build Commands
10
10
11
11
```bash
12
-
# Build and run all tests
12
+
# Build and test
13
13
mvn clean verify
14
14
15
-
# Build with code coverage (excludes bindings package)
16
-
mvn clean verify -P coverage
15
+
# Build with coverage
16
+
mvn -B clean verify -P coverage
17
17
18
-
#Build without tests
19
-
mvn clean verify -DskipTests
18
+
#Run all tests
19
+
mvn test
20
20
21
21
# Run a single test class
22
22
mvn test -Dtest=ModelTest
@@ -25,41 +25,41 @@ mvn test -Dtest=ModelTest
25
25
mvn test -Dtest=ModelTest#solveLinearProgramReturnsExpectedSolution
26
26
```
27
27
28
-
There is no separate lint command. The project uses Lombok for annotation processing (configured in `lombok.config`).
29
-
30
28
## Architecture
31
29
32
-
### Layered Design
30
+
**Problem formulation:** minimize `1/2 x'Px + q'x` subject to `Ax + s = b, s in K` (cone constraints).
33
31
34
-
```
35
-
High-Level API (Model, Parameters, Cone, Matrix, Status, Output)
36
-
↓
37
-
FFM Bindings (com.ustermetrics.clarabel4j.bindings — auto-generated via jextract)
38
-
↓
39
-
Native Clarabel C Library (clarabel_c — loaded at runtime via NativeLoader)
40
-
```
32
+
### Core Classes (`com.ustermetrics.clarabel4j`)
41
33
42
-
### Key Classes (all in `com.ustermetrics.clarabel4j`)
34
+
-**Model** — Main entry point. Implements `AutoCloseable`; must be used with try-with-resources. Lifecycle stages: `NEW → SETUP → OPTIMIZED`. Manages native memory via FFM `Arena`.
35
+
-**Parameters** — Record with builder pattern (`Parameters.builder()...build()`). 39 solver configuration fields with validation in the canonical constructor.
36
+
-**Matrix** — Record for Compressed Sparse Column (CSC) sparse matrices. Fields: `m`, `n`, `colPtr`, `rowVal`, `nzVal`.
37
+
-**Cone** — Sealed abstract class with permits: `ZeroCone`, `NonnegativeCone`, `SecondOrderCone`, `ExponentialCone`, `PowerCone`, `GenPowerCone`.
38
+
-**Output** — Sealed interface with implementations: `StdOutOutput`, `StringOutput`, `FileOutput`.
39
+
-**Status** — Enum of solver result statuses (SOLVED, PRIMAL_INFEASIBLE, etc.).
-**Model** — Main orchestrator. Implements `AutoCloseable`. Has three lifecycle stages: `NEW → SETUP → OPTIMIZED`. Manages native memory via `Arena` (confined by default, or caller-provided). Methods: `setParameters()`, `setup()`, `optimize()`, `x()/z()/s()` etc. for results.
45
-
-**Parameters** — Lombok `@Builder` record with ~35 nullable solver settings. Only non-null values override Clarabel defaults.
46
-
-**Matrix** — Record for CSC (Compressed Sparse Column) format sparse matrices. Validates column pointer monotonicity and row index ordering.
47
-
-**Cone** — Abstract sealed class. Subtypes: `ZeroCone`, `NonnegativeCone`, `SecondOrderCone`, `ExponentialCone`, `PowerCone`, `GenPowerCone`. Each has a `getTag()` (native enum value) and `getDimension()`.
Auto-generated by `jextract` from native C headers. Do not edit manually. Regenerate with `./bindings/generate.sh`. The `bindings/` package is excluded from code coverage.
52
45
53
-
The `bindings/` directory contains `generate.sh` which uses [jextract](https://jdk.java.net/jextract/) to generate FFM bindings from Clarabel C headers. After generation, `NativeLoader.loadLibrary("clarabel_c")` must be manually added to `Clarabel_h`'s static initializer, and platform-specific binding code must be removed. The bindings are checked into source control and should not be manually edited.
46
+
## Key Patterns
54
47
55
-
### Native Library
48
+
-**Lombok** — Uses `@Builder`, `@Getter`, `@NonNull`, `val` throughout. Processed via annotation processor configured in pom.xml.
49
+
-**JPMS** — Module `com.ustermetrics.clarabel4j` defined in `src/main/java/module-info.java`.
50
+
-**Guava Preconditions** — `checkArgument`/`checkState` for validation.
-**Platform-specific native libs** — Loaded via `native-lib-loader` from `clarabel4j-native` with classifiers `linux_64`, `windows_64`, `osx_arm64`. Maven profiles auto-select based on OS.
56
53
57
-
The native library (`clarabel4j-native`) is a test-scoped dependency with platform-specific classifiers (`linux_64`, `windows_64`, `osx_arm64`) activated via Maven OS profiles.
54
+
## Release Process
58
55
59
-
### Conventions
56
+
```bash
57
+
export VERSION=X.Y.Z
58
+
git checkout --detach HEAD
59
+
sed -i -E "s/<version>[0-9]+\-SNAPSHOT<\/version>/<version>$VERSION<\/version>/g" pom.xml
60
+
git commit -m "v$VERSION" pom.xml
61
+
git tag v$VERSION
62
+
git push origin v$VERSION
63
+
```
60
64
61
-
- Guava `Preconditions` for input validation (`checkArgument`, `checkState`)
62
-
- Lombok `@NonNull`, `@Getter`, `@Builder`, `val` throughout
63
-
- Java sealed types for Cone and Output hierarchies
64
-
- Java records for immutable data (Matrix, Parameters)
65
-
- Tests verify against known Clarabel C++ example results with 1e-8 tolerance
65
+
Triggers Maven Central publication via GitHub Actions.
0 commit comments