Skip to content

Commit

Permalink
README updates
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenGar committed Mar 25, 2024
1 parent a4644a0 commit f3cd210
Showing 1 changed file with 30 additions and 33 deletions.
63 changes: 30 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Jagua-rs [![Rust CI](https://github.com/JeroenGar/jagua-rs/actions/workflows/rust.yml/badge.svg?branch=main)](https://github.com/JeroenGar/jagua-rs/actions/workflows/rust.yml)[![Docs](https://github.com/JeroenGar/jagua-rs/actions/workflows/doc.yml/badge.svg)](https://jeroengar.github.io/jagua-rs-docs/jagua_rs/)

### A fast and fearless collision detection engine for 2D irregular cutting and packing problems
### A fast and fearless collision detection engine for 2D irregular cutting and packing problems.

<img src="img/jaguars_logo.svg" width="100%" height="300px" alt="jagua-rs logo">

Expand Down Expand Up @@ -29,7 +29,7 @@ In addition, a reference implementation of a basic optimization algorithm built

## `jagua-rs` 🐆

`jagua-rs` incorporates all components required to create an **easily manipulable internal representation** of 2D
`jagua-rs` includes all components required to create an **easily manipulable internal representation** of 2D
irregular C&P problems.
It also boasts a powerful **Collision Detection Engine (CDE)** which determines whether an item can fit at a specific
position without causing any *collisions*.
Expand All @@ -38,7 +38,7 @@ position without causing any *collisions*.

- **Performant:**
- [x] Focus on maximum performance, both in terms of query resolution and update speed
- [x] Able to resolve millions of collision queries per second
- [x] Can resolve millions of collision queries per second
- [x] Integrated preprocessor to simplify polygons
- **Robust:**
- [x] Designed to mimic the exact results of a naive trigonometric approach
Expand All @@ -51,22 +51,22 @@ position without causing any *collisions*.
- [x] `HazardFilters`: excluding specific `Hazards` from consideration on a per-query basis
- **Currently supports:**
- [x] Bin- & strip-packing problems
- [x] Irregular shaped items & bins
- [x] Irregular-shaped items & bins
- [x] Continuous rotation & translation (double precision)
- [x] Holes and quality zones in the bin

## `lbf` ↙️

The `lbf` crate contains a reference implementation of an optimization algorithm built on top of `jagua-rs`.
It is a simple left-bottom-fill heuristic, which places the items one-by-one in the bin, each time at the left-bottom
It is a simple left-bottom-fill heuristic, which sequentially places the items into the bin, each time at the left-bottom
most position.

The code is thoroughly documented and should provide a good starting point for anyone interested building their own optimization algorithm on top
of `jagua-rs`.

### How to run LBF

Make sure [Rust and Cargo](https://www.rust-lang.org/learn/get-started) are installed and up to date.
Ensure [Rust and Cargo](https://www.rust-lang.org/learn/get-started) are installed and up to date.

General usage:

Expand All @@ -91,7 +91,7 @@ cargo run --release -- \

### Input

The [assets](assets) folder contains a set of input files from the academic literature that were converted to the
The [assets](assets) folder contains a set of problem instances from the academic literature that were converted to the
same JSON structure.

The files are also available in Oscar Oliveira's
Expand All @@ -100,22 +100,21 @@ The files are also available in Oscar Oliveira's
### Solution

At the end of the optimization, the solution is written to the specified folder.
Two types of files are written in the solution folder:
Two types of files are written:

#### JSON

The solution JSON is similar to the input JSON, but with the addition of the `Solution` key at the top level.
It contains all information required to recreate the solution, including the containers used, how the items are placed inside and some additional statistics.
It contains all information required to recreate the solution, such as the bins used, how the items are placed inside and some additional statistics.

#### SVG

A visual representation of every layout is created as an SVG file.
By default, just the container and the items placed inside it are drawn.
Optionally the quadtree, hazard proximity grid or fail-fast surrogates can be drawn on top.
A custom theme can also be defined.
A visual representation of every layout of the solution is created as an SVG file.
By default, only the bin and the items placed inside it are drawn.
Optionally the quadtree, hazard proximity grid and fail-fast surrogates can be drawn on top.
A custom color theme can also be defined.

This can all be configured in the config file.
See [docs](https://jeroengar.github.io/jagua-rs-docs/lbf/io/svg_util/struct.SvgDrawOptions.html) for all available
All visual options be configured in the config file, see [docs](https://jeroengar.github.io/jagua-rs-docs/lbf/io/svg_util/struct.SvgDrawOptions.html) for all available
options.

Some examples of layout SVGs created by `lbf`:
Expand All @@ -130,11 +129,11 @@ Items might therefore sometimes falsely appear to be (very slightly) colliding i

### Config JSON

Configuration of `jagua-rs` and `lbf` heuristic is done through a JSON file.
Configuration of `jagua-rs` and the `lbf` heuristic is done through a JSON file.
An example config file is provided [here](assets/config_lbf.json).
If no config file is provided, the default configuration is used.

The configuration file is a JSON file with the following structure:
The configuration file has the following structure:
```javascript
{
"cde_config": { //Configuration of the collision detection engine
Expand All @@ -150,27 +149,26 @@ The configuration file is a JSON file with the following structure:
"poly_simpl_tolerance": 0.001, //Polygons will be simplified until at most a 0.1% deviation in area from the original
"prng_seed": 0, //Seed for the pseudo-random number generator. If undefined the outcome will be non-deterministic
"n_samples": 5000, //5000 placement samples will be queried per item per layout
"ls_frac": 0.2 //Of those 5000, 80% will be sampled at uniformly at random, 20% will be local search samples
"ls_frac": 0.2 //Of those 5000 samples, 80% will be sampled at uniformly at random, 20% will be local search samples
}
```

See [docs](https://jeroengar.github.io/jagua-rs-docs/lbf/lbf_config/struct.LBFConfig.html) for a detailed description of all
available options.
See [docs](https://jeroengar.github.io/jagua-rs-docs/lbf/lbf_config/struct.LBFConfig.html) for a detailed description of all available configuration options.

### Important note

Due to `lbf` being a one-pass constructive heuristic, the final solution quality is very *chaotic*. \
Meaning that tiny changes in the operation of the algorithm (sorting of the items, configuration, prng seed...)
Due to `lbf` being a one-pass constructive heuristic, the final solution quality is very *chaotic*.
Tiny changes in the operation of the algorithm (sorting of the items, configuration, prng seed...)
will lead to solutions with drastically different quality. \
Seemingly superior configurations (such as increased `n_samples`), for example, can result in worse solutions and vice versa. \
Omitting `prng_seed` in the config file disables deterministic behavior and will demonstrate this variation in solution quality.
Seemingly superior configurations (such as increased `n_samples`), for example, may result in worse solutions and vice versa. \
Omitting `prng_seed` in the config file disables the deterministic behavior and will demonstrate this variation in solution quality.

**This heuristic should only serve as a reference implementation of how to use `jagua-rs` and not as a
optimization algorithm for any real-world use case.**
**This heuristic merely serves as a reference implementation of how to use `jagua-rs`
and should probably not be used as an optimization algorithm for any real-world use case.**

## Documentation

Documentation of this repo is written with rustdoc and is the most recent version is automatically deployed and hosted on GitHub Pages:
Documentation of this repo is written in rustdoc and the most recent version is automatically deployed and hosted on GitHub Pages:

- `jagua-rs` docs: [https://jeroengar.github.io/jagua-rs-docs/jagua_rs/](https://jeroengar.github.io/jagua-rs-docs/jagua_rs/)
- `lbf` docs: [https://jeroengar.github.io/jagua-rs-docs/lbf/](https://jeroengar.github.io/jagua-rs-docs/lbf/)
Expand All @@ -179,18 +177,17 @@ Alternatively, you can compile and view the docs of older versions locally by us

## Testing

The `jagua-rs` codebase contains a suite of assertion checks which verify the correctness of the engine.
These `debug_asserts` are enabled by default in debug and test builds but are omitted in release builds to maximize performance.
These `debug_asserts` are enabled by default in debug and test builds, but are omitted in release builds to maximize performance.

Additionally, `lbf` contains some basic integration tests to validate the correctness of the engine on a macro level.
It basically runs the heuristic on a set of input files with multiple configurations with assertions enabled.
Additionally, `lbf` contains some basic integration tests to validate the general correctness of the engine.
These tests essentially run the heuristic on a set of input files, using multiple configurations and with assertions enabled.

The scope of these tests needs to be expanded in the future.
The coverage and granularity of the tests needs to be expanded in the future.

## Development

Contributions to `jagua-rs` are more than welcome!
To submit code contributions, [fork](https://help.github.com/articles/fork-a-repo/) the repository,
To submit code contributions: [fork](https://help.github.com/articles/fork-a-repo/) the repository,
commit your changes, and [submit a pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).

## License
Expand Down

0 comments on commit f3cd210

Please sign in to comment.