I made an optaplanner rule (see below).
//in expressway long tunnel(over 1km), equipment interval(400m)
rule "lcs_transport_tunnel_expway"
when
$road : RoadVO(roadCtgry=="EXPWAY")
$t1 : Transport(transportCode=="TUNNEL", $direction:direction,
Math.abs(mileageBegin-mileageEnd)>1000,
$mileageBegin:mileageBegin, $mileageEnd:mileageEnd )
$e0 : ItsEquipment(itsClass=="LCS", direction==$direction,
mileage >$mileageBegin && <$mileageEnd, $id:id, $mileage:mileage)
$e1 : ItsEquipment(itsClass== "LCS", direction==$direction, id==$id+1,
mileage==$mileage+400 )
then
scoreHolder.addSoftConstraintMatch(kcontext, 1000);
end
While optaplanner is solving, $e1 is not properly chosen.
What is the problem?
Please let me know. Thanks.
(without knowing what the desired result is, it's hard to answer this, but here goes... :)
The 2 selected
ItsEquipment
's don't constraint that they belong to the original selectedTransport
(or even the sameTransport
). They only need to belong to the samedirection
. Is that your intent?The
$e1
selection hasid==$id+1
andmileage==$mileage+400
. If your id's are unique, any other condition besidesid==$id+1
is pointless (includingmileage==$mileage+400
).