Re: [rules-users] Existence of feasible solution for planner problem
by ge0ffrey
YuraK wrote
>
> I'm new in Drools Planner. I'm investigating the Hospital bed planning
> (PAS - Patient admission scheduling) problem,
> I'm interesting about an existence of feasible solution for the current
> problem.
>
> The idea is follow:
> 1) Doctor/User is sending a request (booking bed for patient). The drools
> planner application is checking if the feasible solution still exists
> after the adding of new problem facts.
> - if solution exists then user will retrieve a response that the request
> has been handled by the application
> - if solution doesn't exist then user will retrieve a response that the
> request can't be handled by the application
>
> 2) At the end of day the main optimization procedure is running by Drools
> Planner and all user retrieve the detail messages about the booked bed in
> the hospital (e.g information about the bed location).
>
>
> *Does it possible to check somehow (at the first stage) if the feasible
> solution exists (all hard and soft constraints are satisfied) without
> running the main(general) optimization procedure and spending a lot of
> time for the getting response ?
>
No, the problem is NP complete, which means that no algorithm in the world
today can guarantee that a feasible solution exists for an arbitrary dataset
in reasonable time.
More info for this old, 1 billion dollar question:
http://en.wikipedia.org/wiki/P_versus_NP_problem
But that doesn't mean we can't answer that question fast with good accuracy:
1) Run planner in real-time. See last part of this video:
http://vimeo.com/25902052
2) Add new data as soon as it comes in
3a) If the real-time planner finds a feasible solution, notify the user that
it's ok. Like in the video, this should be in milliseconds on seconds. There
are no false positives.
3b) If the real-time planner doesn't find a feasible solution in 5 seconds,
notify the user that it's not ok. This might be a false negative, but if
you'd let a human planner do the same task, he would output far more false
negatives.
YuraK wrote
>
> *I want to avoid the situation when the user send the request and waiting
> a lot for the response if the request has been accepted by the
> application.
>
> *Does it possible to solve the problem via termination conditions?*
> For example: after some steps of drools planner (e.g. 1000 steps) the
> score is still not a zero (not all conditions are satisfied) then can i be
> sure that feasible solution doesn't exists?
>
No (see wikipedia link above). No algorithm today will be able to answer
that with 100% accuracy in reasonable time as the problem scales out. But
given some time, planner can easily get to a 99% accuracy. How much time?
That depends on your use case: Use Planner's Benchmarker toolkit to prove by
sampling that you have such an accuracy.
YuraK wrote
>
>
> I will be appreciated if somebody provides some similar examples or ideas
> how to handle this situation.
>
> Thanks.
>
--
View this message in context: http://drools.46999.n3.nabble.com/Existence-of-feasible-solution-for-plan...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Can i see a Decision Table in Tempate (like:each row one Decision Table)
by srinivasasanda
Hi
I have a doubt Please let me know whether it is possible or not.
There is a option in guvnor create "new rule template" (here we are creating
new rule by using WHEN & THEN options), So my doubt is when i click new
rule template i want to get "Decision Table" format like
Decision table
|
|->Condition Columns
|->Action columsn
|->options
---------here decision table----------------
I want to see above options when i click new rule template.
So, If it possible means each row in template in can see one Decision Table.
Thanks,
Sanda
--
View this message in context: http://drools.46999.n3.nabble.com/Can-i-see-a-Decision-Table-in-Tempate-l...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Drools crash on simple drl
by Shur, Bob
I'm repeating this post because I didn't get an answer last time. Is this the wrong place to report a bug? If so, where is the right place? I'm trying to understand whether this is really a bug or whether I'm doing something wrong.
I have what looks to me like a Drools bug on a simple drl with declared classes. I'm using version drools-distribution-5.3.0.Final.
I'm invoking it with this:
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
List<Object> facts = new ArrayList<Object>();
ksession.execute( facts );
=============================
I get this crash:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sample/Cap
at ASMAccessorImpl_129541121334339192620.getValue(Unknown Source)
at org.mvel2.optimizers.dynamic.DynamicGetAccessor.getValue(DynamicGetAccessor.java:73)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:103)
at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:42)
at org.mvel2.MVEL.executeExpression(MVEL.java:952)
...
==========================
Here's the drl file:
package com.sample
import com.sample.*;
declare Item
id : int;
end
declare Priority
name : String;
priority : int;
end
declare Cap
item : Item;
name : String
end
rule "split cart into items"
when
then
insert(new Item(1));
insert(new Item(2));
insert(new Item(3));
end
rule "Priorities"
when
then
insert(new Priority("A", 3));
insert(new Priority("B", 2));
insert(new Priority("C", 5));
end
rule "Caps"
when
$i : Item()
$p : Priority($name : name)
then
insert(new Cap($i, $name));
end
rule "test"
when
$i : Item()
Cap(item.id == $i.id)
then
System.out.println("Cap");
end
====================
Some observations:
- If I comment out any of the insert lines, the crash goes away
- If I change the first field of class Cap to be id:int instead of item:Item and make the corresponding changes, the crash goes away
14 years
Re: [rules-users] Function call in LHS
by San
Hi
I am trying to cal a local function getMaturityAge() in the decision table
condition column like
RuleTable MaturityAge Validation
CONDITION
ACTION
pp:PremiumCalculatorFormBean
getMaturityAge() > "$1"
System.out.println("invalid maturity age");
Premium Payment Term Print out
message?
70 X
The method is defined localy using functions key word.
And moreover whenever I trying to pass pp as the argument to my functions,
its not able to find pp. I am getting cud not parse knowledge error.
can anyone pz help me out.
--
View this message in context: http://drools.46999.n3.nabble.com/Function-call-in-LHS-tp56345p3919318.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Problem with simple Fusion test case
by RobinMacharg
Hi,
I'm new to Drools (this is my first post) and am running into problems
understanding the temporal aspects of it.
I am trying to create a simple test case, using the pseudo-clock to control
time. I declare and add a number of events with different start times
(@timestamp) and durations (@duration). I'd then like to advance the
pseudo-clock by hand, calling fireAllRules() between clock-ticks. I have a
single rule that I would hope would fire on events that are 'valid', i.e.
their (start_time < clock) and their (start_time + duration > clock). I'm
seeing ALL events being picked up the first time I fireAllRules(). I'd
really appreciate an explanation of what I'm missing here.
Some code:
I have a POJO Event class:
public class Event {
public String name;
public long start;
public long dur;
//... constructor, getters, setters omitted for brevity
}
I have a .drl file with an event declaration and a single rule in it:
package myPackage.Event
import myPackage.Event
declare Event
@role( event )
@timestamp ( start )
@duration ( dur )
end
rule "events"
when
e : Event()
then
System.out.println(e.name);
end
My scaffolding creates a STREAM based, pseudo-clock configured stateful
KnowledgeSession, and reads the .drl rules using the standard code from the
examples. I create a number of Events:
Event e1 = new Event("myEvent1", 0, 1000);
Event e2 = new Event("myEvent1", 10000, 20000);
ksession.insert(e1)
... etc.
Then I fireAllRules(), advance the clock and fire them again. I'm seeing
the second event being matched on the first fireAllRules(). I'd not have
expected it to fire until the clock > 10000. I'm sure Drools is doing the
right thing, and I'm not, but I can't work out what. The examples of the
temporal operators all refer to a second event to be compared to. Also, I
can't find an example of referencing the drools system clock value (in this
case the pseudo-clock) from within a rule match section.
So, what am I doing wrong? If I can make my example clearer please let me
know.
Thanks in advance,
Robin
--
View this message in context: http://drools.46999.n3.nabble.com/Problem-with-simple-Fusion-test-case-tp...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Changes are not reflected
by ponmanirajan
hi ,
i have the changeset file as below for scanning the directory of drl
files.
<change-set xmlns="http://drools.org/drools-5.0/change-set"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...">
<add>
<resource source="file:/D:/users/myrules" type="DRL"/>
</add>
</change-set>
Here, i have my agent configuration code.
KnowledgeAgentConfiguration kaconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
kaconf.setProperty( "drools.agent.scanDirectories","true" );
kaconf.setProperty( "drools.agent.newInstance","false" );
kagent =KnowledgeAgentFactory.newKnowledgeAgent( "test agent", kaconf );
System.out.println("Before Applying ChangeSet");
kagent.applyChangeSet(ResourceFactory.newFileResource("D:/users/ChangeSet.xml"));
System.out.println("After Applying Change Set");
ResourceChangeScannerConfiguration sconf =
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty("drools.resource.scanner.interval", "5");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
It loads the drl files. But when i made changes to a drl file, it is not
reflected.
can anyone help me to find out the solution .
thanks in advance....
--
View this message in context: http://drools.46999.n3.nabble.com/Changes-are-not-reflected-tp3917286p391...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
"java.lang.AbstractMethodError: org.jbpm.marshalling.impl.ProcessMarshallerImpl.init" while unmarshalling statefulknowledgesession
by sumatheja
Hi All,
I ran across an issue while unmarshalling StatefulKnowledgeSession.
First I'm marshalling the session using the following code which works fine
Marshaller marshaller = MarshallerFactory
.newMarshaller(workingMemory.getKnowledgeBase());
File file = new File(
"C:\\Users\\Sumatheja\\workingmemory.info");
FileOutputStream fos = new FileOutputStream(file);
ByteArrayOutputStream baos = new
ByteArrayOutputStream();
marshaller.marshall(baos, workingMemory);
baos.writeTo(fos);
baos.close();
When I try to unmarshall the session using
Marshaller marshaller = MarshallerFactory
.newMarshaller(workingMemory.getKnowledgeBase());
FileInputStream fis = new
FileInputStream("C:\\Users\\Sumatheja\\workingmemory.info");
workingMemory = marshaller.unmarshall(fis);
I'm getting the Error:
java.lang.AbstractMethodError:
org.jbpm.marshalling.impl.ProcessMarshallerImpl.init(Lorg/drools/marshalling/impl/MarshallerReaderContext;)V
at
org.drools.marshalling.impl.PersisterHelper.buildRegistry(PersisterHelper.java:287)
at
org.drools.marshalling.impl.ProtobufInputMarshaller.loadAndParseSession(ProtobufInputMarshaller.java:219)
at
org.drools.marshalling.impl.ProtobufInputMarshaller.readSession(ProtobufInputMarshaller.java:152)
at
org.drools.marshalling.impl.ProtobufMarshaller.unmarshall(ProtobufMarshaller.java:117)
at
org.drools.marshalling.impl.ProtobufMarshaller.unmarshall(ProtobufMarshaller.java:86)
at
mattelli.re.ComplianceEngine.ComplianceRunService(ComplianceEngine.java:271)
at mattelli.re.ComplianceEngine.main(ComplianceEngine.java:84)
No Idea what I'm missing out... any help will be appreciated... Thanks in
advance
--
cheers
Sumatheja Dasararaju
14 years
Planner: weighting moves & adaptive foragers
by Christopher Dolan
Three related questions about Drools Planner:
My planning problem involves distributing N jobs into M job queues. The optimal queue ordering depends on a large number of factors, but most important are job priority and job age. Priority usually wins, but old jobs can trump to avoid starvation.
If N x M is large, the collection of possible moves becomes large. But I know a priori that some moves are more likely to help than others. For example, I can promote the high-priority and old jobs first, because they will have the largest score impact.
1) Can I weight the selector to pick the better moves first? It looks like I'd make a custom AbstractSelector subclass that shuffled differently from MoveFactorySelector, maybe lazily finding moves via a pick function.
Of course, selecting better moves first is worthless if the forager doesn't use shortcuts, like FIRST_BEST_SCORE_IMPROVING. But the existing AcceptingForager implementation is very binary: it either takes the first good score or it ignores score and waits for a total number of moves.
2) Has anyone built a generic Forager that looks at the distribution of scores and stops early if it finds a fantastic outlier? In particular, early in the solver there are lots of very easy improvements to make. Taking the first good one may be premature, but going through 1000 moves is a waste of time. I'd like a forager that just tries a few moves early and then tries more moves later on when it's harder to make gains. On the other hand, is putting a lot of work into a perfect forager just redundant with the acceptor?
3) Has anyone employed the undocumented TopListSelector? I'm intrigued that it feeds the forager's best moves back into the selector. How does it work? I think you need to combine it with a move factory to seed the solutions, but then it's redundant with that factory's output. Are selectors allowed to return the same move twice??
Chris
14 years
Guvnor Rest API
by Amin Mohammed-Coleman
Hi
I am trying to use the Guvnor Rest API to upload rules and BPMN process definitions to a remote Guvnor installation. So far I am able to update the binary content of the asset using:
/drools-guvnor/rest/packages/myPackage/assets/myAsset/binary
However when I look at the history for the asset, the current version does not point to the version I have uploaded using the API. Is there a separate API I have to call in order to set the current version to be the one I've uploaded or is there an example which I can reference?
I'm using Guvnor 5.4.0-CR1
Any help would be appreciated.
Thanks
14 years