Re: [rules-users] Drools-solver -- solution questions
hi you could use a solution taboo, on all solutions found so far and let the solver solve again. the problem is that you never know when to stop this algorithm. that is, when you found the last valid solution. but you could stop the solver after a certain amount of time and decide that you have all solutions. best, tim On Wed, Feb 4, 2009 at 11:36 PM, Andrew Waterman wrote: > Hello, > > I'm starting to work with the drools-solver to help on a gaming project. > Basically, we have a game that works in two modes: 1) a competitive game > where humans (or agents) compete with one another on a well defined game > board to achieve 24 points by using three (or four) agricultural development > tokens. 2. A puzzle, where all 4 players work cooperatively to create an > equitable solution, where all 4 players win with at least 24 points by means > of our agricultural development tokens. > > I am starting to work with drools-solver to address the puzzle part of our > game. Basically, we are interested in having the solver do two things for > us: a) find the optimal solution for our game/puzzle, based upon our > requirements [this part seems quite straightforward] and b) getting the > total number of solutions that satisfy our constraints. We would like, as > well, to be able to inspect these other, sub-optimal, solutions, in order to > explore our game and puzzle further. From my reading of the "Solver" API , > it looks like we will only be able to get the optimal solution. Does anyone > have any suggestions for a workaround in this case? Or is there some > functionality in the solver that I am missing? > > I look forward to your feedback. > > best wishes, > > Andrew > > - > Andrew Waterman > San Cristóbal de las Casas, Chiapas, Mexico > > > > > > > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] problem in Maven tests: class antlr CharStream not found, although it is there!
thanks edson your hints helped me search in the right direction. i resolved the problem although i do not know what exactly was the problem.. i did have this antlr dependency in my pom: org.antlr antlr-runtime 3.1.1 org.antlr antlr 3.1.1 which is the same dependency drools uses. when i removed these two dependencies from my pom everything worked. anyway: it works, i am happy! thanks, tim On Wed, Feb 4, 2009 at 11:23 PM, Edson Tirelli wrote: > > You need antlr-runtime jar in your classpath, although maven should get > it as a transitive dependency. > > Try running: > > mvn help:effective-pom > > That will show you what maven is using as pom after resolving > dependencies. If antlr-runtime jar is not there or if you have the wrong > version, that would be the problem. > > []s > Edson > > 2009/2/4 tim tim >> >> hello all >> >> my problem is that my tests work fine in eclipse, but they >> don't work in maven. >> >> when i execute my code via >> >> mvn test >> >> drools cant find the antl CharStream class. >> >> this is the error i get: >> >> java.lang.NoClassDefFoundError: org/antlr/runtime/CharStream >>at >> org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:276) >>at >> com.hikuku.rules.util.TestHelperRules.getPackage(TestHelperRules.java:85) >>at >> com.hikuku.rules.util.TestHelperRules.readRules(TestHelperRules.java:48) >>at >> com.hikuku.rules.util.TestHelperRules.readRules(TestHelperRules.java:67) >>at >> com.hikuku.rules.TestMemoryInsertRetract.insertRetract(TestMemoryInsertRetract.java:126) >>at >> com.hikuku.rules.TestMemoryInsertRetract.testInsertRetractAlldifferent(TestMemoryInsertRetract.java:84) >> Caused by: java.lang.ClassNotFoundException: org.antlr.runtime.CharStream >>at java.net.URLClassLoader$1.run(URLClassLoader.java:200) >>at java.security.AccessController.doPrivileged(Native Method) >>at java.net.URLClassLoader.findClass(URLClassLoader.java:188) >>at java.lang.ClassLoader.loadClass(ClassLoader.java:307) >>at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) >>at java.lang.ClassLoader.loadClass(ClassLoader.java:252) >>at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) >>... 32 more >> >> >> >> i have the antlr3.jar in my dependencies via the drools-compiler pom.xml >> and the class org.antlr.runtime.CharStream is definitely in the >> classpath. >> i can use it from my own code without problems. >> >> but the drools package builder does not seem to find it. >> >> this works (even under maven): >> >> final int a = org.antlr.runtime.CharStream.EOF; >> >> but this doesn't find CharStream: >> >> PackageBuilder builder = new PackageBuilder(); >> builder.addPackageFromDrl(r); >> >> >> this is my dependency on drools as i have it in my pom: >> >> >>org.eclipse.jdt >>core >>3.4.2.v_883_R34x >> >> >> >>janino >>janino >>2.5.10 >> >> >> >>org.drools >>drools-core >>5.0.0.SNAPSHOT >> >> >>org.drools >>drools-api >>5.0.0.SNAPSHOT >> >> >>org.drools >>drools-compiler >>5.0.0.SNAPSHOT >> >> >> >> the snapshot i use is the drools-5.0.0.20090203.112022-386 >> >> >> does anyone have an idea what the problem might be? >> >> thanks, tim >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users > > > > -- > Edson Tirelli > JBoss Drools Core Development > JBoss, a division of Red Hat @ www.jboss.com > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] problem in Maven tests: class antlr CharStream not found, although it is there!
hello all my problem is that my tests work fine in eclipse, but they don't work in maven. when i execute my code via mvn test drools cant find the antl CharStream class. this is the error i get: java.lang.NoClassDefFoundError: org/antlr/runtime/CharStream at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:276) at com.hikuku.rules.util.TestHelperRules.getPackage(TestHelperRules.java:85) at com.hikuku.rules.util.TestHelperRules.readRules(TestHelperRules.java:48) at com.hikuku.rules.util.TestHelperRules.readRules(TestHelperRules.java:67) at com.hikuku.rules.TestMemoryInsertRetract.insertRetract(TestMemoryInsertRetract.java:126) at com.hikuku.rules.TestMemoryInsertRetract.testInsertRetractAlldifferent(TestMemoryInsertRetract.java:84) Caused by: java.lang.ClassNotFoundException: org.antlr.runtime.CharStream at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 32 more i have the antlr3.jar in my dependencies via the drools-compiler pom.xml and the class org.antlr.runtime.CharStream is definitely in the classpath. i can use it from my own code without problems. but the drools package builder does not seem to find it. this works (even under maven): final int a = org.antlr.runtime.CharStream.EOF; but this doesn't find CharStream: PackageBuilder builder = new PackageBuilder(); builder.addPackageFromDrl(r); this is my dependency on drools as i have it in my pom: org.eclipse.jdt core 3.4.2.v_883_R34x janino janino 2.5.10 org.drools drools-core 5.0.0.SNAPSHOT org.drools drools-api 5.0.0.SNAPSHOT org.drools drools-compiler 5.0.0.SNAPSHOT the snapshot i use is the drools-5.0.0.20090203.112022-386 does anyone have an idea what the problem might be? thanks, tim ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Re: drools 5.0.0-SNAPSHOT Maven repository broken! please fix!
thanks geoffrey sorry, that i didn't put it in jira straight away. next time.. :) best, tim On Mon, Oct 13, 2008 at 5:41 PM, Geoffrey De Smet <[EMAIL PROTECTED]> wrote: > https://jira.jboss.org/jira/browse/JBRULES-1800 > > With kind regards, > Geoffrey De Smet > > > tim tim schreef: >> >> the maven list found the solution see here: >> >> >> http://www.nabble.com/mvn2-url-resolution-for-SNAPSHOT-sources-wrong-ts19951159.html >> >> from brett porter on the maven list: >>> >>> '.' is not a valid separator for snapshots - it needs to be -SNAPSHOT. >>> Drools will need to redeploy it as 5.0.0-SNAPSHOT for it to work. >> >> >> best, tim >> >> >> >> On Wed, Oct 8, 2008 at 6:35 PM, Geoffrey De Smet >> <[EMAIL PROTECTED]> wrote: >>> >>> With kind regards, >>> Geoffrey De Smet >>> >>> >>> tim tim schreef: >>>> >>>> hi >>>> >>>> when i am getting drools snapshot via "mvn eclipse:eclipse" >>>> the compiled drools jars are downloaded but the sources are not, >>>> although >>>> i have >>>> true >>>> defined as parameter in my pom.xml and the sources of the other >>>> libraries >>>> are downloaded correctly. >>>> when i use drools 4.0.7 those sources are downloaded correctly. >>>> >>>> i can find the sources manually in the http://snapshots.jboss.org/maven2 >>>> repository, they are just not downloaded >>>> automatically. >>>> >>>> i deleted the |mvn-eclipse-cache.properties |file in my target directory >>>> before calling mvn. (see >>>> http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html) >>> >>> Doesn't "mvn eclipse:clean" delete that cache too? >>> >>>> an extract from my maven output: >>>> >>>> // the compiled jars are located correctly: >>>> .. >>>> [INFO] snapshot org.drools.solver:drools-solver:5.0.0.SNAPSHOT: checking >>>> for updates from snapshots.jboss.org <http://snapshots.jboss.org> >>>> [INFO] snapshot org.drools.solver:drools-solver:5.0.0.SNAPSHOT: checking >>>> for updates from repo1.maven.org <http://repo1.maven.org> >>>> Downloading: >>>> >>>> http://snapshots.jboss.org/maven2/org/drools/solver/drools-solver/5.0.0.SNAPSHOT/drools-solver-5.0.0.20081008.102800-121.pom >>>> 1K downloaded >>>> Downloading: >>>> >>>> http://snapshots.jboss.org/maven2/org/drools/drools-compiler/5.0.0.SNAPSHOT/drools-compiler-5.0.0.20081008.102800-232.jar >>>> 943K downloaded >>>> Downloading: >>>> >>>> http://snapshots.jboss.org/maven2/org/drools/drools-core/5.0.0.SNAPSHOT/drools-core-5.0.0.20081008.102800-233.jar >>>> 1547K downloaded >>>> Downloading: >>>> >>>> http://snapshots.jboss.org/maven2/org/drools/solver/drools-solver-core/5.0.0.SNAPSHOT/drools-solver-core-5.0.0.20081008.102800-121.jar >>>> 94K downloaded >>>> ... >>>> // but maven searches for the sources in the wrong repositories: >>>> >>>> Downloading: >>>> >>>> http://repository.jboss.org/maven2/org/drools/drools-compiler/5.0.0.20081008.102800-232/drools-compiler-5.0.0.20081008.102800-232-sources.jar >>>> Downloading: >>>> >>>> http://repo1.maven.org/maven2/org/drools/drools-compiler/5.0.0.20081008.102800-232/drools-compiler-5.0.0.20081008.102800-232-sources.jar >>>> Downloading: >>>> >>>> http://repo1.maven.org/maven2/org/drools/drools-compiler/5.0.0.20081008.102800-232/drools-compiler-5.0.0.20081008.102800-232-sources.jar >>>> Downloading: >>>> >>>> http://repository.jboss.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar >>>> Downloading: >>>> >>>> http://repo1.maven.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar >>>> Downloading: >>>> >>>> http://repo1.maven.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar >>>> ... >>>> >>>> does someone else have this problem? >>>> >>>> or maybe my pom.xml is wrong? >>
Re: [rules-users] Re: drools 5.0.0-SNAPSHOT Maven repository broken?
> I am convinced that: > 2) Penalty's equals/hashcode uses both "cause" and "weight"? > then 3) happens: Keep Penalty(10), add Penalty(5) > is an issue in drools core and instead 2) should happen: > Remove Penalty(10), add Penalty(5) > because Penalty(10) is no longer true exactly! that is the behavior i was expecting. it took me quite some time to find out why my program did not find a solution. > I am going to make a testcase to isolate the problem and make it more > transparent that it is indeed an issue. And then try to convince Mark and > Edson that it's an issue :) maybe there could be a switch, to tell drools which mode is prefered? then they could keep the strange behavior in the engine ;-) > which the HACK indeed that you quothed below: > the hack causes the rule to no longer apply (retracting the > ConstraintOccurrence), after which it then refires. argh, you are right! i didnt see that it gets retracted. i still have to get used to the drools way.. best, tim > >> >> i solved the problem of improving constraints for the same causes that >> differ in hashCode by retracting the old fact before inserting the new >> one. >> but it takes quite some overhead to be able to do so. i could post my >> code if anyone is interested. >> >> unfortunately i could not find in your samples how you handle such a >> scenario. >> >> does the "HACK" part of this rule have something to do with it? >> >> from curriculumCourseScoreRules.drl >> >> // MinimumWorkingDays: The lectures of each course must be spread into >> a minimum number of days. >> // Each day below the minimum counts as 5 points of penalty. >> rule "minimumWorkingDays" >>when >>$course : Course($minWorkingDaySize : minWorkingDaySize); >>$dayCount : Number(intValue < $minWorkingDaySize) from accumulate( >>$day : Day() >>and exists Lecture(course == $course, day == $day), >>count($day) >>); >>// HACK to fix wierd truth maintance behavior in drools >>// because making weight part of the equals/hashcode doesn't cut it >>not IntConstraintOccurrence( >>ruleId == "minimumWorkingDays", >>constraintType == ConstraintType.NEGATIVE_SOFT, >>causes contains $course, >>eval(weight != (($minWorkingDaySize - $dayCount.intValue()) * >> 5)) >>); >>// An uninitialized schedule should have no constraints broken >>exists Lecture(course == $course); >>then >>insertLogical(new >> IntConstraintOccurrence("minimumWorkingDays", >> ConstraintType.NEGATIVE_SOFT, >>(($minWorkingDaySize - $dayCount.intValue()) * 5), >>$course)); >> end >> >> but the hack makes the rule not fire at all, when it had fired before. >> even if the error has improved by now. >> > > Feed back is always welcome :) > > With kind regards, > Geoffrey De Smet > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] drools solver move factory crash
hello the new version of the drools-solver supports multiple move factories. i happily split my move factory to take advantage of the relativeSelection parameter. now the problem is that not all move factories can produce moves for every possible current solution. and the org.drools.solver.core.localsearch.decider.selector.MoveFactorySelector crashes, when a move factory does not return a single move. public final List selectMoveList(StepScope stepScope) { List moveList = moveFactory.createMoveList(stepScope.getWorkingSolution()); if (shuffle) { Collections.shuffle(moveList, stepScope.getWorkingRandom()); } if (relativeSelection != null) { int selectionSize = (int) Math.ceil(relativeSelection * moveList.size()); if (selectionSize == 0) { selectionSize = 1; } moveList = moveList.subList(0, selectionSize); // <-- CRASH, if moveList is empty } return moveList; } currently i solve it by always returning at least a "null-move". but a better solution would be to change the MoveFactorySelector.selectMoveList(), so that it tests for an empty list. best, tim ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Re: drools 5.0.0-SNAPSHOT Maven repository broken! please fix!
the maven list found the solution see here: http://www.nabble.com/mvn2-url-resolution-for-SNAPSHOT-sources-wrong-ts19951159.html from brett porter on the maven list: > '.' is not a valid separator for snapshots - it needs to be -SNAPSHOT. > Drools will need to redeploy it as 5.0.0-SNAPSHOT for it to work. best, tim On Wed, Oct 8, 2008 at 6:35 PM, Geoffrey De Smet <[EMAIL PROTECTED]> wrote: > > With kind regards, > Geoffrey De Smet > > > tim tim schreef: >> >> hi >> >> when i am getting drools snapshot via "mvn eclipse:eclipse" >> the compiled drools jars are downloaded but the sources are not, although >> i have >> true >> defined as parameter in my pom.xml and the sources of the other libraries >> are downloaded correctly. >> when i use drools 4.0.7 those sources are downloaded correctly. >> >> i can find the sources manually in the http://snapshots.jboss.org/maven2 >> repository, they are just not downloaded >> automatically. >> >> i deleted the |mvn-eclipse-cache.properties |file in my target directory >> before calling mvn. (see >> http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html) > > Doesn't "mvn eclipse:clean" delete that cache too? > >> >> an extract from my maven output: >> >> // the compiled jars are located correctly: >> .. >> [INFO] snapshot org.drools.solver:drools-solver:5.0.0.SNAPSHOT: checking >> for updates from snapshots.jboss.org <http://snapshots.jboss.org> >> [INFO] snapshot org.drools.solver:drools-solver:5.0.0.SNAPSHOT: checking >> for updates from repo1.maven.org <http://repo1.maven.org> >> Downloading: >> http://snapshots.jboss.org/maven2/org/drools/solver/drools-solver/5.0.0.SNAPSHOT/drools-solver-5.0.0.20081008.102800-121.pom >> 1K downloaded >> Downloading: >> http://snapshots.jboss.org/maven2/org/drools/drools-compiler/5.0.0.SNAPSHOT/drools-compiler-5.0.0.20081008.102800-232.jar >> 943K downloaded >> Downloading: >> http://snapshots.jboss.org/maven2/org/drools/drools-core/5.0.0.SNAPSHOT/drools-core-5.0.0.20081008.102800-233.jar >> 1547K downloaded >> Downloading: >> http://snapshots.jboss.org/maven2/org/drools/solver/drools-solver-core/5.0.0.SNAPSHOT/drools-solver-core-5.0.0.20081008.102800-121.jar >> 94K downloaded >> ... >> // but maven searches for the sources in the wrong repositories: >> >> Downloading: >> http://repository.jboss.org/maven2/org/drools/drools-compiler/5.0.0.20081008.102800-232/drools-compiler-5.0.0.20081008.102800-232-sources.jar >> Downloading: >> http://repo1.maven.org/maven2/org/drools/drools-compiler/5.0.0.20081008.102800-232/drools-compiler-5.0.0.20081008.102800-232-sources.jar >> Downloading: >> http://repo1.maven.org/maven2/org/drools/drools-compiler/5.0.0.20081008.102800-232/drools-compiler-5.0.0.20081008.102800-232-sources.jar >> Downloading: >> http://repository.jboss.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar >> Downloading: >> http://repo1.maven.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar >> Downloading: >> http://repo1.maven.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar >> ... >> >> does someone else have this problem? >> >> or maybe my pom.xml is wrong? >> the relevant parts of my pom.xml file are: >> >> >> >>repo1.maven.org <http://repo1.maven.org> > > I don't think you need to explicitly add this one, it's always automatically > added, unless you overwrite it with the id "central" I think. >> >>http://repo1.maven.org/maven2 >> >>true > > repo1.maven.org doesn't contain snapshots as far as I know, so it should be > false > It could be that the eclipse plugin only searches on the first snapshot repo > it encounters? Which version of the eclipse plugin are you using? >> >> >> >>true >> >> >> >>repository.jboss.org <http://repository.jboss.org> >>http://repository.jboss.org/maven2 >> >>false >> >> >>true >> >> >> >>snapshots.jboss.org <http://snapshots.jboss.org> >>http://snapshots.jboss.org/
Re: [rules-users] Re: drools 5.0.0-SNAPSHOT Maven repository broken?
hi geoffrey thanks for your help > I am out of idea, check on the maven user list? ok, i did that, maybe they can help. http://www.nabble.com/mvn2-url-resolution-for-SNAPSHOT-sources-wrong-ts19951159.html > I am curious, what are you using drools-solver for? i am using it for a sports trainings expert system. your idea of complementing the drools rules engine with a solver seems perfect for my needs. :-) the plan is that the rules will be written by physiologists and trainers and the solver should find a trainings session that adheres to all the rules. a typical rule would be: "do warmup before training" the problem is a typical configuration problem. > Feed-back, comments and patches welcome ;) thanks a lot for the solver! and congratulations that you got it into the official project! your documentation and the samples made my start with the solver straight forward. where i got stuck for quite some time was this: http://www.nabble.com/Questions-about-logically-justified-objects-ts14788904.html#a14790335 and i could not find how you solved this problem in the end. i solved the problem of improving constraints for the same causes that differ in hashCode by retracting the old fact before inserting the new one. but it takes quite some overhead to be able to do so. i could post my code if anyone is interested. unfortunately i could not find in your samples how you handle such a scenario. does the "HACK" part of this rule have something to do with it? from curriculumCourseScoreRules.drl // MinimumWorkingDays: The lectures of each course must be spread into a minimum number of days. // Each day below the minimum counts as 5 points of penalty. rule "minimumWorkingDays" when $course : Course($minWorkingDaySize : minWorkingDaySize); $dayCount : Number(intValue < $minWorkingDaySize) from accumulate( $day : Day() and exists Lecture(course == $course, day == $day), count($day) ); // HACK to fix wierd truth maintance behavior in drools // because making weight part of the equals/hashcode doesn't cut it not IntConstraintOccurrence( ruleId == "minimumWorkingDays", constraintType == ConstraintType.NEGATIVE_SOFT, causes contains $course, eval(weight != (($minWorkingDaySize - $dayCount.intValue()) * 5)) ); // An uninitialized schedule should have no constraints broken exists Lecture(course == $course); then insertLogical(new IntConstraintOccurrence("minimumWorkingDays", ConstraintType.NEGATIVE_SOFT, (($minWorkingDaySize - $dayCount.intValue()) * 5), $course)); end but the hack makes the rule not fire at all, when it had fired before. even if the error has improved by now. best, tim > > With kind regards, > Geoffrey De Smet > > > tim tim schreef: >> >> thanks geoffrey, >> >> i used the 2.4 version of the eclipse plugin. >> >> but now i changed it to use 2.5.1, and removed the explicit >> http://repo1.maven.org/maven2 repository but still no sources. >> >> maven is still searching in the wrong repositories: >> >> Downloading: >> http://repository.jboss.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar >> Downloading: >> http://repo1.maven.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar >> >> >> best, tim >> >> On Wed, Oct 8, 2008 at 6:35 PM, Geoffrey De Smet >> <[EMAIL PROTECTED]> wrote: >>> >>> With kind regards, >>> Geoffrey De Smet >>> >>> >>> tim tim schreef: >>>> >>>> hi >>>> >>>> when i am getting drools snapshot via "mvn eclipse:eclipse" >>>> the compiled drools jars are downloaded but the sources are not, >>>> although >>>> i have >>>> true >>>> defined as parameter in my pom.xml and the sources of the other >>>> libraries >>>> are downloaded correctly. >>>> when i use drools 4.0.7 those sources are downloaded correctly. >>>> >>>> i can find the sources manually in the http://snapshots.jboss.org/maven2 >>>> repository, they are just not downloaded >>>> automatically. >>>> >>>> i deleted the |mvn-eclipse-cache.properties |file in my target directory >>>> before calling mvn. (see >>>> http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html) >>> >>> Doesn't "mvn eclipse:clean" delete that cache too? >>> >
Re: [rules-users] Re: drools 5.0.0-SNAPSHOT Maven repository broken?
thanks geoffrey, i used the 2.4 version of the eclipse plugin. but now i changed it to use 2.5.1, and removed the explicit http://repo1.maven.org/maven2 repository but still no sources. maven is still searching in the wrong repositories: Downloading: http://repository.jboss.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar Downloading: http://repo1.maven.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar best, tim On Wed, Oct 8, 2008 at 6:35 PM, Geoffrey De Smet <[EMAIL PROTECTED]> wrote: > > With kind regards, > Geoffrey De Smet > > > tim tim schreef: >> >> hi >> >> when i am getting drools snapshot via "mvn eclipse:eclipse" >> the compiled drools jars are downloaded but the sources are not, although >> i have >> true >> defined as parameter in my pom.xml and the sources of the other libraries >> are downloaded correctly. >> when i use drools 4.0.7 those sources are downloaded correctly. >> >> i can find the sources manually in the http://snapshots.jboss.org/maven2 >> repository, they are just not downloaded >> automatically. >> >> i deleted the |mvn-eclipse-cache.properties |file in my target directory >> before calling mvn. (see >> http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html) > > Doesn't "mvn eclipse:clean" delete that cache too? > >> >> an extract from my maven output: >> >> // the compiled jars are located correctly: >> .. >> [INFO] snapshot org.drools.solver:drools-solver:5.0.0.SNAPSHOT: checking >> for updates from snapshots.jboss.org <http://snapshots.jboss.org> >> [INFO] snapshot org.drools.solver:drools-solver:5.0.0.SNAPSHOT: checking >> for updates from repo1.maven.org <http://repo1.maven.org> >> Downloading: >> http://snapshots.jboss.org/maven2/org/drools/solver/drools-solver/5.0.0.SNAPSHOT/drools-solver-5.0.0.20081008.102800-121.pom >> 1K downloaded >> Downloading: >> http://snapshots.jboss.org/maven2/org/drools/drools-compiler/5.0.0.SNAPSHOT/drools-compiler-5.0.0.20081008.102800-232.jar >> 943K downloaded >> Downloading: >> http://snapshots.jboss.org/maven2/org/drools/drools-core/5.0.0.SNAPSHOT/drools-core-5.0.0.20081008.102800-233.jar >> 1547K downloaded >> Downloading: >> http://snapshots.jboss.org/maven2/org/drools/solver/drools-solver-core/5.0.0.SNAPSHOT/drools-solver-core-5.0.0.20081008.102800-121.jar >> 94K downloaded >> ... >> // but maven searches for the sources in the wrong repositories: >> >> Downloading: >> http://repository.jboss.org/maven2/org/drools/drools-compiler/5.0.0.20081008.102800-232/drools-compiler-5.0.0.20081008.102800-232-sources.jar >> Downloading: >> http://repo1.maven.org/maven2/org/drools/drools-compiler/5.0.0.20081008.102800-232/drools-compiler-5.0.0.20081008.102800-232-sources.jar >> Downloading: >> http://repo1.maven.org/maven2/org/drools/drools-compiler/5.0.0.20081008.102800-232/drools-compiler-5.0.0.20081008.102800-232-sources.jar >> Downloading: >> http://repository.jboss.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar >> Downloading: >> http://repo1.maven.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar >> Downloading: >> http://repo1.maven.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar >> ... >> >> does someone else have this problem? >> >> or maybe my pom.xml is wrong? >> the relevant parts of my pom.xml file are: >> >> >> >>repo1.maven.org <http://repo1.maven.org> > > I don't think you need to explicitly add this one, it's always automatically > added, unless you overwrite it with the id "central" I think. >> >>http://repo1.maven.org/maven2 >> >>true > > repo1.maven.org doesn't contain snapshots as far as I know, so it should be > false > It could be that the eclipse plugin only searches on the first snapshot repo > it encounters? Which version of the eclipse plugin are you using? >> >> >> >>true >> >> >> >>repository.jboss.org <http://repository.jboss.org> >>http://repository.jboss.org/maven2 >> >>false >>
[rules-users] Re: not exists / forall(not) logically equivalent, behave differently
edson, thanks a lot for your answer. now i came to a new problem. i stated the rule as you said: rule "no dog without a tail" when $dog :Dog() not( Tail(dog == $dog) ) then // fire rule end but now, if i do workingMemory.insert(dog); workingMemory.insert(dog.getTail()); workingMemory.fireAllRules(); modifyRetract(dogHandle); dog.changeHashCode(); // do something that changes the hashCode of the dog modifyInsert(dogHandle); workingMemory.fireAllRules(); in the second fireAllRules() the rule fires, even though there is a tail for the dog. am i not allowed to do an opperation that changes the hashCode of the modified object between the modifyRetract() and modifyInsert() ? should i totally retract the object, and insert it again instead? thank you, tim > I believe there is an open ticket for a bug when using "not(exists())" in > 5.0. I did not investigated yet, but I believe this is a regression in the > new asymmetric matching algorithm in 5.0. Anyway, we will fix it before > releasing the final version. > >Meantime, just use: > >not( Tail(dog == $dog) ) > >Since the "exists" is redundant there because "not" is the existential > operator, not the "boolean" operator. > >[]s >Edson 2008/10/6 tim tim <[EMAIL PROTECTED]> hello there, i have a rule, that should fire, when a required part of a whole is missing. lets say the whole is a dog, and the required part the tail. then the rule should fire, when there is a dog without a tail. i stated the rule in two logically equivalent ways. 1) when we have a dog, and all existing tails belong to other peoples dogs, the rule should fire: rule "no dog without a tail; forall" when $dog :Dog() forall($t : Tail() Tail(dog != $dog)) then // fire rule end 2) when we have a dog and no tail exists that belongs to this dog the rule should fire: rule "no dog without a tail; not exists" when $dog :Dog() not( exists( Tail(dog == $dog))) then // fire rule end and they really do behave similar, but not the same.. workingMemory.insert(dog); workingMemory.insert(dog.getTail()); workingMemory.fireAllRules(); // here both did not fire, but when i go on: workingMemory.modifyRetract(dogHandle) workingMemory.modifyInsert(dogHandle, dog) workingMemory.fireAllRules(); // now the not(exists(..)) version did fire, whereas the forall(..) version did not. of course both rules should not have fired, nothing changed for the dogs relationship with its tail. i am using the 5.0.0.snapshot version of drools but i can not imagine that this is an unknown bug, as this is rather basic predicate logic. what am i missing? best, tim ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] drools 5.0.0-SNAPSHOT Maven repository broken?
hi when i am getting drools snapshot via "mvn eclipse:eclipse" the compiled drools jars are downloaded but the sources are not, although i have true defined as parameter in my pom.xml and the sources of the other libraries are downloaded correctly. when i use drools 4.0.7 those sources are downloaded correctly. i can find the sources manually in the http://snapshots.jboss.org/maven2repository, they are just not downloaded automatically. i deleted the mvn-eclipse-cache.properties file in my target directory before calling mvn. (see http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html) an extract from my maven output: // the compiled jars are located correctly: .. [INFO] snapshot org.drools.solver:drools-solver:5.0.0.SNAPSHOT: checking for updates from snapshots.jboss.org [INFO] snapshot org.drools.solver:drools-solver:5.0.0.SNAPSHOT: checking for updates from repo1.maven.org Downloading: http://snapshots.jboss.org/maven2/org/drools/solver/drools-solver/5.0.0.SNAPSHOT/drools-solver-5.0.0.20081008.102800-121.pom 1K downloaded Downloading: http://snapshots.jboss.org/maven2/org/drools/drools-compiler/5.0.0.SNAPSHOT/drools-compiler-5.0.0.20081008.102800-232.jar 943K downloaded Downloading: http://snapshots.jboss.org/maven2/org/drools/drools-core/5.0.0.SNAPSHOT/drools-core-5.0.0.20081008.102800-233.jar 1547K downloaded Downloading: http://snapshots.jboss.org/maven2/org/drools/solver/drools-solver-core/5.0.0.SNAPSHOT/drools-solver-core-5.0.0.20081008.102800-121.jar 94K downloaded ... // but maven searches for the sources in the wrong repositories: Downloading: http://repository.jboss.org/maven2/org/drools/drools-compiler/5.0.0.20081008.102800-232/drools-compiler-5.0.0.20081008.102800-232-sources.jar Downloading: http://repo1.maven.org/maven2/org/drools/drools-compiler/5.0.0.20081008.102800-232/drools-compiler-5.0.0.20081008.102800-232-sources.jar Downloading: http://repo1.maven.org/maven2/org/drools/drools-compiler/5.0.0.20081008.102800-232/drools-compiler-5.0.0.20081008.102800-232-sources.jar Downloading: http://repository.jboss.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar Downloading: http://repo1.maven.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar Downloading: http://repo1.maven.org/maven2/org/drools/drools-core/5.0.0.20081008.102800-233/drools-core-5.0.0.20081008.102800-233-sources.jar ... does someone else have this problem? or maybe my pom.xml is wrong? the relevant parts of my pom.xml file are: repo1.maven.org http://repo1.maven.org/maven2 true true repository.jboss.org http://repository.jboss.org/maven2 false true snapshots.jboss.org http://snapshots.jboss.org/maven2 true false janino janino 2.5.10 org.drools drools-core 5.0.0.SNAPSHOT org.drools drools-compiler 5.0.0.SNAPSHOT org.drools.solver drools-solver-core 5.0.0.SNAPSHOT unfortunately i have no idea what the problem might be and installing the sources manually every time i update is no very attractive option.. thanks in advance, tim ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] insertLogical and modifyRetract (drools-solver)
ups, i created a nice endless loop with my proposed solution. :-) the correct (still ugly) solution is: rule "fact1 should be smaller then 1" when $f : UserFact($fact1 : fact1 >= 1) not IntConstraintOccurence( ruleId == "fact1 should be smaller then 1", constraintType == ConstraintType.NEGATIVE_SOFT, causes contains $f, weight != $fact1) // the weight has to be different, else the rule should not fire then // use the value of fact1 to determine the error insertLogical(new IntConstraintOccurence("fact1 should be smaller then 1", $fact1, $f )); end rule "fact1 should be smaller then 1, old constraint exists" when $f : UserFact($fact1 : fact1 >= 1); // see if there is already a fact in the $oldConstraint : IntConstraintOccurence( ruleId == "fact1 should be smaller then 1", constraintType == ConstraintType.NEGATIVE_SOFT, causes contains $f, weight != $fact1) // the weight has to be different, else the rule should not fire then retract($oldConstraint); // manually retract the obsolete fact // use the value of fact1 to determine the error insertLogical(new IntConstraintOccurence("fact1 should be smaller then 1",ConstraintType.NEGATIVE_SOFT, $fact1, $f )); end On Tue, Oct 7, 2008 at 6:59 PM, tim tim <[EMAIL PROTECTED]>wrote: > thanks, you are right, that is kind of a solution. but not really what i am > looking for. > i am using drools-solver, and the "CreatedFact" is an > IntConstraintOccurrence, which i do not want to change. > > maybe i should make the example more specific for my problem. > > i have a rule, used for the solver: > > rule "fact1 should be smaller then 1" > when > $f : UserFact(fact1 >= 1); > then > // use the value of fact1 to determine the error > insertLogical(new IntConstraintOccurence("fact1 should be smaller > then 1", $f.getFact1(), $f )); > end > > > i have a Move that decrements fact1, so that after the move the error > should be 1 smaller. > but the move is almost never triggered, because the old constraintOccurence > is not retracted from memory and the new one added anyway, > hence the error is nearly double after the move, as now two > constraintOccurences represent the same error. > > > what i could think of is something like this: > > one rule for the first test: > > rule "fact1 should be smaller then 1" > when > $f : UserFact(fact1 >= 1) >not IntConstraintOccurence( > ruleId == "fact1 should be smaller then 1", > constraintType == > ConstraintType.NEGATIVE_SOFT, > causes contains $f) > then > // use the value of fact1 to determine the error > insertLogical(new IntConstraintOccurence("fact1 should be smaller > then 1", $f.getFact1(), $f )); > end > > and a second rule, when the first rule has already fired before: > > rule "fact1 should be smaller then 1, old constraint exists" > when > $f : UserFact(fact1 >= 1); > > // see if there is already a fact in the > $oldConstraint : IntConstraintOccurence( > ruleId == "fact1 should be smaller then 1", > constraintType == > ConstraintType.NEGATIVE_SOFT, > causes contains $f) > then >retract($oldConstraint); // manually retract the obsolete fact > // use the value of fact1 to determine the error > insertLogical(new IntConstraintOccurence("fact1 should be smaller > then 1",ConstraintType.NEGATIVE_SOFT, $f.getFact1(), $f )); > end > > this solution seems very verbose for such a common task. and again, i do > not understand, why an obsolete fact is not > retracted automatically? > > best, tim > > On Tue, Oct 7, 2008 at 5:57 PM, Gras, Patrick <[EMAIL PROTECTED]>wrote: > >> Hello, >> >> If you can change the code for CreatedFact and let it have a reference to >> UserFact and change the rule to: >> >> rule "fact = 1" >> when >> $f : UserFact(fact1 == 1); >> then >> insertLogical(new CreatedFact($f)); >> end >> you will also have to overide equals and hashcode for CreatedFact so that &
Re: [rules-users] insertLogical and modifyRetract (drools-solver)
thanks, you are right, that is kind of a solution. but not really what i am looking for. i am using drools-solver, and the "CreatedFact" is an IntConstraintOccurrence, which i do not want to change. maybe i should make the example more specific for my problem. i have a rule, used for the solver: rule "fact1 should be smaller then 1" when $f : UserFact(fact1 >= 1); then // use the value of fact1 to determine the error insertLogical(new IntConstraintOccurence("fact1 should be smaller then 1", $f.getFact1(), $f )); end i have a Move that decrements fact1, so that after the move the error should be 1 smaller. but the move is almost never triggered, because the old constraintOccurence is not retracted from memory and the new one added anyway, hence the error is nearly double after the move, as now two constraintOccurences represent the same error. what i could think of is something like this: one rule for the first test: rule "fact1 should be smaller then 1" when $f : UserFact(fact1 >= 1) not IntConstraintOccurence( ruleId == "fact1 should be smaller then 1", constraintType == ConstraintType.NEGATIVE_SOFT, causes contains $f) then // use the value of fact1 to determine the error insertLogical(new IntConstraintOccurence("fact1 should be smaller then 1", $f.getFact1(), $f )); end and a second rule, when the first rule has already fired before: rule "fact1 should be smaller then 1, old constraint exists" when $f : UserFact(fact1 >= 1); // see if there is already a fact in the $oldConstraint : IntConstraintOccurence( ruleId == "fact1 should be smaller then 1", constraintType == ConstraintType.NEGATIVE_SOFT, causes contains $f) then retract($oldConstraint); // manually retract the obsolete fact // use the value of fact1 to determine the error insertLogical(new IntConstraintOccurence("fact1 should be smaller then 1",ConstraintType.NEGATIVE_SOFT, $f.getFact1(), $f )); end this solution seems very verbose for such a common task. and again, i do not understand, why an obsolete fact is not retracted automatically? best, tim On Tue, Oct 7, 2008 at 5:57 PM, Gras, Patrick <[EMAIL PROTECTED]>wrote: > Hello, > > If you can change the code for CreatedFact and let it have a reference to > UserFact and change the rule to: > > rule "fact = 1" > when > $f : UserFact(fact1 == 1); > then > insertLogical(new CreatedFact($f)); > end > you will also have to overide equals and hashcode for CreatedFact so that > several CreatedFacts referencing the same UserFact are considered equal... > > But with this solution CreatedFact will always be up to date with the value > of UserFact even without firing the rules and maybe it's not what you > want... > > -Patrick > > -Message d'origine- > *De :* [EMAIL PROTECTED] [mailto: > [EMAIL PROTECTED] la part de* tim tim > *Envoyé :* mardi, 7. octobre 2008 16:53 > *À :* rules-users@lists.jboss.org > *Objet :* [rules-users] insertLogical and modifyRetract > > Hello, > > I am a bit confused about how insertLogical() supposed to work in drools 5. > > when i have a rule such as: > > rule "fact = 1" > when > $f : UserFact(fact1 == 1); > then > insertLogical(new CreatedFact($f.getFact2())); > end > > now i change $f in such a way, that the rule will fire again. > via > > // build first version > UserFact f = new UserFact(); > f.setFact1(1); > f.setFact2(1); > > memory.insert(f); > memory.fireAllRules(); // <- Rule fires once > > // now i change the memory and fire the rules again > > memory.modifyRetract(f) ; > f.setFact2(100); // <- changing $f, but leaving fact1 as it is. > memory.modifyInsert(f); > > memory.fireAllRules(); // <- Rule fires again > > now the rule should fire again, which it does. > but i end up with two CreatedFact instances in the workingMemory.. > one with the old OtherFact value 1, and one with the new value, 100 > > but i want only the second instance. the one created first is not valid any > more. > i could write an extra rule for retracting the first CreatedFact-fact, but > then i would have > a very tight coupling of the two rules. > > is there a better way? > it seems odd to me, that a consequence of a rule stays in memory, when > there is > a more current version of the rule evocation with the _same_ facts in the > precond
[rules-users] insertLogical and modifyRetract
Hello, I am a bit confused about how insertLogical() supposed to work in drools 5. when i have a rule such as: rule "fact = 1" when $f : UserFact(fact1 == 1); then insertLogical(new CreatedFact($f.getFact2())); end now i change $f in such a way, that the rule will fire again. via // build first version UserFact f = new UserFact(); f.setFact1(1); f.setFact2(1); memory.insert(f); memory.fireAllRules(); // <- Rule fires once // now i change the memory and fire the rules again memory.modifyRetract(f) ; f.setFact2(100); // <- changing $f, but leaving fact1 as it is. memory.modifyInsert(f); memory.fireAllRules(); // <- Rule fires again now the rule should fire again, which it does. but i end up with two CreatedFact instances in the workingMemory.. one with the old OtherFact value 1, and one with the new value, 100 but i want only the second instance. the one created first is not valid any more. i could write an extra rule for retracting the first CreatedFact-fact, but then i would have a very tight coupling of the two rules. is there a better way? it seems odd to me, that a consequence of a rule stays in memory, when there is a more current version of the rule evocation with the _same_ facts in the precondition and a different consequence. thanks in advance, tim ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] not exists / forall(not) logically equivalent, behave differently
hello there, i have a rule, that should fire, when a required part of a whole is missing. lets say the whole is a dog, and the required part the tail. then the rule should fire, when there is a dog without a tail. i stated the rule in two logically equivalent ways. 1) when we have a dog, and all existing tails belong to other peoples dogs, the rule should fire: rule "no dog without a tail; forall" when $dog :Dog() forall($t : Tail() Tail(dog != $dog)) then // fire rule end 2) when we have a dog and no tail exists that belongs to this dog the rule should fire: rule "no dog without a tail; not exists" when $dog :Dog() not( exists( Tail(dog == $dog))) then // fire rule end and they really do behave similar, but not the same.. workingMemory.insert(dog); workingMemory.insert(dog.getTail()); workingMemory.fireAllRules(); // here both did not fire, but when i go on: workingMemory.modifyRetract(dogHandle) workingMemory.modifyInsert(dogHandle, dog) workingMemory.fireAllRules(); // now the not(exists(..)) version did fire, whereas the forall(..) version did not. of course both rules should not have fired, nothing changed for the dogs relationship with its tail. i am using the 5.0.0.snapshot version of drools but i can not imagine that this is an unknown bug, as this is rather basic predicate logic. what am i missing? best, tim ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users