Joiner construction #1686
Replies: 2 comments 2 replies
-
Hello @jerome1968! You should look into |
Beta Was this translation helpful? Give feedback.
-
Welcome @jerome1968 ! From what I read of this issue, private Constraint demand(@NonNull ConstraintFactory constraintFactory) {
return constraintFactory.forEach(VLCCDemand.class)
.join(CrudeCarrier.class, equal(a -> a.getVlcc(), b -> b.getDestinateVLCC()))
// expand is used to avoid recomputation
.expand((vlccDemand,crudeCarrier) -> crudeCarrier.getCandidateVLCC(vlccDemand.getVlcc()))
// I am assuming null vessels are not wanted
.filter((vlccDemand, crudeCarrier, vessel) -> vessel != null)
.groupBy((vlccDemand,crudeCarrier, vessel) -> vlccDemand.getDemand(),
(vlccDemand,crudeCarrier, vessel) -> vessel,
sum((vlccDemand,crudeCarrier, vessel) ->
crudeCarrier.totalVolume(vlccDemand.getVlcc().getLocation(),
vlccDemand.getDemand().getClassification())))
.filter((demand, vessel, volume) -> volume < demand.getVolume())
.penalize(HardSoftLongScore.ONE_HARD, (demand, vessel volume) -> (int)(demand.getVolume() - volume))
.asConstraint("VLCC demand");
} If you want to filter by a property, either use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I would appreciate some advice on the modelling of the following constraint.
I have resources (crude carriers) that are carrying crude oil to large vessels (VLCC). In order t satisfy the demand from the vessel, I have to sum all the volumes (of a given oil classification) brought by all the candidate crude carriers until the vessel location in the route.
In the code below, I use a joiner that joins the vessel with demand (the facts) and the carriers that are candidate to serve that vessel. In the joiner, instead of b.getDestinateVLCC(), I would like to write something like that: b.getCandidateVLCC(a.getVlcc()) where this method will returns the vessel object itself (to perform the join sucessfully) or null depending on the capability between the two ships. Unfortunately, this not allowed in the joiner construction. If I don´t want to use the ship capability profile, is there a way to sum the quantities of all crude carriers without using any joiner?
Beta Was this translation helpful? Give feedback.
All reactions