Optaplanner: Unexpected global [scoreHolder]
by jonathan.labin
I am using Optaplanner 6.0.0-Beta2 and I am in some cases receiving the
following error during initial solution construction:
Exception in thread "main" java.lang.RuntimeException: Unexpected global
[scoreHolder]
at
org.drools.core.common.AbstractWorkingMemory.setGlobal(AbstractWorkingMemory.java:515)
at
org.drools.core.impl.StatefulKnowledgeSessionImpl.setGlobal(StatefulKnowledgeSessionImpl.java:360)
at
org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.resetKieSession(DroolsScoreDirector.java:83)
at
org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.setWorkingSolution(DroolsScoreDirector.java:74)
at
org.optaplanner.core.impl.solver.scope.DefaultSolverScope.setWorkingSolutionFromBestSolution(DefaultSolverScope.java:176)
at
org.optaplanner.core.impl.solver.DefaultSolver.solvingStarted(DefaultSolver.java:176)
at
org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:154)
I noticed this error in gist:
https://gist.github.com/ge0ffrey/5236604
If this is the same error, what are the current constraints that I need
adhere to in order to avoid this error?
Jon
--
View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-Unexpected-global-scoreHold...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years
using Drools in Tomcat 6.0 enviourment
by Erez Zarini
Hi,
I am new to Drools.
I have successfully created a project from the Examples provided at the site
using Java APP project.
but when trying to move it as a Dynamic Web Project in Eclipse I get the
following Exception:
(the files kmodule and pom.xml resides in all subfolders of the project)
21/11/2013 15:49:42 org.drools.compiler.kie.builder.impl.ClasspathKieProject
discoverKieModules
INFO: Found kmodule:
file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/DecisionTableGvia/WEB-INF/classes/META-INF/kmodule.xml
21/11/2013 15:49:43 org.drools.compiler.kie.builder.impl.ClasspathKieProject
getPomProperties
WARNING: Unable to load pom.properties tried recursing down
from/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/DecisionTableGvia/WEB-INF/classes
null
21/11/2013 15:49:43 org.drools.compiler.kie.builder.impl.ClasspathKieProject
discoverKieModules
SEVERE: Unable to build index of kmodule.xml
url=file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/DecisionTableGvia/WEB-INF/classes/META-INF/kmodule.xml
null
[]
21/11/2013 15:49:43 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet getDecisionGvia threw exception
java.lang.NullPointerException
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.newStatelessKieSession(KieContainerImpl.java:360)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.newStatelessKieSession(KieContainerImpl.java:351)
at
gvia.PricingRuleDTExample.executeExample(PricingRuleDTExample.java:39)
at gvia.PricingRuleDTExample.main(PricingRuleDTExample.java:32)
at gvia.getDecisionGvia.doGet(getDecisionGvia.java:33)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Unknown Source)
when running as a Java project (not Java EE) it seems to work find and
continues to find pom.xml instead of pom.properties.
any ideas?
--
View this message in context: http://drools.46999.n3.nabble.com/using-Drools-in-Tomcat-6-0-enviourment-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years
Optaplanner rules NullPointerException
by ns
Hi,
I am trying to accomplish the following, a part time employee (eg 50%) needs
to do only half the shifts a full time employee needs to do. I have created
a rule, that
1. count number of shifts of certain shiftType
2. count number of shifts of a certain shiftType per employee
3. count the total number of "arbeidsbreuken" per employee and within a
certain shiftType
4. do something with these numbers so that an part time employee only gets
half the shifts assigned that a full time employee gets
The complete rule is:
rule "arbeidsbreuk"
when
//System.out.println("arbeidsbreuk, Drools!");
ShiftAssignment($employee : employee, $shiftType : shiftType)
//count aantal shifts
$assignmentTotal : Number() from accumulate(
$assignment : ShiftAssignment(shiftType == $shiftType),
count($assignment)
)
//count aantal shifts per medewerker
$assignmentTotalEmployee : Number() from accumulate(
$assignmentEmployee : ShiftAssignment(employee == $employee,
shiftType == $shiftType),
count($assignmentEmployee)
)
//count arbeidsbreuken van alle medewerkers
$arbeidsbreukTotal : Number() from accumulate(
//Employee($breuk : arbeidsbreuk),
ShiftAssignment(employee == $employee, shiftType == $shiftType),
sum($employee.getArbeidsbreuk())
)
$assignmentTotalEmployee.intValue())
then
System.out.println("Arbeidsbreuk drools: " +
$employee.getArbeidsbreuk() + " - " + $assignmentTotal.intValue() + " - " +
$assignmentTotalEmployee.intValue() + " - " + $arbeidsbreukTotal);
scoreHolder.addSoftConstraintMatch(kcontext,
-(Math.abs(($employee.getArbeidsbreuk() * $assignmentTotal.intValue()) -
$assignmentTotalEmployee.intValue()) *
(Math.abs(($employee.getArbeidsbreuk() * $assignmentTotal.intValue()) -
$assignmentTotalEmployee.intValue()))) );
end
I get the following error:
Exception in thread "main" org.drools.core.RuntimeDroolsException:
java.lang.NullPointerException
at org.drools.core.rule.Accumulate.accumulate(Accumulate.java:182)
at
org.drools.core.phreak.PhreakAccumulateNode.addMatch(PhreakAccumulateNode.java:756)
at
org.drools.core.phreak.PhreakAccumulateNode.doLeftInserts(PhreakAccumulateNode.java:164)
at
org.drools.core.phreak.PhreakAccumulateNode.doNode(PhreakAccumulateNode.java:81)
at
org.drools.core.phreak.RuleNetworkEvaluator.switchOnDoBetaNode(RuleNetworkEvaluator.java:524)
at
org.drools.core.phreak.RuleNetworkEvaluator.evalBetaNode(RuleNetworkEvaluator.java:494)
at
org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:277)
at
org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:161)
at
org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:116)
at
org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:205)
at
org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:65)
at
org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:936)
at
org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1183)
at
org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:935)
at
org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:909)
at
org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:233)
at
org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.calculateScore(DroolsScoreDirector.java:98)
at
org.optaplanner.core.impl.solver.scope.DefaultSolverScope.calculateScore(DefaultSolverScope.java:101)
at
org.optaplanner.core.impl.bestsolution.BestSolutionRecaller.solvingStarted(BestSolutionRecaller.java:58)
at
org.optaplanner.core.impl.solver.DefaultSolver.solvingStarted(DefaultSolver.java:177)
at
org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:154)
at be.ocmwturnhout.permanenties.Main.main(Main.java:495)
Caused by: java.lang.NullPointerException
at
be.ocmwturnhout.permanenties.solver.Rule_arbeidsbreuk654888368.accumulateExpression2(Rule_arbeidsbreuk654888368.java:23)
at
be.ocmwturnhout.permanenties.solver.Rule_arbeidsbreuk654888368AccumulateExpression2Invoker.evaluate(Rule_arbeidsbreuk654888368AccumulateExpression2Invoker.java:25)
at
org.drools.core.base.accumulators.JavaAccumulatorFunctionExecutor.accumulate(JavaAccumulatorFunctionExecutor.java:107)
at org.drools.core.rule.Accumulate.accumulate(Accumulate.java:173)
... 21 more
Any idea how I can solve this? Thanks.
Kind regards,
Nick
--
View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-rules-NullPointerException-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years
How to deal with doubles in Optaplanner drools rules
by ns
Hi,
I am having trouble dealing with doubles in the Optaplanner drools rule drl
file. See error message below.
Exception in thread "main" java.lang.IllegalStateException: There are errors
in the scoreDrl's:
Error Messages:
Message [id=1, level=ERROR,
path=optaplanner-kie-namespace//be/ocmwturnhout/permanenties/solver/permanentiesScoreRules.drl,
line=96, column=0
text=Rule Compilation error The method
addSoftConstraintMatch(RuleContext, int) in the type HardSoftScoreHolder is
not applicable for the arguments (RuleContext, double)]
I have the following then rule part:
scoreHolder.addSoftConstraintMatch(kcontext, -(10 *
Math.abs(($employee.getArbeidsbreuk() * $assignmentTotal.intValue()) -
$assignmentTotalEmployee.intValue())) * (10 *
Math.abs(($employee.getArbeidsbreuk().intValue() *
$assignmentTotal.intValue()) - $assignmentTotalEmployee.intValue())) );
$employee.getArbeidsbreuk() is a double.
Aren't doubles allowed or can I convert it? Thanks.
Kind regards,
Ncik
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-deal-with-doubles-in-Optaplanner...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years
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.
11 years