please help on complex rule (linking entities)
by Dave Brubanks
Hi all,
(after writing this mail I realized that it became quite long, but please hang in there with me. my actual question is not that big, I only need to build some context.)
I need to implement a planning for placing new floors in hotels (renovation).
Renovating a single hotel requires a number of jobs. For example
- replacing wooden floor in the lobby
- replacing carpets in the bedrooms
- replacing tiles in the bathroom
Each kind of replacement is done by a specialized kind team.
Thus for example a team that places wooden floors will only do that.
for each renovation project we decide which jobs are needed (for example only carpet and tiles) and we make an estimate of how many people we want to send there and how long it will take to complete the job.
For example: we have a
Renovation A
- replacing wooden floor : 3 weeks, 2 workers
- replacing carpet floor : 5 weeks, 4 workers
- replacing tiles: 4 weeks, 5 workers
Renovation B
- replacing carpet floor : 3 weeks, 1 workers
- replacing tiles: 3 weeks, 2 workers
... and so on.
Now we need to schedule the renovations.
Actually we took the replacement jobs as planning entity, I hope that was the right choise:
In case of renovation A we will have
- 2 jobs of type wood, each lasting 3 weeks.
- 4 jobs of type carpet, each lasting 5 weeks
- 5 jobs of type tile, each lasting 4 weeks.
I currently do not have projects as facts. I do have the project-id set on a Job on its instantiation (so I know which jobs belong together).
When scheduling the jobs of a renovation we need to follow these rules:
- it does not matter when a renovation is planned (for now) (within a given number of weeks - usually 12)
- a resource with the required skill needs to be available for doing that kind of job (planning-variable)
- the start of a job needs to be planned in a week (one of 12 - planning 12 weeks at the time) - we do not plan exactly on a day.
- the job is always done in 1 sequential block of x weeks, no gaps between.
- !! all jobs need to be done within the time of the longest job in the project.
So in Renovation A all jobs need to be fitted in a time span of 5 weeks.
In Renovation A the wooden-floor team can start in week 1, 2 or 3 of the 5-week span.
- the jobs of a project do not have to start in the same week (for better occupation)
I already have some rules up and running, but the one I cannot figure how to do is how I can plan the jobs of a renovation project so that they all are planned within the span of the largest job.
Currently I have all jobs of a project to start in the same week... but that limits the number of solutions.
In order to get this extra flexibility, do I need to introduce a kind of holder-fact (project)?
Any ideas will be greatly appreciated.
Thanks
Davido
13 years
No String constructor found on type [org.drools.builder.ResourceType]
by ashokkuppuswamy
I am trying to integrate with spring and I am stuck on this error
2012-12-05 04:43:45 [main] DEBUG
org.springframework.core.env.StandardEnvironment - Adding
[systemProperties] PropertySource with lowest search precedence
2012-12-05 04:43:45 [main] DEBUG
org.springframework.core.env.StandardEnvironment - Adding
[systemEnvironment] PropertySource with lowest search precedence
2012-12-05 04:43:45 [main] DEBUG
org.springframework.core.env.StandardEnvironment - Initialized
StandardEnvironment with PropertySources
[systemProperties,systemEnvironment]
2012-12-05 04:43:45 [main] DEBUG
org.springframework.core.env.StandardEnvironment - Initializing new
StandardEnvironment
2012-12-05 04:43:45 [main] DEBUG
org.springframework.core.env.StandardEnvironment - Adding
[systemProperties] PropertySource with lowest search precedence
2012-12-05 04:43:45 [main] DEBUG
org.springframework.core.env.StandardEnvironment - Adding
[systemEnvironment] PropertySource with lowest search precedence
2012-12-05 04:43:45 [main] DEBUG
org.springframework.core.env.StandardEnvironment - Initialized
StandardEnvironment with PropertySources
[systemProperties,systemEnvironment]
2012-12-05 04:43:45 [main] DEBUG
org.springframework.core.env.StandardEnvironment - Initializing new
StandardEnvironment
2012-12-05 04:43:45 [main] DEBUG
org.springframework.core.env.StandardEnvironment - Adding
[systemProperties] PropertySource with lowest search precedence
2012-12-05 04:43:45 [main] DEBUG
org.springframework.core.env.StandardEnvironment - Adding
[systemEnvironment] PropertySource with lowest search precedence
2012-12-05 04:43:45 [main] DEBUG
org.springframework.core.env.StandardEnvironment - Initialized
StandardEnvironment with PropertySources
[systemProperties,systemEnvironment]
2012-12-05 04:43:45 [main] DEBUG org.springframework.beans.BeanUtils - No
property editor [org.drools.builder.ResourceTypeEditor] found for type
org.drools.builder.ResourceType according to 'Editor' suffix convention
2012-12-05 04:43:45 [main] DEBUG
org.springframework.beans.TypeConverterDelegate - No String constructor
found on type [org.drools.builder.ResourceType]
java.lang.NoSuchMethodException:
org.drools.builder.ResourceType.<init>(java.lang.String)
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getConstructor(Class.java:1657)
at
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:197)
at
org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470)
at
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516)
at
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:510)
This is the config I have
<jbpm:kbase id="kbase">
<jbpm:resources>
<jbpm:resource type="BPMN2" source="classpath:Evaluation.bpmn"/>
</jbpm:resources>
</jbpm:kbase>
Any help is greatly appreciated.
--
View this message in context: http://drools.46999.n3.nabble.com/No-String-constructor-found-on-type-org...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years
Mixing Drools language and Java implementions without performance loss
by Oliver Libutzki
Hello everyone,
as I try to find the best solution for a scheduling problem Drools
Planner seems to be the perfect fit.
Instead of using drl files I want to implement the rules in Java, but I
still would like to use the power of Drools (Planner) to find the best
solution as fast as possible.
My first attempt is to use the Description API (Examples:
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test...).
This might work, but I wonder if I really have to write the whole rule
this way. Of course I can use "eval" Expressions to integrate Java code,
but I would like to know how expensive this is in certain situations.
So, which information does Drools use to optimize the algorithm?
An example taken from the Test class I mentioned:
.lhs()
.pattern("StockTick").constraint("company ==
\"RHT\"").end()
.end()
I guess it's important to select the StockTick by using the pattern. But
what about the company criteria? Is using the constraint faster than
invoking a method like "checkType"?
.lhs().pattern("StockTick").name("myStockTick").eval().constraint(
"checkCompany(myCheese, \"RHT\"").end()
.end()
In general, I would like to know which parts can be implemented in
"secret Java" which the drools compiler doesn't know and which parts
should be implemented by using the explicit descr api elements in order
to use the full power of the Drools engine. Thanks for your answers!
Kind regards Oliver
13 years
How to ensure that a person does not execute the same task twice in a row?
by Michiel Vermandel
Hi,
In my usecase I need to plan tasks (PlanningEntity).
I have two kinds of tasks (for example CleaningTask and InspectionTask (inspect that cleaning was OK)).
Each taskneeds to be assigned to a person and a period.
Person and period both are PlanningVariables.
I need to ensure that a person does not execute an InspectionTask twice in a row.
How can I find out what the previous task is that is assigned to a person?
It is not guaranteed that the person had a task in the previous period (period-1).
Thanks,
Michiel
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials
13 years
Re: [rules-users] Value is not reflected in Fact Object at Drool Client Side
by Esteban Aliverti
'*MortgageAgent'*is just the name you want to use for the agent. You could
use whatever name you want. The important parts of the code snippet are:
Resource changeset = ResourceFactory.newClassPathResource(
"org/drools/guvnor/examples/mortgage/mortgage-changeset.xml");
kagent.applyChangeSet(changeset);
Please take a look at the content of 'mortgage-changeset.xml' to get a
better understanding of how this works.
Best Regards,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
- Blog @ http://ilesteban.wordpress.com
On Wed, Dec 5, 2012 at 10:44 AM, Hushen Savani
<hushen.savani(a)elitecore.com>wrote:
> MortgageAgent
13 years
Re: [rules-users] Value is not reflected in Fact Object at Drool Client Side
by Esteban Aliverti
I'm wondering where did you get the content of that Guvnor.properties file.
The problem you are having is that the property file is not used to tell
the agent which resources should it use, but to set some of its internal
configurations such as:
- drools.agent.monitorChangeSetEvents (boolean)
- drools.agent.scanDirectories (boolean)
- drools.agent.scanResources (boolean)
- drools.agent.newInstance (boolean)
- drools.agent.useKBaseClassLoaderForCompiling (boolean)
- drools.agent.validationTimeout (long)
So, the properties you have there are not even being user, nor understood,
by drools.
In order to tell the agent which resources should it use, you must provide
a change-set pointing to those resources. You can find more information
about change-sets in Drools documentation.
Best Regards,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
- Blog @ http://ilesteban.wordpress.com
On Wed, Dec 5, 2012 at 8:52 AM, Hushen Savani
<hushen.savani(a)elitecore.com>wrote:
> It seems that problem is with rule consumer (client), because even when
> I mess up with url of guvnor, it is giving me the same behavior:****
>
> ** **
>
> *Guvnor.properties*:****
>
> ** **
>
> url=http://localhost:10080/ *guvnor*-5.5.0.Final-*tomcat*
> -6.0/org.drools.guvnor.Guvnor/package/new *Pkg*/car111_*messed_up_url*****
>
> enableBasicAuthentication=true****
>
> username=*admin*****
>
> password=*admin*****
>
> name=*drooltest*
>
> * *
>
> ** **
>
> *Drool Consumer*:****
>
> ** **
>
> *package* kijanowski.eu;****
>
> ** **
>
> *import* java.util.Collection;****
>
> *import* java.util.Iterator;****
>
> ** **
>
> *import* org.drools.KnowledgeBase;****
>
> *import* org.drools.agent.KnowledgeAgent;****
>
> *import* org.drools.agent.KnowledgeAgentFactory;****
>
> *import* org.drools.runtime.StatefulKnowledgeSession;****
>
> ** **
>
> *public* *class* GuvnorTest {****
>
> ** **
>
> *public* *static* *final* *void* main(String[] args) {****
>
> ** **
>
> KnowledgeAgent agent = KnowledgeAgentFactory.*
> newKnowledgeAgent*("/Guvnor.properties"); ****
>
> KnowledgeBase ruleBase = agent.getKnowledgeBase();****
>
> ** **
>
> StatefulKnowledgeSession workingMemory =
> ruleBase.newStatefulKnowledgeSession();****
>
> ****
>
> Driver d = *new* Driver("Jarek", 20, *null*);****
>
> workingMemory.insert(d);****
>
> ** **
>
> workingMemory.fireAllRules();****
>
> ****
>
> *Collection* c = workingMemory.getObjects();****
>
> ****
>
> *for*(*Iterator* i = c.iterator(); i.hasNext();) {****
>
>
> //System.out.println(i.next().getClass().getCanonicalName());****
>
> Driver e = (Driver)i.next();****
>
> System.*out*.println(" Age: " + e.getAge() + " Name: "+ e.getName() + "
> Car: " + e.getCar() + " Object: " + e);****
>
> }****
>
> }****
>
> }****
>
> ** **
>
> Can anyone please suggest some pointers on the same.****
>
> ** **
>
> Thanks.****
>
> ** **
>
> Best Regards****
>
> *Hushen Savani*****
>
> ** **
>
> *From:* rules-users-bounces(a)lists.jboss.org [mailto:
> rules-users-bounces(a)lists.jboss.org] *On Behalf Of *Esteban Aliverti
> *Sent:* Tuesday, December 04, 2012 9:38 PM
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Value is not reflected in Fact Object at
> Drool Client Side****
>
> ** **
>
> Sorry, I've just re-read your post and saw that you already mentioned that
> you are not seeing the system.out of your rule.****
>
> What you can do is to debug (or add some code) to see which rules do you
> have in the kbase returned by the kagent.****
>
> My guess is that your are not getting what you are expecting from Guvnor.*
> ***
>
> ** **
>
> Best Regards, ****
>
>
>
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
> Esteban Aliverti
> - Blog @ http://ilesteban.wordpress.com
>
> ****
>
> On Tue, Dec 4, 2012 at 5:03 PM, Esteban Aliverti <
> esteban.aliverti(a)gmail.com> wrote:****
>
> Do you see the message you are printing in the RHS of your rule?****
>
> ** **
>
> Best Regards,****
>
>
>
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
> Esteban Aliverti
> - Blog @ http://ilesteban.wordpress.com****
>
>
>
> ****
>
> On Tue, Dec 4, 2012 at 3:28 PM, Mister Nono <noel.maurice(a)univ-jfc.fr>
> wrote:****
>
> Hi,
>
> Have you try to add in the then of the drools rule the line : *update(a);*
>
> Best regards. ;)
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/rules-users-Value-is-not-reflected-in-F...
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users****
>
> ** **
>
> ** **
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
13 years
Guvnor and Global Functions
by Dean Whisnant
I'm using Drools/Guvnor version 5.1.1.
In the Global Area of Guvnor, under functions, I've created a function called splitDiagnosis.
In another package, we'll call it V222, I have a rule called LoadDiag.
In the Then section of the rule, I set the value of a field "=splitDiagnosis(diag,type)"
When run through our live software, the rule errors out because it evidently does not see the global area. If the rule is in the local package, then it works properly, but I have dozens of packages that all need access to this function and I don't want to keep copying it from one package to another.
I must be missing something to tell package V222 to include the global area. Any thoughts?
Thank you,
Dean Whisnant
13 years
Value is not reflected in Fact Object at Drool Client Side
by Hushen Savani
Hi,
I m a newbie. Again, stuck with a problem.
I have created a package in Drools Guvnor as:
Created two POJO. Driver and Car as following:
Driver.java:
package kijanowski.eu;
public class Driver {
private String name;
private int age;
private Car car;
public Driver(String name, int age, Car car) {
this.name = name;
this.age = age;
this.car = car;
}
.
//Setter and Getters
.
}
Car.java:
package kijanowski.eu;
public class Car {
private String color;
private double value;
public Car() {}
public Car(String color, double value) {
this.color = color;
this.value = value;
}
.
//Setter and Getters
.
}
Prepared its jar and uploaded to Guvnor as following:
Both POJO are loaded successfully:
Then I created a new rule as following:
Then I verified, build and created Snapshot.
Now, I prepared a client program to consume rules deployed
in guvnor as following:
package kijanowski.eu;
import java.util.Collection;
import java.util.Iterator;
import org.drools.KnowledgeBase;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.runtime.StatefulKnowledgeSession;
public class GuvnorTest {
public static final void main(String[] args) {
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("/Guvnor.properties");
KnowledgeBase kbase = kagent.getKnowledgeBase();
StatefulKnowledgeSession workingMemory =
kbase.newStatefulKnowledgeSession();
Driver d = new Driver("Jarek", 20, null);
workingMemory.insert(d);
workingMemory.fireAllRules();
Collection c = workingMemory.getObjects();
for (Iterator i = c.iterator(); i.hasNext();) {
d = (Driver)i.next();
System.out.println(" Age: " + d.getAge() + " Name: " +
d.getName() + " Car: " + d.getCar() + " Object: " + d);
}
}
}
And Guvnor.properties is as following:
url=http://localhost:10080/guvnor-5.5.0.Final-tomcat-6.0/org.drools.guvnor.G
uvnor/package/myNewPackage/car_example_snapshot
enableBasicAuthentication=true
username=admin
password=admin
name=drooltest
But when I run the client, I get following o/p:
Age: 20 Name: Jarek Car: null Object:
kijanowski.eu.Driver@15b9e68
I cannot see name changed to "Applicable" and cannot even see the o/p
of sysout on server side:
Can anyone please help me with this. Thanks.
Best Regards
Hushen Savani
13 years
Rules Unit Testing
by John Poole
How is unit testing handled for rules? I'm playing with the nurse
rostering app and the only test I see is a performance test.
-John
13 years
Using outcome of previous planning as input of new planning
by Michiel Vermandel
Hi,
We need to plan tasks over a period of 6 months.
But when the next planning is done (months after the first planning) we need to know some details about the previous planning.
For example, a person should not execute the same task twice in a row.
So I need to know who did a specific task in the previous planning in order to verify that it is not the same in this planning.
Do I need to persist the solution of the first planning?
Is there any example amongst the list of available examples which can give me a head-start on this?
Any help is greatly appreciated.
Regards,
Michiel
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials
13 years