Skip to content

Commit 177f2af

Browse files
committed
Update CLAUDE.md with Opus 4.6
1 parent 224b681 commit 177f2af

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

CLAUDE.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Project Overview
66

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+.
88

99
## Build Commands
1010

1111
```bash
12-
# Build and run all tests
12+
# Build and test
1313
mvn clean verify
1414

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
1717

18-
# Build without tests
19-
mvn clean verify -DskipTests
18+
# Run all tests
19+
mvn test
2020

2121
# Run a single test class
2222
mvn test -Dtest=ModelTest
@@ -25,41 +25,41 @@ mvn test -Dtest=ModelTest
2525
mvn test -Dtest=ModelTest#solveLinearProgramReturnsExpectedSolution
2626
```
2727

28-
There is no separate lint command. The project uses Lombok for annotation processing (configured in `lombok.config`).
29-
3028
## Architecture
3129

32-
### Layered Design
30+
**Problem formulation:** minimize `1/2 x'Px + q'x` subject to `Ax + s = b, s in K` (cone constraints).
3331

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`)
4133

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.).
40+
- **DirectSolveMethod** — Enum (AUTO, QDLDL, FAER, PARDISO_MKL).
4341

44-
- **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()`.
48-
- **Status** — Enum mapping native solver status codes (SOLVED, PRIMAL_INFEASIBLE, etc.).
49-
- **Output** — Sealed interface with `StdOutOutput`, `StringOutput`, `FileOutput` implementations.
42+
### Bindings (`com.ustermetrics.clarabel4j.bindings`)
5043

51-
### Bindings Package
44+
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.
5245

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
5447

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.
51+
- **Native access** — Tests require JVM flags `--enable-native-access=com.ustermetrics.clarabel4j --enable-native-access=org.scijava.nativelib` (configured in maven-surefire-plugin).
52+
- **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.
5653

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
5855

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+
```
6064

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

Comments
 (0)