Hi everyone,
I’m working on an optimization setup in Grasshopper where I’m trying to place three smaller boxes (Breps) inside a larger container Brep. I’d like to share my approach and get some advice on improving the optimization — especially with multi-objective solvers and handling discrete fitness values.
I am trying to find solution for ;
- How can I better structure these fitness functions to work with Wallacei or other multi-objective solvers?
- Are there strategies to smooth or scale discrete Boolean outputs (like Point In Brep or Brep collision) so that the solver can evolve solutions more effectively?
- Would it be better to separate containment and collision into hierarchical stages instead of simultaneous objectives?
Any insights or examples of similar setups would be greatly appreciated!
So far my experiments is below described:
1. Optimization Goals
-
Containment: All corner points of the small boxes must remain inside the container.
-
Collision-free arrangement: The small boxes should not intersect or collide with each other.
2. Fitness Functions
2.1 Containment Fitness
- Extracted all 24 corner points (8 corners × 3 boxes).
- Used Point In Brep to test if each point is inside the container.
- Converted results to numeric values:
- Inside = 1
- Outside = 0
- Used Mass Addition to count how many corners were inside.
- Normalized the result → score = (number inside) / 24, so the range is 0–1.
- Objective: Maximize (more corners inside = better).
2.2 Collision Fitness
- Tested pairwise Brep vs Brep collisions between the 3 boxes.
- For each pair:
- Collision = 1
- No collision = 0
- Summed the 3 results → total range 0–3.
- Objective: Minimize (fewer collisions = better).
3. Experiments
3.1 Using Galapagos (single-objective solver)
- Containment only:
Galapagos worked well. It successfully evolved solutions where all 24 corners were inside the container. - Containment + Collision (combined fitness):
I inverted the collision score (so “no collision” = 3) and added it to the containment score (24 corners).
→ Total fitness target = 27.Problem:
Once Galapagos reached 24 (perfect containment), it kept searching to push the fitness toward 27.
This caused the boxes to move out of the container again, leading to instability.
Essentially, Galapagos kept over-optimizing for the combined target instead of maintaining the containment goal once achieved.
3.2 Using WallaceiX (multi-objective solver)
- Tested WallaceiX with only the containment objective (ignoring collisions for now).
- Results were not significantly better than random — the optimization didn’t progress much.
- This suggests the issue might be due to the discrete nature of the fitness function (lots of 0s and 1s, few gradual transitions).
Packing.gh (35.4 KB)
