Skip to content

Commit

Permalink
Elaborated on 0.9.0 rectpacking restructure in release notes and blog.
Browse files Browse the repository at this point in the history
  • Loading branch information
soerendomroes committed Jan 4, 2024
1 parent 75a4a1e commit 0fa97fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
22 changes: 11 additions & 11 deletions docs/content/blog/posts/2022/22-08-31-rectpacking.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title: "Rectpacking"
title: "Rectpacking (Updated)"
menu:
main:
identifier: "22-08-31-rectpacking"
parent: "2022"
weight: 10
---
_By Sören Domrös, August 31, 2022_
_By Sören Domrös, August 31, 2022_, updated January 4, 2024

The [`rectpacking`](https://www.eclipse.org/elk/reference/algorithms/org-eclipse-elk-rectpacking.html) algorithm was introduced to solved common problems with the [`box`](https://www.eclipse.org/elk/reference/algorithms/org-eclipse-elk-box.html) algorithm, which cannot stack boxes in a row.
The idea is to form stacks with subrows inside rows, while the size of a row is always dominated by a highest rectangle to provide a visual anchor point to "read" the rows from left to right.
Expand All @@ -31,39 +31,39 @@ The algorithm is divided into several phases.
Same as the `box` algorithm `rectpacking` packs rectangles inside a given aspect ratio.
As a first step this problem is transformed in a strip packing problem by approximating the width.

The width can also be specified by setting a [target width](https://www.eclipse.org/elk/reference/options/org-eclipse-elk-rectpacking-targetWidth.html).
The width can also be specified by setting a [target width](https://www.eclipse.org/elk/reference/options/org-eclipse-elk-rectpacking-targetWidth.html) ) (ELK 0.9.0 [target width](https://eclipse.dev/elk/reference/options/org-eclipse-elk-rectpacking-widthApproximation-targetWidth.html)).

Different strategies can be chosen for width approximation based on which [goal](https://www.eclipse.org/elk/reference/options/org-eclipse-elk-rectpacking-optimizationGoal.html) the greedy algorithm should prioritize.
Different strategies can be chosen for width approximation based on which [goal](https://www.eclipse.org/elk/reference/options/org-eclipse-elk-rectpacking-optimizationGoal.html) (ELK 0.9.0 [goal](https://eclipse.dev/elk/reference/options/org-eclipse-elk-rectpacking-widthApproximation-optimizationGoal.html)) the greedy algorithm should prioritize.

Since the approximated width is mainly responsible for the line breaks between the rows that are formed by rectpacking, one can make sure that a rectangle is placed [in a new row](https://www.eclipse.org/elk/reference/options/org-eclipse-elk-rectpacking-inNewRow.html) (since ELK 0.9.0).

Greedy width approximation may yield the following graph:
`GREEDY` [width approximation](https://eclipse.dev/elk/reference/options/org-eclipse-elk-rectpacking-widthApproximation-strategy.html) (0.9.0) may yield the following graph:

{{< image src="scchartsregions-widthapproximation-annotated.svg" alt="Graph after width approximation." >}}



### Placement

Rectangles are placed in rows similar to the `box` algorithm. Per default the row height does not change after this step. By enabling [row height re-evaluation](TODO) (since ELK 0.9.0) the row height might change by investing more computation time.

After placement the graph looks like this:
Rectangles are placed in rows similar to the `box` algorithm. Per default the row height does not change after this step. By enabling [row height re-evaluation](https://eclipse.dev/elk/reference/options/org-eclipse-elk-rectpacking-packing-compaction-rowHeightReevaluation.html) (since ELK 0.9.0) the row height might change by investing more computation time. After placement the graph looks like this:

{{< image src="scchartsregions-placement-annotated.svg" alt="Graph after initial placement." >}}

### Compaction

After placement the rectangles are compacted to from stack with subrows inside the rows. This can also be [disabled](https://www.eclipse.org/elk/reference/options/org-eclipse-elk-rectpacking-rowCompaction.html), however, this is not recommended.
After placement the rectangles are compacted to from stack with subrows inside the rows. This can also be [disabled](https://www.eclipse.org/elk/reference/options/org-eclipse-elk-rectpacking-rowCompaction.html) (ELK < 0.9.0), however, this is not recommended.

In ELK 0.9.0 this step is part of the placement step and done via the default [`packing.strategy`](https://eclipse.dev/elk/reference/options/org-eclipse-elk-rectpacking-packing-strategy.html). Only placement can be done by setting the `packing.strategy` to `SIMPLE`.

{{< image src="scchartsregions-rectpacking-noexpand-annotated.svg" alt="graph after compaction." >}}

### Whitespace Elimination

Rectangles can [fill potential whitespace](https://www.eclipse.org/elk/reference/options/org-eclipse-elk-expandNodes.html).
Rectangles can [fill potential whitespace](https://www.eclipse.org/elk/reference/options/org-eclipse-elk-expandNodes.html) (ELK 0.9.0 [`whiteSpaceElimination.strategy`](https://eclipse.dev/elk/reference/options/org-eclipse-elk-rectpacking-whiteSpaceElimination-strategy.html) set to `EQUAL_BETWEEN_STRUCTURES`).

{{< image src="scchartsregions-rectpacking-annotated.svg" alt="graph after whitespace elimination." >}}

The drawing can also be configured to fill whitespace such that the drawing has the [desired aspect ratio](https://www.eclipse.org/elk/reference/options/org-eclipse-elk-rectpacking-expandToAspectRatio.html).
The drawing can also be configured to fill whitespace such that the drawing has the [desired aspect ratio](https://www.eclipse.org/elk/reference/options/org-eclipse-elk-rectpacking-expandToAspectRatio.html) (ELK 0.9.0 . [`whiteSpaceElimination.strategy`](https://eclipse.dev/elk/reference/options/org-eclipse-elk-rectpacking-whiteSpaceElimination-strategy.html) set to `TO_ASPECT_RATIO`).

{{< image src="scchartsregions-rectpacking-toaspectratio2.svg" alt="Whitespace eliminated to fit the aspect ratio." >}}

3 changes: 1 addition & 2 deletions docs/content/downloads/releasenotes/release-0.9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ This is mainly a bugfix release. See GitHub for the full [list of resolved issue
- [#973](https://github.com/eclipse/elk/pull/973), [#702](https://github.com/eclipse/elk/issues/702), [#794](https://github.com/eclipse/elk/issues/794), [#900](https://github.com/eclipse/elk/pull/900), [#807](https://github.com/eclipse/elk/issues/807): Moved from Java 8 to Java 11 while testing compliance with Java 17.
- [#876](https://github.com/eclipse/elk/pull/876): Renamed and reworked FORCE_MODEL_ORDER component ordering strategy to MODEL_ORDER and GROUP_MODEL_ORDER component ordering strategy.
- [#651](https://github.com/eclipse/elk/issues/651), [#885](https://github.com/eclipse/elk/pull/885): Report invalid hierarchical cross min configuration instead of fixing it.
- [#865](https://github.com/eclipse/elk/pull/865), [#835](https://github.com/eclipse/elk/pull/835): Restructure and improve rectpacking.
- [#865](https://github.com/eclipse/elk/pull/865), [#835](https://github.com/eclipse/elk/pull/835): Restructure and improve rectpacking. This includes a lot of renaming. `optimizationGoal` is renamed to `widthApproximation.optimizationGoal`, `lastPlaceShift` is renamed to `widthApproximation.lastPlaceShift`, `onlyFirstIteration` is deleted, `rowCompaction` is now the default `packing.strategy` `COMPACTION`, `packing.compaction.rowHeightReevaluation` and `packing.compaction.iterations` are added to further improve the packing compaction, `expandNodes` and `expandToAspectRatio` have been reworked into `whiteSpaceElimination.strategy`s `EQUAL_BETWEEN_STRUCTURES` and `TO_ASPECT_RATIO`, `targetWidth` is now set via `widthApproximation.targetWidth`and is enabled by setting the `widthApproximation.strategy`, the `inNewRow` option can constrain the packing, and the `tryBox` option may be set to try whether the rectangles are stackable and in the case they are not use the simpler `box` layout algorithm.


### Bugfixes
Expand All @@ -61,4 +61,3 @@ This is mainly a bugfix release. See GitHub for the full [list of resolved issue




0 comments on commit 0fa97fe

Please sign in to comment.