Scheduling Application and Optaplanner
by marchias
Just started researching OptaPlanner. Loaded examples in Eclipse and got them
running. I'm interested in extending the Nurse rostering example to work
with a scheduling application I have written. I have some interesting
constraints though that wanted to reach out to the community with to make
sure they can be accomodated. My scheduling app has a hierachical entity
setup with Organizations and child locations. An employee can be configured
to work at multiple locations and are also assigned a "Primary" location
which means they should be picked up on shifts at that location before an
employee that does not have that location as primary. Also I have a priority
group or ranking (1-10) which would be considered in sorting employees as
well. Shifts are location, date/time and skill specific with a configured
amount of resources needed.
Shift Examples
Location 1 = 2 nurses, (Monday Wednesay Friday), 7AM - 11PM
Location 1 = 1 nurse, (Sunday,Tuesday,Thursday,Saturday), 7AM - 11PM
Constraints for an employee
Max Hours/Week: 0.00
Min Hours/Week: 0.00
Max Hours/Day: 0.00
Min Hours/Day: 0.00
Max Days/Week: 0.00
Max Consecutive Days: 0.00
Max Shifts/Day: 0.00
Max Shifts/Month: 2.00
Max Weekend Shifts/Month 0.00
Max Consecutive Shifts of Duration 0.00 consecutive 0.00 hr shifts
--
View this message in context: http://drools.46999.n3.nabble.com/Scheduling-Application-and-Optaplanner-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
decision and prediction based on the same set of rules
by Sean Su
Our rules will be using "Date" heavily when making decisions. When the LHS
involving dates is evaluated "true", decision will be made.
Meanwhile, from prediction point of view, we want to know when the LHS
would be evaluated to false, with the changes made to the date fields
(forward to the future). Therefore this becomes prediction - what is the
future date that would cause the LHS to be false.
Question to the list:
has anyone explored the possibility of using the same set of rules to
achieve both tasks?
If there is no tools automatically doing this in Drools (I doubt there is),
I am thinking to build a tool to parse the rules and then auto-generate the
prediction rules based on the "decision" rules. Is this the right direction?
Any inputs will be appreciated.
thanks
Sean
12 years, 7 months
uninformative rule parsing/compiling error -> org.drools.rule.Rule cannot be cast to org.drools.rule.Query
by De Rooms Brecht
Dear rules users,
I am currently writing my own Drools-server since I wanted more control
than the drools-execution server (and it never worked very well here)
where I can send rules/facts over JMS/AQMP/STOMP. Rules which are sent
are saved on the server-side in DRL files that are monitored. That way,
I can debug easily by changing the sent files. However, when I sent the
following code, the agent does not provide me with an error message at
all and hangs:
/
//rule "TrackerRemote.TrackerUpdate"//
// when//
// message:TrackerRemote.TrackerUpdate()//
// then//
// System.out.println("Tracker: " + message);//
//end/
at first I thought it was because TrackerRemote.TrackerUpdate is not in
that package anymore and thus unknown so I tried to send the rule listed
below which gives me the nice and expected error:
Unable to resolve ObjectType 'NotExistingType' : [Rule name='Foo']
/rule "Foo"//
// when //
// NotExistingType( bloe == "test")//
// then//
// System.out.println("this should not work");//
//end/
when I compile the rule myself with a KnowledgeBuilder:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
InputStream is = new ByteArrayInputStream(drlstring.getBytes());
kbuilder.add( ResourceFactory.newInputStreamResource(is),ResourceType.DRL );
I receive the error:
org.drools.rule.Rule cannot be cast to org.drools.rule.Query
which I think doesn't tell me anything about the mistake I made in my
rule, is this a Drools bug and should I post this somewhere?
Kind Regards,
De Rooms Brecht
Full Stack:
java.lang.ClassCastException: org.drools.rule.Rule cannot be cast to
org.drools.rule.Query
at
org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:175)
at
org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:118)
at
org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:67)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:84)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2706)
at
org.drools.compiler.PackageBuilder.compileRules(PackageBuilder.java:930)
at
org.drools.compiler.PackageBuilder.compileAllRules(PackageBuilder.java:839)
at
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:831)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:467)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:673)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:45)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:34)
at
derooms.be.server.listeners.RulesListener.processMessage(RulesListener.java:33)
at
derooms.be.server.listeners.AbstractListener.onMessage(AbstractListener.java:35)
at
org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1321)
at
org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:131)
at
org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:202)
at
org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:129)
at
org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:47)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
12 years, 7 months
NullPointerException when updating a fact
by schenka7
Hi dear drools team,
I've got a strange problem and hope someone can help me. I'm using drools
5.5.0.
I have some rules to validate user input. These will set the valid flag on a
fact to false and insert a Message fact into working memory that will
contain a message and a reference to the causing fact.
I also have a rule to retract Messages for facts which are not invalid
anymore.
I observe a NullPointerException originating at
DefaultAgenda.createActivation() when I perform following steps:
Insert a valid FirstName and call session.fireAllRules().
Change the FirstName to become invalid, call session.update() on it and call
session.fireAllRules().
The rule for retracting messages is the cause for the problem.
My question is, how can I fix it? Or is there a better way to manage error
messages?
Thank you
--
View this message in context: http://drools.46999.n3.nabble.com/NullPointerException-when-updating-a-fa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Controlling Rule Execution
by jking527467
All,
I'm new to Drools and I'm faced with what seems to be a pretty trivial task
that's taken a lot longer than expected.
I'm working mainly with distances and am looking for an plain English
response to this trivial problem.
Here's the problem:
- Activate all things within x miles.
- If nothing is within x miles, activate all things within y miles.
It seems pretty straight forward but here's my dilemma. If I execute on y
miles first, everything within x miles will also be activated. I need to
ensure the things between x and y miles aren't activated if anything is
within x miles of a certain fact.
Does this make any sense to anyone? I'm have a hard time grasping the
proper approach and have looked into activation groups, etc. but haven't had
any luck.
Any help is GREATLY appreciated!!!
Thanks in advance!
Jason
--
View this message in context: http://drools.46999.n3.nabble.com/Controlling-Rule-Execution-tp4025231.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
How to Call RuleFLow from Servlet
by josh
Drools 5.0
Server Tomcat
I am not able to call RuleFlow from servlet. It doesn’t throw any error, nor
shows the output. However I am able to call single rule(SampleRule.drl.DRL).
Below is the snapshot for the same.
/private RuleBase readRule() throws Exception {
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(new InputStreamReader(
TestServlet1.class.getResourceAsStream( "/com/sample/SampleRule.drl" ) ) );
builder.addRuleFlow( new
InputStreamReader(TestServlet1.class.getResourceAsStream(
"/com/sample/sampleruleflow.rf" ) ) );
Package pkg = builder.getPackage();
// add the package to a rulebase (deploy the rule package).
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(pkg);
return ruleBase;
}
/
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-Call-RuleFLow-from-Servlet-tp402...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Any API accessing to the rule logic instead of only Facts
by Sean Su
Does anyone know a public Drools API that we can use to access to the
actual rule logic in a structured way? Current we can use
AgendaEventListener and WorkingMemoryEventListener to access the facts
using in LHS and the objects used in RHS. But my project has some special
requirements which need to access the actual rule logic on LHS for auditing
and justification purpose.
For example, if a rule is like this:
when fact.list contains "123"
then do something.
When this rule is fired, not only do I need to know what the fact object
is, I also need to know the condition of this rule is involved a "contains"
API, with value "123".
Thanks in advance.
Sean
12 years, 7 months
Questions On Rule Flow
by josh
I am from WODM background and have a question on rule flow
1). Why do I need to add all the rules or decision tables to the
KnowledgeBuilder object? I have created rule flow with multiple task (rule
task # 1 for myRule1.drl, rule task # 2 for myTable.xls). Shouldn’t it take
all the elements from the rule task automatically that has been added to the
rule flow like WODM does?
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
DecisionTableConfiguration config =
KnowledgeBuilderFactory.newDecisionTableConfiguration();
config.setInputType(DecisionTableInputType.XLS);
kbuilder.add(ResourceFactory.newClassPathResource("myRule1.drl",myClas.class),
ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("myTable.xls"),ResourceType.DTABLE,
config);
kbuilder.add(ResourceFactory.newClassPathResource("myRuleFlow.rf",myClas.class),
ResourceType.DRF);
2). Why do I need to give ‘RuleFlowGroup” in my decision table. If I am
executing table it should execute all the rows based on their condition?
What is the usage of RuleFlowGroup?
3). What is the benefit of using reusable Subtask within rule flow?
Thanks in Advance
--
View this message in context: http://drools.46999.n3.nabble.com/Questions-On-Rule-Flow-tp4025223.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
IntelliFest 2013 (San Diego) - only 10 weeks to go
by Mark Proctor
http://blog.athico.com/2013/07/intellifest-2013-san-diegl-only-10.html
----
Here is the updated flyer for IntelliFest 2013, this October in San Diego. Dr. Ernest Friedman-Hill, the creator ofJess, will be there talking about the new Jess 8.0 release. Also Dr. Daniel Miranker, the creator of the Leaps algorithm (a lazy alternative to the Rete algorithm), will be there talking about web scale distributed pattern matching.
I'll also be there presenting my new algorithm, entitled "From Eager to Lazy : The Evolution of the Rete Algorithm
12 years, 7 months
Why the drools modified object does not reflect the changes when I call the remote web service?
by Nuwan Bandara
When I use the local drools rules instance, object gets updated and
reflects the changes accordingly but when I use the remote web service call
to use the remote drools engine, rules get executed correctly but updated
values does not get reflected back in the return object.
Environment into:
- JBoss 5
- Uses XLS decision table for the drools rules file
- Front end uses jbosseap5 and back-end users JBoss 5
Currently I have drools engine running on front end server (referred as
local) and back-end server (referred as remote) both. When I call the local
drools engine it works. But when I call the remote server through REST web
server function get executed correctly but updated values are not in the
object when it comes back to the front end.
Here’s the function that I use in the decision table (.xls)
function boolean setCTCFlag(Object resultViewMapObj, String siteCode){
boolean flag = false;
Map<String, ResultView> resultViewMap = (Map<String, ResultView>)
resultViewMapObj;
List<ResultView> resultViewList = new ArrayList<ResultView>();
resultViewList = new ArrayList<ResultView> (resultViewMap.values());
ResultView resultView = new ResultView();
resultView = resultViewList.get(0);
if(resultView.getSampleView().getSample() != null){
String sampleInd =
resultView.getSampleView().getSample().getSampleIndicator();
if(sampleInd != null && sampleInd.length() != 0){
String[] sampleIndComp = sampleInd.split(""[^\\w\\s]"");
for(int i = 0; i<sampleIndComp.length; i++){
LabelValueView labelValueView = new
LabelValueView();
labelValueView.setLabel(sampleIndComp[i].trim());
labelValueView.setValue(" ");
// DOTO: this is the issue
// folowing line gets executed but changes do
not get reflected in the object.
// Only happens when this called remotely.
resultView.getDynamicFields().put("CTC_CLIENT_FLAG", labelValueView);
flag = true;
}
}
}
return flag;
}
12 years, 7 months