With kind regards, Geoffrey De Smet
Andrew Waterman schreef:
Hi Geoffrey,Sorry to be so late on this feedback. I like your suggestions, it would be quite nice to move away from the magic ScoreCalculator name. I'd like to be able to list the components that were fed into a score, as well. For example, I have a rule such as:rule "western border deforested" when$tok1 : Token ($id : id, border == BorderType.WEST, type in (TokenType.MODERATE_PASTURE, TokenType.INTENSIVE_PASTURE))$tok2 : Token (id > $id, $id2 : id, border == BorderType.WEST, type in (TokenType.MODERATE_PASTURE, TokenType.INTENSIVE_PASTURE))$tok3 : Token (id > $id2, border == BorderType.WEST, type in (TokenType.MODERATE_PASTURE, TokenType.INTENSIVE_PASTURE)) theninsertLogical (new UnweightedConstraintOccurrence("western border deforested", $tok1, $tok2, $tok3));endI would like to be able to query the score later, in my case when it is less than 0.0, in order to list out the specific constraints (identifying String and causal objects) that keep the problem from being solved, I believe I can do this today, by implementing my own ScoreCalculator, but it would be a nice feature of the Score object, especially when accessible from the Solution handle.
With the changes I have locally, you can implement the Score (better yet HardAndSoftScore) interface and do exactly that. The only problem is for some reason it's a lot slower and I am now figuring out what's causing it before committing it to trunk.
I'm not sure how happy I am with imposing references to the actions of the solver into outside facts, however. I would prefer to keep my inserted facts quite seperate from the solver code -- however I see nothing wrong with a reference inside a Move implementation. :)
I haven't started on this part yet, so these are just some ideas:Move would have a reference to Solution and Solution would have a reference to Score. Both seem natural. But Token would need a reference to YourSolution, which is probably what's bugging you since YourSolution isn't in your database (because it's a singleton in your database anyway and all token records would refence the same your_solution record). But will it always remain a singleton? And don't you want to persist the Score in the database as field in a your_solution record?
What do you think?
best wishes, Andrew --------------------------------- Andrew Waterman San Cristóbal de las Casas, Chiapas, Mexico +52 1 967 107 5902 +1 510 342 5693 On Feb 21, 2009, at 5:07 AM, Geoffrey De Smet wrote:Feed-back welcome :)The score should be a Score instance of double. Add build-in support for HardAndSoftScore. Replace ScoreCalculator with ScoreHolder.https://jira.jboss.org/jira/browse/JBRULES-1158Solution should have a getScore() and the score rules need to calculate the correct score for a solution instead of filling some magic global variablehttps://jira.jboss.org/jira/browse/JBRULES-1977 With kind regards, Geoffrey De Smet Geoffrey De Smet schreef:I am actually considering a couple of designs, which also happens to solve the problem of the magic name of the scoreCalculator. 1) a score will no longer be a double, but an instance of a new interface Score. This will means that a score of an int hard and int soft will be represented as it should be: an int hard and an int soft. That has 2 advantages: - you could use implement their own Score, if the out-of-the-box types don't suffice, say int hard, BigDecimal soft, double verySoft. - it would be possible to decide the step, not on a normal compareTo, where hard is always higher then soft, but on (hard * hardAsSoftWeight + soft), where hardAsSoftWeight changes: it's normally very high, but when no hard constraints are broken in a long time, it temporarily goes down. This allows the local search to take steps that break a hard constraints for a while, passing through hard barriers. Experiments have proven that this gives better results.2) a Solution has a Score. That Score can be uninitialized or dirty.A Solution is also inserted into the working memory (along with it's facts). Every changing fact (Queen, Lesson, Exam, ...) will also need to hold a reference to it's Solution. That way every ConstraintOccurrence can hold a reference to it's Solution. Then the calculateScore rule will update the score in a solution, instead of putting it into a global. The solver still has a reference to the solution, so it can retrieve the score. This allows for multiple solution instances to be put into same working memory and there's no magic scoreCalculator.What do you think? Criticism welcome :)Of course, backward compatibility will be broken (as stated in the manual), but everything will be documented into an upgradeRecipe.txt,so it shouldn't be to hard to upgrade to a newer version. With kind regards, Geoffrey De Smet Greg Barton schreef:Actually, I was wishing for something similar last night, but for the names of entry-points. I think it would be nice if you could specify the names of things in DRL from the values of public static final Strings. (i.e. constants) Do you dev folk think that's possible enough to make a jira request for it?--- On Fri, 2/13/09, Geoffrey De Smet <[email protected] <mailto:[email protected]>> wrote:From: Geoffrey De Smet <[email protected] <mailto:[email protected]>> Subject: [rules-users] Re: drools-solver - magic name of scoreCalculatorTo: [email protected] <mailto:[email protected]> Date: Friday, February 13, 2009, 9:37 AM Yes, it's not that good that it's a magic name. However, I don't know any other way to do it. Feel free to make a jira for it, especially if you know a better way to do it :) With kind regards, Geoffrey De Smet Andrew Waterman schreef:Thanks Geoffrey! I patched this yesterday withslf4j-jcl and slf4j-nop for no loging. I'll post the mavne dependencies later this morning in case others wish to use non-log4j implementations. :) I did noticeas well that the "scoreCalculator" global is referenced by name from the solver. Want me to file a jira issue on that? It seems strange that the variable name shoudl be static like that to me.best wishes, Andrew On Fri, Feb 13, 2009 at 7:55 AM, Geoffrey De Smet<[email protected] <mailto:[email protected]> <mailto:[email protected]>> wrote:Adding the slf4j-log4j12 dependency to yourpom.xml should fix it :)<dependency><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId><scope>runtime</scope> </dependency> Not sure how changing anything indrools-solver-examples could fixit, normally your project wouldn't depend onit, only ondrools-solver-core. With kind regards, Geoffrey De Smet Greg Barton schreef: I was getting the error below running thebenchmarkNQueens.shscript in drools-solver-examples. I gotaround it by taking the"<scope>runtime</scope>"line out of the slf4j-log4j12dependency in drools-solver-examples/pom.xml.Not sure ifthat's the right way to get around it, butit worked. :)--- On Fri, 2/13/09, Geoffrey De Smet<[email protected] <mailto:[email protected]><mailto:[email protected]>>wrote:From: Geoffrey De Smet<[email protected] <mailto:[email protected]><mailto:[email protected]>> Subject: [rules-users] Re: drools-solver-- logger error(slf4j binding)?To: [email protected] <mailto:[email protected]><mailto:[email protected]> Date: Friday, February 13, 2009, 1:04 AM drools-score (like hibernate and manyother lib projects)just depends on sl4j-api, which is alogging interface.It's up to the end-use product todecide which loggingimplementation to use under that and howto configure thelogging (where to log to, how much to log,...).In the drools solver examples I 'veput slf4j-log4junderneat it, because I am familiar withlog4j'sconfiguration, take a look at theirlog4j.xml files. Howeverthey say that the logback implementationis better thesedays. PS: I 'll take a look at the otherdiscussions thisafternoon. With kind regards, Geoffrey De Smet Andrew Waterman schreef: Hi, I'm using the drools-solver.M5build through Mavenand have gotten the following error whilerunning myproject: SLF4J: Failed to load class"org.slf4j.impl.StaticLoggerBinder".SLF4J: Seehttp://www.slf4j.org/codes.html#StaticLoggerBinder forfurther details. I've checked my dependency graph,anddrools-solver references the sl4j-api, butnoimplementation. I checked themvnrepository, and there areseveral other slf4j related projects.What is the preferredbinding for JDK1.6? best wishes, Andrew --------------------------------- Andrew Waterman San Cristóbal de las Casas, Chiapas,Mexico+52 1 967 107 5902 +1 510 342 5693_______________________________________________rules-users mailing list[email protected] <mailto:[email protected]><mailto:[email protected]>https://lists.jboss.org/mailman/listinfo/rules-users_______________________________________________rules-users mailing list[email protected] <mailto:[email protected]><mailto:[email protected]>https://lists.jboss.org/mailman/listinfo/rules-users_______________________________________________rules-users mailing list[email protected] <mailto:[email protected]><mailto:[email protected]>https://lists.jboss.org/mailman/listinfo/rules-users_______________________________________________ rules-users mailing list [email protected] <mailto:[email protected]><mailto:[email protected]>https://lists.jboss.org/mailman/listinfo/rules-users-- +1 510 342 5693 PO Box 7775 #8750 San Francisco, California 94120-7775 "Warning: following standard input indefinitelyis ineffective"- /bin/tail error message "Against logic there is no armor likeignorance."- Laurence J. Pete------------------------------------------------------------------------_______________________________________________ rules-users mailing list [email protected] <mailto:[email protected]> https://lists.jboss.org/mailman/listinfo/rules-users_______________________________________________ rules-users mailing list [email protected] <mailto:[email protected]> https://lists.jboss.org/mailman/listinfo/rules-users_______________________________________________ rules-users mailing list [email protected] <mailto:[email protected]> https://lists.jboss.org/mailman/listinfo/rules-users_______________________________________________ rules-users mailing list [email protected] <mailto:[email protected]> https://lists.jboss.org/mailman/listinfo/rules-users_______________________________________________ rules-users mailing list [email protected] <mailto:[email protected]> https://lists.jboss.org/mailman/listinfo/rules-users------------------------------------------------------------------------ _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
