How to balance the distance of vehicles?

25 views
Skip to first unread message

Kent Zhang

unread,
Jul 27, 2021, 10:24:18 PM7/27/21
to OptaPlanner development
Hello Everyone.

In the VRP example, I want to balance the distance between vehicles. That is, the distance of each vehicle is as equal as possible. How should this constraint be implemented? My constraint is as follows, but it doesn't work. Is it something I ignore? Thanks.

rule "Distance Balance"
when
        $vehicle : Vehicle()
        accumulate(
            Customer(
                getVehicle() == $vehicle,
                $toPreviousTrip : getDistanceFromPreviousStandstill());
            $totalTrip : sum($toPreviousTrip);
            $totalTrip > 0
        )
then
scoreHolder.addSoftConstraintMatch(kcontext, 1, - ($totalTrip * $totalTrip));
end




Thanks in advance!

Lukas Petrovicky

unread,
Jul 28, 2021, 2:43:12 AM7/28/21
to optapla...@googlegroups.com
Kent,


--
You received this message because you are subscribed to the Google Groups "OptaPlanner development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to optaplanner-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/optaplanner-dev/40ceec2c-6f89-4129-b95a-0bd30fcfd745n%40googlegroups.com.


--

Lukáš Petrovický

He/Him/His

Principal Software Engineer, Business Automation

Red Hat Czech, s. r. o.

lukas.pe...@redhat.com    IM: triceo/lpetrovi

Kent Zhang

unread,
Jul 29, 2021, 5:05:40 AM7/29/21
to OptaPlanner development
Got it, thank you  Lukáš  , I will look into these methods.
Reply all
Reply to author
Forward
0 new messages