Why is solving a partial puzzle much slower than generating one from scratch?
by aitchnyu
I am making a 3x3 Sudoku solver with Drools planner. The planning entities
are the digits. The problem facts are the rows (planning variable) and
columns.
When I set Drools Planner to solve a problem where no digit is initialized,
it gives a perfect solution in ~15 secs. But when I set a few digits as
initialized, it never finds a solution. It always lists 8 hard constraints
broken on termination.
I implemented the moves as:
if(digit.getFixed()==false){
moveList.add(new RowChangeMove(digit, toRow));
}
If the digit is fixed, dont make a move object for it.
Earlier, I implemented it in isMoveDoable: if the digit.getFixed() is true,
it returns false. Both do not work.
20:31:13.442 [main] INFO o.d.p.c.l.DefaultLocalSearchSolverPhase - Phase
local search finished: step total (978), time spend (60061), best score
(-8).
20:31:13.442 [main] INFO o.d.p.core.solver.DefaultSolver - Solved: time
spend (60061), best score (-8), average calculate count per second (7433).
--
View this message in context: http://drools.46999.n3.nabble.com/Why-is-solving-a-partial-puzzle-much-sl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 10 months
Is there a faster way of doing this in Drools ?
by soumya_sd
I've a use case where I need to create a rule dynamically every time the user
sends a request.
My current understanding of Drools is that you need to create a
KnowledgeBuilder and then add the rules
I'm creating the KnowledgeBase as follows.
private static KnowledgeBase readKnowledgeBase() throws Exception {
long t1 = System.currentTimeMillis();
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
long t11 = System.currentTimeMillis();
kbuilder.add(
org.drools.io.ResourceFactory.newByteArrayResource(getRule()),
ResourceType.DRL);
long t2 = System.currentTimeMillis();
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse
knowledge.");
}
long t3 = System.currentTimeMillis();
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
long t4 = System.currentTimeMillis();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
long t5 = System.currentTimeMillis();
Collection<KnowledgePackage> kpackages =
kbase.getKnowledgePackages();
for (KnowledgePackage knowledgePackage : kpackages) {
System.out.println("Package -------- " + knowledgePackage.getName());
Collection<Rule> rules = knowledgePackage.getRules();
for (Rule rule : rules) {
System.out.println("****" + rule.getName());
}
}
long t6 = System.currentTimeMillis();
System.out.println( (t11-t1) + " " + (t2-t11) + " " + ( t3-t2) + " " +
( t4-t3) + " " + ( t5-t4) + " " + ( t6-t5)+ " " );
return kbase;
}
Based on the timing logs the code take majority (more than 80%) of time in
only these two operations. Is there a way to make it faster ?
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( org.drools.io.ResourceFactory.newByteArrayResource(getRule()),
ResourceType.DRL);
thanks.
--
View this message in context: http://drools.46999.n3.nabble.com/Is-there-a-faster-way-of-doing-this-in-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 10 months
Start of Guvnor 5.4.0.CR1 results in javax.naming.NamingException
by FlyingEagle
Hi,
I try to start Guvnor 5.4.0.CR1 under JBoss 7.0.0.
I used the guvnor-5.4.0.CR1-jboss-as-7.0.war from the
guvnor-distribution-5.4.0.CR1.
The guvnor.war was deployed successfully on the app server, but when I try
to start Guvnor via Firefox, I get the following exception:
javax.naming.NamingException: Failed to get context with name comp
at
org.jboss.as.naming.context.NamespaceObjectFactory.getObjectInstance(NamespaceObjectFactory.java:71)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:283)
[:1.6.0_12]
at javax.naming.spi.NamingManager.getContext(NamingManager.java:422)
[:1.6.0_12]
at
javax.naming.spi.ContinuationContext.getTargetContext(ContinuationContext.java:38)
[:1.6.0_12]
at
javax.naming.spi.NamingManager.getContinuationContext(NamingManager.java:770)
[:1.6.0_12]
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:175)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
at javax.naming.InitialContext.lookup(InitialContext.java:392) [:1.6.0_12]
at
org.jboss.seam.transaction.DefaultSeamTransaction.getEJBContext(DefaultSeamTransaction.java:165)
[seam-transaction-3.1.0.Final.jar:]
at
org.jboss.seam.transaction.DefaultSeamTransaction.createCMTTransaction(DefaultSeamTransaction.java:132)
[seam-transaction-3.1.0.Final.jar:]
at
org.jboss.seam.transaction.DefaultSeamTransaction.getSeamTransaction(DefaultSeamTransaction.java:116)
[seam-transaction-3.1.0.Final.jar:]
It seems, that anything with naming is missing or wrong. I have read, that
Guvnor 5.4.0 uses seam 3, instead of seam 2. May that be the cause?
Or is something wrong with the xml files in \WEB-INF? I have found there
some "TODO" comments in the web.xml.
Has anybody an idea, what the problem is?
Thx for each idea
--
View this message in context: http://drools.46999.n3.nabble.com/Start-of-Guvnor-5-4-0-CR1-results-in-ja...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 10 months
Help
by seagull
Hi everyone,
I am new to drools.net and I am testing some basic commands but can't seem
to find help anywhere! I am trying to print the contents of a variable but
for some reason, the contents are not printed! The first line (i.e. hello)
on the other hand is being printed.. Is there a common mistake I may be
doing?
Thanks!
rule "testing"
when
p: Person (name == "john")
then
Console.WriteLine ("hello");
Console.WriteLine (p.name);
end
--
View this message in context: http://drools.46999.n3.nabble.com/Help-tp3812782p3812782.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 10 months
Guvnor sync issues
by devan.vanreenen@gmail.com
Hi Guys,
Please assist.
I have Guvnor running on 2 different machines.
Both Guvnors have been configured exactly the same to use Oracle for the
storing the BRMS assets. They have exactly the same repository.xml.
Because of this I am expecting that when I make changes to Guvnor on the one
machine that these changes will sync to other Guvnor instance.
Please advise what could possibly be wrong.
Regards
Devan
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-sync-issues-tp3974395.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 10 months
Getting Current Date in LHS of a rule
by sumatheja
Hi All,
Can anyone tell me if there is a variable or standard way to get
the *current date* and compare with the java.util.Date. I'm trying write
the below rule but it doesn't work. It doesn't throw any error but the rule
is not at all fired in any case
rule "new rule"
dialect "java"
when
Message(*testDate < new Date()*)
then
System.out.println("Test");
end
Do I have to insert a seperate fact which will contain the current date?
Thanks in advance.
--
cheers
Sumatheja Dasararaju
13 years, 10 months
Creating a business process programatically, Jbpm5 tutorials for beginners
by bardelman
Hi,
i m a jbpm5 beginner and i m reading the Drools Developer's Cookbook
-[Packt Publishing, Jan 2012] and on its chapter 9 :"jBPM5: Managing
,Business Processes" there is a sample project for Creating a business
process manually (creating-process-using-the-api) in i which there is an
EventNode instanciation :
EventNode eventNode = new EventNode();
eventNode.setName("EventNode");
eventNode.setId(2);
eventNode.setScope("external");
EventTypeFilter eventFilter = new EventTypeFilter();
eventFilter.setType(eventType);
eventNode.addEventFilter(eventFilter);
i want to understand what the "eventNode.setScope("external");" means and
also about filters.
i googled for the jbpm-flow-builder API but didnt find any documentation.
i dont know where to find some tuorials for these stuffs..
thnx for help !
--
View this message in context: http://drools.46999.n3.nabble.com/Creating-a-business-process-programatic...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 10 months
Complex pattern
by rcano
Hi there,
I've been struggling for almost a day now, trying to create a pattern that goes something as follows (notice it doesn't compile):
rule "Complex pattern"
when
$triviaResponse : TriviaResponseArrived($matchers: matchers)
$subscriptions : ArrayList() from collect (
$s: Subscription()
$lock: Lock(object == $s)
exists SubscriptionMatcher(matches($s)) from $matchers
)
then
logger.info("NO TRANSACTION", "Selected subscriptions " + $subscriptions);
end
where TriviaResponseArrived, contains a List of SubscriptionMatchers (a simple object which just returns true or false when its matches method is called).
Upon receiving this TriviaResponseArrived fact, I'm trying to select all subscriptions from the working memory, for which there is also a Lock, and that there exists a matcher within the matchers
list that validates it. To sum up, all subscriptions in the list subscription, should be locked, and matched by a matcher in the triviaResponseArrived fact.
The closes I've managed to come is:
rule "Complex pattern"
when
$triviaResponse : TriviaResponseArrived($matchers: matchers)
$subscription : Subscription()
$lock: Lock(object == $subscription)
exists SubscriptionMatcher(matches($subscription)) from $matchers
then
logger.info("NO TRANSACTION", "Subscription " + $subscription);
end
Which is not quite right, since I need to process all the subscription that match the above logic at once.
As always, all help is really appreciated. Thanks.
Cheers.
13 years, 10 months