Skip to content

Commit 609c08a

Browse files
committed
Adding another merit type, improving max density objective
1 parent 63f78b5 commit 609c08a

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

SC.ObjectModel/Additionals/ContainerInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public ContainerInfo(COSolution solution, Container container)
2929
/// <summary>
3030
/// The container which this info is tracking.
3131
/// </summary>
32-
private Container Container { get; set; }
32+
internal Container Container { get; private set; }
3333

3434
/// <summary>
3535
/// The volume packed inside of the container.

SC.ObjectModel/Additionals/MeritType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,10 @@ public enum MeritFunctionType
5050
/// Aims to minimize packing height
5151
/// </summary>
5252
H,
53+
54+
/// <summary>
55+
/// Aims to minimize packing height while aiming for fewer containers (Reduce-Height-Reduce-Container)
56+
/// </summary>
57+
RHRC,
5358
}
5459
}

SC.ObjectModel/Additionals/Objective.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,14 @@ public double Value
4242
return
4343
-Solution.OffloadPieces.Count * _heightBigM * 2
4444
- Solution.ContainerInfos.Count(c => c.NumberOfPieces > 0) * _heightBigM
45-
+ Solution.ContainerInfos.Where(c => c.NumberOfPieces > 0).MinOrDefault(c => c.PackingHeight) / _heightBigM;
45+
- Solution.ContainerInfos.Where(c => c.NumberOfPieces > 0).Sum(c => c.Container.Mesh.Height - c.PackingHeight);
4646
}
4747
default:
4848
throw new ArgumentException($"Unknown objective type: {Solution.Configuration.Objective}");
4949
}
5050
}
5151
}
5252

53-
54-
55-
5653
/// <summary>
5754
/// The volume packed inside of the containers.
5855
/// </summary>

SC.ObjectModel/COSolution.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,13 @@ public double ScorePieceAllocation(Container container, VariablePiece piece, int
11771177
score += position.Z + piece[orientation].BoundingBox.Height;
11781178
}
11791179
break;
1180+
case MeritFunctionType.RHRC:
1181+
{
1182+
var newHeight = Math.Max(position.Z + piece[orientation].BoundingBox.Height, ContainerInfos[container.VolatileID].PackingHeight);
1183+
var newVolume = ContainerInfos[container.VolatileID].VolumeContained + piece.Volume;
1184+
score += newVolume / (container.Mesh.Length * container.Mesh.Width * newHeight) + ContainerInfos[container.VolatileID].NumberOfPieces > 0 ? 1 : 0;
1185+
}
1186+
break;
11801187
case MeritFunctionType.None:
11811188
default:
11821189
break;

0 commit comments

Comments
 (0)