[rules-users] Optaplanner order schedule performance problem

Mohr, Michael Michael.Mohr at koehl.eu
Wed Nov 20 11:32:51 EST 2013


Hi,

I must find start and end times for orders on different equipment's in requirement of a stock.
What can I do better to get faster a solution.

I read the forum entries but it don't helps.
- Scheduling events with varying durations - corrupted score
- Time Slots vs Time Periods
Graphics and detail description in the pdf.


Domain model

@PlanningEntity
EquipmentAllocation has a Equipment
EquipmentAllocation has a Order
EquipmentAllocation has a TimeSlot
------------------------------------------------------
@PlanningVariable
Order
Attribute: quantity
------------------------------------------------------
TimeSlot
Attribute: startTime, endTime, duration, sequenceNumber
------------------------------------------------------
Material
Attribute: stock, minStock, maxStock
------------------------------------------------------
Material Demand has a TimeSlot
Attribute: quantity
------------------------------------------------------

Conditions:
-        Order is executable on each equipment.
-        Orders has different sizes.
-        Order running time is depending of the material and the equipment.
-        Gaps between orders are possible if there is no demand.
-        Gaps between orders are possible when there is a equipment setup time.
-        Parallel orders with same material on different equipment's are possible.

Target:
-        Calculate start and endtims for an order.
-        Start and endtime is precisely one minute (maximum five minutes if runtime is to long).
-        Satisfy only the demand of a material.
-        Good result in 5 minutes.
-        No exceed min or max stock.

Plan data:
-        Plan for 24 hours.
-        Plan 35 orders (normal order time is 2 hours).
-        Plan 5 demands with different materials (7 orders per demand).
-        Plan 3 equipment's.

Problem:
-        No result in 5 minutes.
-        Concept with timeslots has to many possible order positions.
-        No restrictions are possible to find the best solution.

Use a pillar swap to create the possible order positions on each equipment.
Use a pillar swap to lay the order over a lot of timeslots on a equipment.

Example:
-        1 order (with 2 hours)
-        1 equipment
-        24 hours planning time with 1 timeslot per minute
-        Possible order positions = 22 * 60 = 1320 (on one equipment)
-        Possible order positions = 1320 * 3 = 3960 (on three equipment)
-        Possible order positions = 3960 * 35 = 138.600 (all orders on all equipment)


rule "Check order not allocate to less."

        when
                $f : Order( $quantity : quantity , $m : material )

                $result : Number( (intValue > 0) && ( intValue < $quantity ) )
                from accumulate(
                        EquipmentAllocation( order != null && order == $f , $sp : equipment.speedMap ),
                         sum($sp.get($m))
                )
        then
                int hard = $result.intValue() - $quantity;
                scoreHolder.addHardConstraintMatch(kcontext, hard );
end


rule "Check order not allocate to many."

        when
                $f : Order( $quantity : quantity , $m : material )

                $result : Number( (intValue > 0) && ( intValue > $quantity ) )
                from accumulate(
                        EquipmentAllocation(order != null && order == $f , $map : equipment.orderMap )
                        sum( $map.get( $f ))
                )
        then
                int hard = $quantity - $result.intValue();
                scoreHolder.addHardConstraintMatch(kcontext, hard );
end


rule "Check demand"

        when
                $m : Material( $stock : stock )

                $t : TimeSlot( $sequence : sequence )

                $sumDemand : Number( )
                from accumulate (
                         Demand ( timeSlot.sequence <= $sequence , material == $m , $quantity : quantity )
                   sum( $quantity )
                )

                $sumAllocation : Number( ($stock + intValue - $sumDemand.intValue()) < 0 )
                from accumulate (
                         EquipmentAllocation( (order != null && order.material == $m) , timeSlot.sequence <= $sequence , $sp : equipment.speedMap),
                        sum( $sp.get($m) )
                )
        then
                scoreHolder.addHardConstraintMatch(kcontext,  -1);
end


rule "Check min stock"

        when
                $m : Material( $stock : stock , $minStock : minStock, $maxStock : maxStock )

                $t : TimeSlot( $sequenceT : sequence )

                $sumDemand : Number( )
                from accumulate (
                         Demand ( timeSlot.sequence <= $sequenceT , material == $m , $quantityDemand : quantity )
                   sum( $quantityDemand )
                )

                $sumAllocation : Number( ($stock + (intValue) - $sumDemand.intValue()) < $minStock )
                from accumulate (
                         EquipmentAllocation( order != null , order.material == $m , timeSlot.sequence <= $sequenceT , $sp : equipment.speedMap ),
                        sum( $sp.get($m) )
                )
        then
                scoreHolder.addHardConstraintMatch(kcontext,  -1);
end


rule "Check max stock"

        when
                $t : TimeSlot( $sequence : sequence )

                $m : Material( $stock : stock , $maxStock : maxStock )

                $sumDemand : Number( )
                from accumulate (
                         Demand ( timeSlot.sequence <= $sequence , material == $m, $quantityDemand : quantity)
                   sum( $quantityDemand )
                )

                $sumAllocation : Number( ($stock + intValue - $sumDemand.intValue()) > $maxStock )
                from accumulate (
                         EquipmentAllocation( (order != null && order.material == $m) , timeSlot.sequence <= $sequence , $sp : equipment.speedMap ),
                        sum( $sp.get($m) )
                )
        then
                scoreHolder.addHardConstraintMatch(kcontext,  -1);
end

Gruß

Michael Mohr
Software Engineer



________________________________
CONFIDENTIALITY : This e-mail and any attachments are confidential and may be privileged. If you are not a named recipient, please notify the sender immediately and delete the e-mail from your system. You are not authorized to disclose the contents to another person, to use it for any purpose or store or copy the information in any medium.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20131120/4ab1133e/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OrderScheduleWithStock.pdf
Type: application/pdf
Size: 285898 bytes
Desc: OrderScheduleWithStock.pdf
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20131120/4ab1133e/attachment-0001.pdf 


More information about the rules-users mailing list