Optaplanner order schedule performance problem
by Mohr, Michael
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.
12 years, 3 months
Date equal comparison fails - don't understand why
by Saloojee, Karim
Hi
I am comparing SimpleAccount( dateAccountOpened == "5-Feb-2011")
where dateAccountOpened is "Sat Feb 05 00:00:00 GMT+02:00 2011" (if you
call toString()). The equal comparator fails (==) but the greater than
comparator passes (>) which I don't understand.
I feel I am missing something obvious here, but I have no idea what it
is.
rule "Test date equality"
when
$acc : SimpleAccount( dateAccountOpened == "5-Feb-2011")
then
System.out.println("Expected and found an account opened
on 5-Feb-2011: " + $acc);
end
rule "Some dates are more equal than others"
when
$acc : SimpleAccount( dateAccountOpened > "5-Feb-2011")
then
System.out.println("Unexpected match: " +
$acc.getDateAccountOpened());
end
Regards,
Karim
To read FirstRand Bank's Disclaimer for this email click on the following address or copy into your Internet browser:
https://www.fnb.co.za/disclaimer.html
If you are unable to access the Disclaimer, send a blank e-mail to
firstrandbankdisclaimer(a)fnb.co.za and we will send you a copy of the Disclaimer.
12 years, 3 months
Transaction problems in high concurrency JBPM+Drools+Hibernate instalation
by Alberto R. Galdo
Hi guys,
We have an application built around long running JBPM processes with a
large user base and high concurrency ... early on we began to have issues
with transactions in JBPM and nowadays are watching lots of different
realizations of transaction managing problems that lead to dead human tasks
( state: ERROR ), errors running processes and so on ( different
exceptions follows ):
13:22:48,261 WARN [org.drools.persistence.jta.JtaTransactionManager]
(pool-11-thread-1) Unable to commit transaction:
javax.transaction.RollbackException: ARJUNA016053: Could not commit
transaction
Caused by: javax.persistence.PersistenceException: error during managed
flush
Caused by: javax.transaction.RollbackException: ARJUNA016053: Could not
commit transaction.
at
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1177)
at
com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:117)
at
com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
at
org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:167)
at
org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:179)
[drools-persistence-jpa-6.0.0-SNAPSHOT.jar:6.0.0-SNAPSHOT]
Caused by: javax.persistence.PersistenceException:
org.hibernate.HibernateException: Flush during cascade is dangerous
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1361)
[hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289)
[hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
11:46:23,754 ERROR [stderr] (schedulerVT_Worker-8)
javax.persistence.PersistenceException: org.hibernate.HibernateException:
proxy handle is no longer valid
11:46:23,754 ERROR [stderr] (schedulerVT_Worker-8) at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1361)
11:46:23,755 ERROR [stderr] (schedulerVT_Worker-8) at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289)
11:46:23,756 ERROR [stderr] (schedulerVT_Worker-8) at
org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:261)
11:46:23,756 ERROR [stderr] (schedulerVT_Worker-8) at
So, we're running this installation by the manual. Are using JBoss 7 as
application server, it's transaction manager, Hibernate 4.x as entity
manager, our connection pool delivers READ_COMMITED connections ( so does
hibernate ) ...
Is there anything else we should be doing to avoid this transactional
problems? Has anyone ever tested JBPM in such concurrent scenario? Any
experiences?
Alberto R. Galdo
argaldo(a)gmail.com
12 years, 3 months
Scaling Drools based application
by Arul Prashanth
We have an requirement to scale the implemented Drools Rule Engine to all
states in United States. With respect to the current implementation we have
around 50 decision tables which when packaged creates a 200 MB pkg file and
another pkg around 150 MB. The request which the drools engine consumes is a
150 KB xml file which is marshalled and processed. We have a JBoss server
configured with 4 GB of memory (heap size + permGen) and works well with
processing 5 concurrent request. Any request beyond 5 leads to
OutOfMemoryException
Now we have to scale this application to process request from 45 states, so
there will be state specific pkg files (350 MB of pkg file). Each pkg is
different for each state.
With all this, do we need to increase the memory as no of states * 4 GB. Is
this assumption correct? Is there a better architecture to handle scaling of
drools application.
Any memory/performance tuning tricks would also be helpful.
-----
- Prashanth
--
View this message in context: http://drools.46999.n3.nabble.com/Scaling-Drools-based-application-tp4026...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months