[rules-users] Parallel / Distributed Optaplanner
I know that this topic has come up before. At various times there were responses indicating that it was being considered at some level within the project(s). How has that played out? Was there progress or has the idea been put on the back-burner? Was something discovered that seems to make the idea not worth pursuing? I'm contemplating doing some investigating of my own to attempt to leverage additional hardware in a distributed way for our application. But I didn't want to end up re-discovering things or try things that have already proved to be a dead end by an effort ongoing within the project. Any insight you could share? -- View this message in context: http://drools.46999.n3.nabble.com/Parallel-Distributed-Optaplanner-tp4029930.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Moves Defined from Current State
I'm using Optaplanner 6.0.1 and I'm having trouble defining a type of move that I'd like to define. In my domain, there may be an opportunity to split the value assigned to one entity across two entities. For example: E1=5could become E2=2, E3=3 The trouble is that in some cases this split can be performed more than one way. The above example could also be split to become E2=1,E3=4, ... At the time that the Moves is created (and initialized with entities) by the MoveFactory, there are values assigned to the entities but those values may change and shouldn't be part of the Move (am I right about that?). So when Moves are executed, the values assigned could be considered to create a set of Moves based on the current state but aren't Moves already created long before then? Is there a way to generate moves based on the current state? How do you ensure they are not cached ore reused after that step? Thanks, Jon -- View this message in context: http://drools.46999.n3.nabble.com/Moves-Defined-from-Current-State-tp4027892.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] SwapMove for Entities with different Value ranges
I'd like to implement something like a swap move but in my domain each Planning Entity has it's own value range provider. The value ranges are completely disjoint sets of value instances although two values from separate ranges can be considered equivalent for the purposes of the swap. I have started implementing my move using ShiftAssignmentSwapMove as a template however I want to be correct and efficient about how and when the work of searching for the value from the leftEntity's value range that is equivalent to the rightEntity's current value. The methods isMoveDoable and doMove must both have this identification made. Can they share the answer with a class variable in a way that is safe under caching configurations? Is there a recommendation for minimizing the repeated effort to identify these equivalent values? Thanks, Jon -- View this message in context: http://drools.46999.n3.nabble.com/SwapMove-for-Entities-with-different-Value-ranges-tp4027852.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Planner with a list of planning variables
Does having PeriodChangeMove and RoomChangeMove undermine the effect of having the swap filter? Since a swap can be constructed by a sequence of changes does the filter reduce the space or simply remove swapMoves that are silly to enact? -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Planner-with-a-list-of-planning-variables-tp4024088p4027734.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Planner with a list of planning variables
I have a related question and I'd like to ask it by extending the domain described here. Say that instead of the solution being one recipe, I am building a multiple-course meal of recipes. The problem will define the course slots including the maximum number of ingredients that can be used and the list of ingredients allowed for the slots of that course. Not all courses must have a recipe built. If the constraints of the guests can be satisfied with fewer courses, the caterer saves money. Each course is one recipe as described here: a list of ingredients (in my case i don't particularly care about the order of the ingredients within the recipe). Certainly each recipe does not need to use it's maximum number of ingredients. In my current implementation, I have a flattened list of assignment Planning Entities where each assignment represents an ingredient slot of a course mapped ingredient). For example if the first course has a maximum of 5 ingredients, the second course has a maximum of 10 ingredients, and the third has a maximum of 3 ingredients, my problem would have a list containing 18 Planning Entities all in one list. The trouble with this approach is that each slot is a separate entity. This means that assigning the ingredient to each of the 5 possible slots of first course is considered a separate solution when in reality it doesn't matter which slot of the course the ingredient ends up in. This makes the search space much larger than it needs to be and results in a lot of swapping of ingredient assignments within the same course which results in no change in score. Is there a recommended pattern to model this domain efficiently? Is there a modification that I can apply to my current representation of this domain which will allow an ingredient assigned to any slot of a course to be considered the same? Thanks, Jon -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Planner-with-a-list-of-planning-variables-tp4024088p4027704.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Optaplanner with Apache Commons Collections 4.0
Apache Commons Collections 4.0 has been released and has some data structures that I'm interested in using in my application. To your knowledge can Optaplanner function with version 4.0 swapped in place of 3.2.1? I have tried this and not encountered any issues at build or run time but that of course doesn't mean they aren't there. Will the next release of Optaplanner leverage this more recent release of Collections? Thanks, Jon -- View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-with-Apache-Commons-Collections-4-0-tp4026958.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Optaplanner: Unexpected global [scoreHolder] - Kie API trouble
It seems to also throw this error any time the path includes the character: \ Even properly escaped in the string as \\ -- View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-Unexpected-global-scoreHolder-tp4023837p4026886.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Optaplanner: Unexpected global [scoreHolder] - Kie API trouble
I am calling KieFileSystem.write(String path ,String content) but the same issue may be experienced with any of the versions of write that take a path parameter but I haven't tried them. I found that if the path parameter includes a character \ there is no error produced when calling KieFileSystem.write(...). When a KieBuilder.buildAll() is called a warning is logged: [o.d.compiler.kie.builder.impl.AbstractKieModule ] No files found for KieBase defaultKieBase Then when solving begins the exception is thrown: java.lang.RuntimeException: Unexpected global [scoreHolder] (the same stack trace provided at the beginning of this thread). For my code I've done a String regex just before the write call to swap any \ into / replaceAll(,/) -- View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-Unexpected-global-scoreHolder-tp4023837p4026888.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Optaplanner: Unexpected global [scoreHolder] - Kie API trouble
The exception is not finally thrown until the call to solver.solve(); -- View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-Unexpected-global-scoreHolder-tp4023837p4026891.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Optaplanner: Shadow Variables vs insertLogical
It turns out that the score corruption was caused by something unrelated. In fact, a rule that will be removed in the re-design I am asking about. If I see a similar problem after the re-design I'll pursue your suggestions to determine the reason. However I was wondering if you had more insight into the Shadow Variable vs insertLogical() question for my domain. I imagine that the insertLogical() approach would fire for each line of an order (Planning Entity) and insert a fact for each type of raw material in the order where each fact contains the number of that type of raw material. Then, a rule with a different salience would accumulate all of these facts to produce total counts of each type across all orders. Is this an appropriate approach? Does this approach break the delta score calculation? Will the creation, (automated) retraction, and accumulation of these facts create a slowdown or is this an intended use? I imagine that the Shadow Variable approach would update a similar set of total count variables but instead do so appropriately when the Planning Variable changes. Would the classes representing the raw material types themselves become Planning Entities in this case? Is this the intended use? Thanks, Jon -- View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-Shadow-Variables-vs-insertLogical-tp4024863p4024928.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Optaplanner: Shadow Variables vs insertLogical
ge0ffrey wrote But the first question is why you're getting score corruption the first place. Of course I'm not sure of the cause of the score corruption. I assume that it is due to my rules using an accumulator over Planning Entities in the When portion of the rule and that somehow confusing the delta score calculations. I hoped that a rule redesign based on Shadow Variables or insertLogical rather than accumulators would be more efficient and not result in score corruption. Jon -- View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-Shadow-Variables-vs-insertLogical-tp4024863p4024872.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Optaplanner: Shadow Variables vs insertLogical
I noticed the recent introduction of the concept of Shadow Variables in the Optaplanner. I'm wondering if someone could help me understand the difference between Shadow Variables and inserting facts with insertLogical()? Each are described a little bit in the manual and it seems that there is a similar use case but I'm not sure I understand the implications of using one over the other? I see that some of the examples still use insertLogical so I'm assuming that shadow variables are not a replacement in every case. To help frame the answer, consider the following toy problem which maps to my domain fairly well: Say my problem is creating purchase orders of raw materials for my factory from various vendors. The input states how many of each raw material I need. Obviously I would want to minimize cost but I also have no capacity to store extra raw materials so any extra that I buy will be waste. Therefore, I'll want to create a list of orders that obtains exactly the required number of each if possible. Each vendor offers package deals that include different combinations of raw materials in different amounts. There would clearly be other optimizations such as reducing the number of vendors used but those would likely be secondary to the cost and waste optimizations. The domain model for this problem would include a Planning Value for each individual raw material item as well as one for each package combo offered by a vendor (essentially anything with a price). So, for a problem space like this, I'll want rules which count the number of each raw material type across all of the different packages purchased from different vendors and make sure it meets the needs of the particular provided problem. Currently I am using a rule that fires for each raw material type and counts the number of units ordered for that type using an accumulator over Planning Entities. I am currently experiencing score corruption which I believe may be due to this approach so I am looking to redesign. Would Shadow Variables or calls to insertLogical() be more appropriate/efficient for this use? Thanks in advance, Jon -- View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-Shadow-Variables-vs-insertLogical-tp4024863.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Lazy Planning Value Validation
I am using Optaplanner 6.0.0.beta2. Like most domains, I am working where it is possible that a given planning value is invalid to assign to some planning entities. However, it is impractical to perform a thorough validity check against every combination in order to a Value Range list containing only valid assignments. I could simply create a Hard Constraint rule to test for these invalid assignments but I fear the validity check may even too computationally expensive for this (i.e. run for each potential step during step selection). Also, this does not prevent the Optaplanner from considering this assignment in the future in a slightly different context. Instead, what I'd prefer is to only check the validity of an assignment after it is used as part of a solution which improved the score. That way it is never called for any of the huge space of possible assignments that won't ever be part of a final solution anyway. If the assignment turns out to be invalid in this check, I'd like to remove it from the Value Range so it is never considered again. Is there a way to have the Optaplanner behave this way? Which components should I investigate implementing (a forager)? How does the Optaplanner respond to run-time changes? Once, discovered, can I simply remove the invalid planning value from the value range for the planning entity? Thanks, Jon -- View this message in context: http://drools.46999.n3.nabble.com/Lazy-Planning-Value-Validation-tp4024095.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Lazy Planning Value Validation
Thanks for the feedback. I'll look into DefaultDecider to see if I can make a version that suits this need and hold my breath for multi-step score evaluation. For clarity I'd like to address your comment below: ge0ffrey wrote If the assignment turns out to be invalid in this check, I'd like to remove it from the Value Range so it is never considered again. That's weird: - either you can predict it's never going to be valid for a certain entity, no matter the variable state of the other entities = use @ValueRange(FROM_ENTITY) - or you can't (not without taking a look at the variable state of the other entities = invalid for a single solution does not mean you can just remove it to be never considered again You're right. In this case, I CAN predict that it's never going to be valid for a certain entity. My concern is the computational effort that is required in order to make that decision. I'm afraid that making that determination for every single planning value (a huge space) would take too long. Since many of those planning values are unlikely to yield a valuable score, I was hoping to delay the validation until I know they may be useful in a solution. Would removing a planning value from the value range at run time be problematic? Jon -- View this message in context: http://drools.46999.n3.nabble.com/Lazy-Planning-Value-Validation-tp4024095p4024098.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] [Optaplanner] No-arg constructor for BendableScoreDefinition
I have switched to 6.0.0.beta2 and I am still receiving a similar error. While BendableScoreDefinition does now have a no-arg constructor, It seems that XStream is still upset that the constructor is not public. ... Caused by: java.lang.IllegalArgumentException: The scoreDefinitionClass (class org.optaplanner.core.impl.score.buildin.bendable.BendableScoreDefinition) does not have a public no-arg constructor at org.optaplanner.persistence.xstream.XStreamScoreConverter.init(XStreamScoreConverter.java:43) ... 17 more Caused by: java.lang.IllegalAccessException: Class org.optaplanner.persistence.xstream.XStreamScoreConverter can not access a member of class org.optaplanner.core.impl.score.buildin.bendable.BendableScoreDefinition with modifiers private at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:95) at java.lang.Class.newInstance0(Class.java:366) at java.lang.Class.newInstance(Class.java:325) at org.optaplanner.persistence.xstream.XStreamScoreConverter.init(XStreamScoreConverter.java:38) ... 17 more -- View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-No-arg-constructor-for-BendableScoreDefinition-tp4023523p4023961.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Optaplanner: Unexpected global [scoreHolder] - Kie API trouble
My problem turned out to be due to a lack of understanding of what KieFileSystem does. I'm still not sure i fully understand but I noticed that you added a fixed prefix to your path provided to kieFileSystem.write(...) I didn't have this prefix and used the provided path directly. When this path was absolute or did not fall under what KieFileSystem obviously prefers, i would get the Unexpected global [scoreHolder] error once planning started. From what I can tell, this error occurred anytime the provided path began with something other than src/main/resources/ Jon -- View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-Unexpected-global-scoreHolder-tp4023837p4023868.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Optaplanner: Unexpected global [scoreHolder]
I am using Optaplanner 6.0.0-Beta2 and I am in some cases receiving the following error during initial solution construction: Exception in thread main java.lang.RuntimeException: Unexpected global [scoreHolder] at org.drools.core.common.AbstractWorkingMemory.setGlobal(AbstractWorkingMemory.java:515) at org.drools.core.impl.StatefulKnowledgeSessionImpl.setGlobal(StatefulKnowledgeSessionImpl.java:360) at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.resetKieSession(DroolsScoreDirector.java:83) at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.setWorkingSolution(DroolsScoreDirector.java:74) at org.optaplanner.core.impl.solver.scope.DefaultSolverScope.setWorkingSolutionFromBestSolution(DefaultSolverScope.java:176) at org.optaplanner.core.impl.solver.DefaultSolver.solvingStarted(DefaultSolver.java:176) at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:154) I noticed this error in gist: https://gist.github.com/ge0ffrey/5236604 If this is the same error, what are the current constraints that I need adhere to in order to avoid this error? Jon -- View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-Unexpected-global-scoreHolder-tp4023837.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] [Optaplanner] No-arg constructor for BendableScoreDefinition
Is there an example that uses BendableScore? I'm trying to convert my app from using HardSoftScore to BendableScore and I've run into my first issue: Changing from: @XStreamConverter(value = XStreamScoreConverter.class, types = {HardSoftLongScoreDefinition.class}) to @XStreamConverter(value = XStreamScoreConverter.class, types = {BendableScoreDefinition.class}) throws: Caused by: java.lang.IllegalArgumentException: The scoreDefinitionClass (class org.optaplanner.core.impl.score.buildin.bendable.BendableScoreDefinition) does not have a public no-arg constructor. The answer to this issue would be helpful but I'll probably hit other bumps along the way. Does anyone have an example that uses BendableScore? Thanks, Jon -- View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-No-arg-constructor-for-BendableScoreDefinition-tp4023523.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] [Optaplanner] No-arg constructor for BendableScoreDefinition
Sorry. This is in 6.0.0.Beta1 -- View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-No-arg-constructor-for-BendableScoreDefinition-tp4023523p4023525.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Planner: How to Set Global Varaiables
I see in the documentation for Drools Expert a description of how to set global variables through the API via a StatefullKnowledgeSession or StatelessKnowledgeSession. How is this achieved when using the Drools Planner? I have a solver instance that is created from a XmlSolverFactory (as shown in the examples). Is there a sequence of getters calls originating at the Solver instance that ultimately gets to the ksession on which setGlobal can be called? -- View this message in context: http://drools.46999.n3.nabble.com/Planner-How-to-Set-Global-Varaiables-tp4021333.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users