Re: [rules-users] Drools 6.0.1 Negative Patterns in Stream Mode not working

2014-05-07 Thread rjh
You should set TimedRuleExectionOption to YES. 

See here
http://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html_single/index.html#d0e592



--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-6-0-1-Negative-Patterns-in-Stream-Mode-not-working-tp4029463p4029474.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] Drools 6.0.1 Negative Patterns in Stream Mode not working

2014-05-07 Thread Mark Proctor
Can you try 6.1 beta2? And if there is still a bug, please open a jira:
http://mvnrepository.com/artifact/org.drools/drools-core/6.1.0.Beta2

Ideally please submit a self contained unit test, as a pull request. As 
explained here:
http://docs.jboss.org/drools/release/5.5.0.Final/droolsjbpm-introduction-docs/html/gettingstarted.html

Mark


On 7 May 2014, at 14:44, RichardAmbridge  wrote:

> I am using drools 6.0.1 and I have the following test.
> 
> public class DroolsTest {
> 
>public DroolsTest() {
>}
> 
>@Test
>public void work() throws InterruptedException, IOException,
> ClassNotFoundException {
> 
>StringBuilder sb = new StringBuilder();
>sb.append("package drools\n");
>sb.append("import drools.MyObject;\n\n");
> 
>sb.append("declare MyObject\n"
>+ " @role ( event )\n"
>+ "end\n\n");
> 
>sb.append("rule \"Template2\"\n"
>+ "\n"
>+ "salience 0\n"
>+ "dialect \"mvel\"\n"
>+ "when\n"
>+ "  $s : MyObject(val==0)\n"
>+ "  not( MyObject(val==1, this after [0s,5s] $s ) )\n"
>+ "\n"
>+ "then\n"
>+ "  System.out.println(\"Template 2 fired\")\n"
>+ "   $s.name=\"2\";\n"
>+ "\n"
>+ "end\n");
> 
>KieServices kieServices = KieServices.Factory.get();
> 
>KieFileSystem kfs = kieServices.newKieFileSystem();
>kfs.write("src/main/resources/rules.drl", sb.toString());
> 
>KieBuilder kieBuilder = kieServices.newKieBuilder(kfs);
>kieBuilder.buildAll();
>Results results = kieBuilder.getResults();
>assertFalse(results.hasMessages(Message.Level.ERROR));
>if (results.hasMessages(Message.Level.WARNING)) {
>System.out.println("Warnings logged");
>}
>KieContainer kieContainer =
> kieServices.newKieContainer(kieBuilder.getKieModule().getReleaseId());
> 
>KieBaseConfiguration kieBaseConfiguration =
> kieServices.newKieBaseConfiguration();
>kieBaseConfiguration.setOption(EventProcessingOption.STREAM);
>KieBase kieBase = kieContainer.newKieBase(kieBaseConfiguration);
>KieSession ksession = kieBase.newKieSession();
> 
>MyObject one = new MyObject();
>one.val = 0;
> 
>FactHandle fh1 = ksession.insert(one);
>System.out.println("Insert one");
>ksession.fireAllRules();
>for (int i = 0; i < 13; i++) {
>System.out.println("Sleep:" + i);
>Thread.sleep(1000);
>//After 5 seconds, rule should fire
>}
>assertEquals("2", one.name);
> 
>System.out.println("End");
>ksession.halt();
>ksession.dispose();
>}
> 
>public class MyObject implements Serializable {
> 
>String name;
>int val;
>boolean fired;
> 
>public String getName() {
>return name;
>}
> 
>public void setName(String name) {
>this.name = name;
>}
> 
>public int getVal() {
>return val;
>}
> 
>public void setVal(int val) {
>this.val = val;
>}
> 
>public boolean isFired() {
>return fired;
>}
> 
>public void setFired(boolean fired) {
>this.fired = fired;
>}
> 
>}
> }
> 
> 
> The rule is using 
> + "  $s : MyObject(val==0)\n"
> + "  not( MyObject(val==1, this after [0s,5s] $s ) )\n"
> 
> So, if a MyObject with val==0 is inserted, then after 5 seconds no MyObject
> with val==1 is found the rule will fire.
> This works in Drools 5.5.0
> 
> In 6.0.1 the rule doesn't fire.
> 
> Please help. I want to use drools 6 but cannot with this problem.
> 
> Thanks
> 
> 
> 
> 
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/Drools-6-0-1-Negative-Patterns-in-Stream-Mode-not-working-tp4029463.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 mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] How to implement immovable planning entities for vehicle routing problem?

2014-05-07 Thread Hagai
I am implementing a vehiclerouting like solution with OptaPlanner
6.0.1.Final.
According to the documentation for continuous planning, the way to 'lock'
parts of the solution is by declaring a movableEntitySelectionFilter on the
planning entity: Section 14.3.1. Immovable planning entities.
However, this does not work well with chained entities where parts of the
solution is calculated, like in the vehiclerouting example.

For example, let's assume the following chains, where [Customer A] and
[Customer C] are immovable:
[Vehicle 1] <- *[Customer A]* <- [Customer B]
[Vehicle 2] <- *[Customer C]* <- [Customer D]

Even if we filter immovable entities, a move to set the variable [Vehicle 2]
as previous standstill to [Customer B] can be selected with the following
result that changes the immovable entity [Customer C]:
[Vehicle 1] <- *[Customer A]* 
[Vehicle 2] <- [Customer B] <- *[Customer C]* <- [Customer D]

A workaround is to filter moves with immovable entities as well as moves
with immovable variables (variables are also entities). However, this can
only work when immovable entities are placed at the beginning of chines
before any movable entities. 

Is there a better way to implement immovable planning entities for vehicle
routing problem?



--
View this message in context: 
http://drools.46999.n3.nabble.com/How-to-implement-immovable-planning-entities-for-vehicle-routing-problem-tp4029467.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] KieScanner not working

2014-05-07 Thread pictin
Created https://issues.jboss.org/browse/DROOLS-477



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-KieScanner-not-working-tp4029446p4029466.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] KieScanner not working

2014-05-07 Thread Mario Fusco
Our Jira is here: https://issues.jboss.org/browse/DROOLS
Can you please open a ticket there and also attach your sample projects so I
can be sure that I am reproducing your issue?

Thanks,
Mario



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-KieScanner-not-working-tp4029446p4029465.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] KieScanner not working

2014-05-07 Thread pictin
> However I confirm that it is not possible to create a KieContainer out of a
project that doesn't contain a kmodule.xml file.

Sorry, Mario, I didn't make myself clear. My project_jar is indeed a kjar. I
just not looking to have any rules in project_jar dynamically updated. What
I'm focusing on is drools_jar, for which I want the rules to get updated.
project_jar depends on drools_jar:


com.study
drools_jar
0.0.1-SNAPSHOT


Initial version of rules runs just fine when project_jar is deployed.
However, KieScanner is not picking up any updates in drools_jar.

Also, can you please point me to Drools Jira?



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-KieScanner-not-working-tp4029446p4029464.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] Drools 6.0.1 Negative Patterns in Stream Mode not working

2014-05-07 Thread RichardAmbridge
I am using drools 6.0.1 and I have the following test.

public class DroolsTest {

public DroolsTest() {
}

@Test
public void work() throws InterruptedException, IOException,
ClassNotFoundException {

StringBuilder sb = new StringBuilder();
sb.append("package drools\n");
sb.append("import drools.MyObject;\n\n");

sb.append("declare MyObject\n"
+ " @role ( event )\n"
+ "end\n\n");

sb.append("rule \"Template2\"\n"
+ "\n"
+ "salience 0\n"
+ "dialect \"mvel\"\n"
+ "when\n"
+ "  $s : MyObject(val==0)\n"
+ "  not( MyObject(val==1, this after [0s,5s] $s ) )\n"
+ "\n"
+ "then\n"
+ "  System.out.println(\"Template 2 fired\")\n"
+ "   $s.name=\"2\";\n"
+ "\n"
+ "end\n");

KieServices kieServices = KieServices.Factory.get();

KieFileSystem kfs = kieServices.newKieFileSystem();
kfs.write("src/main/resources/rules.drl", sb.toString());

KieBuilder kieBuilder = kieServices.newKieBuilder(kfs);
kieBuilder.buildAll();
Results results = kieBuilder.getResults();
assertFalse(results.hasMessages(Message.Level.ERROR));
if (results.hasMessages(Message.Level.WARNING)) {
System.out.println("Warnings logged");
}
KieContainer kieContainer =
kieServices.newKieContainer(kieBuilder.getKieModule().getReleaseId());

KieBaseConfiguration kieBaseConfiguration =
kieServices.newKieBaseConfiguration();
kieBaseConfiguration.setOption(EventProcessingOption.STREAM);
KieBase kieBase = kieContainer.newKieBase(kieBaseConfiguration);
KieSession ksession = kieBase.newKieSession();

MyObject one = new MyObject();
one.val = 0;

FactHandle fh1 = ksession.insert(one);
System.out.println("Insert one");
ksession.fireAllRules();
for (int i = 0; i < 13; i++) {
System.out.println("Sleep:" + i);
Thread.sleep(1000);
//After 5 seconds, rule should fire
}
assertEquals("2", one.name);

System.out.println("End");
ksession.halt();
ksession.dispose();
}

public class MyObject implements Serializable {

String name;
int val;
boolean fired;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getVal() {
return val;
}

public void setVal(int val) {
this.val = val;
}

public boolean isFired() {
return fired;
}

public void setFired(boolean fired) {
this.fired = fired;
}

}
}


The rule is using 
 + "  $s : MyObject(val==0)\n"
 + "  not( MyObject(val==1, this after [0s,5s] $s ) )\n"

So, if a MyObject with val==0 is inserted, then after 5 seconds no MyObject
with val==1 is found the rule will fire.
This works in Drools 5.5.0

In 6.0.1 the rule doesn't fire.

Please help. I want to use drools 6 but cannot with this problem.

Thanks




--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-6-0-1-Negative-Patterns-in-Stream-Mode-not-working-tp4029463.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] KieScanner not working

2014-05-07 Thread Mohit Srivastava
Yes. As much I know, kmodule.xml is mandatory to use KieContainer.





On Wed, May 7, 2014 at 3:17 PM, Mario Fusco  wrote:

> Oops, sorry Mohit (and sorry Alex). I didn't check the sender of the last
> email and I thought it was sent by the guy who opened this thread.
>
> However I confirm that it is not possible to create a KieContainer out of a
> project that doesn't contain a kmodule.xml file. Do you agree, Mohit?
>
> Mario
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/rules-users-KieScanner-not-working-tp4029446p4029461.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 mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] KieScanner not working

2014-05-07 Thread Mario Fusco
Oops, sorry Mohit (and sorry Alex). I didn't check the sender of the last
email and I thought it was sent by the guy who opened this thread.

However I confirm that it is not possible to create a KieContainer out of a
project that doesn't contain a kmodule.xml file. Do you agree, Mohit?

Mario



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-KieScanner-not-working-tp4029446p4029461.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] KieScanner not working

2014-05-07 Thread Mario Fusco
Alex,

sorry but what you're saying is just NOT possible and it doesn't depend on
kie-ci. If your project_jar doesn't contain a kmodule.xml file, you CANNOT
do something like:

ReleaseId releaseId = ks.newReleaseId( "com.study", "project_jar",
"0.0.1-SNAPSHOT" );
KieContainer kContainer = ks.newKieContainer( releaseId );

If you try to you should get a RuntimeException saying: 

java.lang.RuntimeException: Cannot find KieModule:
com.study:project_jar:0.0.1-SNAPSHOT

I suggest you to open a ticket on our Jira and upload your sample projects
there so I could reproduce your actual issue.

Thanks,
Mario



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-KieScanner-not-working-tp4029446p4029460.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] KieScanner not working

2014-05-07 Thread Mohit Srivastava
Hi,

That was happened to me too, but I change the kie-ci version to
6.1.0.Beta2. That works for me.


On Wed, May 7, 2014 at 1:56 PM, Mario Fusco  wrote:

> Hi Alex,
>
> sorry but I am not fully understanding your use case.
> You wrote that “drools_jar” is a kjar (i.e. is a project containing a
> kmodule.xml file) but "project_jar” isn't.
> Nevertheless in your code snippet you're creating a KieContainer against
> "project_jar” that actually isn't a kproject. Of course this couldn't work
> so I am pretty sure I am misunderstanding the description of your use case.
> Can you please better clarify what is a kjar and what isn't (i.e. which
> project contains the kmodule.xml file). It would be even better if you
> could
> open a ticket on our Jira and attach your samples projects there, so we can
> be sure that I am reproducing exactly your use case.
>
> Thanks,
> Mario
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/rules-users-KieScanner-not-working-tp4029446p4029458.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 mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] KieScanner not working

2014-05-07 Thread Mario Fusco
Hi Alex,

sorry but I am not fully understanding your use case. 
You wrote that “drools_jar” is a kjar (i.e. is a project containing a
kmodule.xml file) but "project_jar” isn't.
Nevertheless in your code snippet you're creating a KieContainer against
"project_jar” that actually isn't a kproject. Of course this couldn't work
so I am pretty sure I am misunderstanding the description of your use case. 
Can you please better clarify what is a kjar and what isn't (i.e. which
project contains the kmodule.xml file). It would be even better if you could
open a ticket on our Jira and attach your samples projects there, so we can
be sure that I am reproducing exactly your use case.

Thanks,
Mario



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-KieScanner-not-working-tp4029446p4029458.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] Drools 6.0.0 activation-group + salience bug or feature?

2014-05-07 Thread Jan Šťastný
Thanks for answer,
well I thought that the activation-group and salience applies only on 
the rules with the same LHS, I mean exact match by equality. But there 
it cancels different ones. Nevermind.

The game doesn't exist (yet). It is for my diploma thesis coordinated by 
Red Hat. I have to implement game logic of civilization-like game.

As for my project, I started blog a while ago, but lately I'm busy 
writing my diploma thesis, so I haven't updated it for a while. Here it 
is: http://civilization-mmo.blogspot.com/ . Also you can visit my github 
account where again there are some projects concerning the game, but 
current version is to be added in short time. Hopefully by 26 may it 
shall be updated.

Jan

Dne 7.5.2014 01:49, Mark Proctor napsal(a):
> That’s what an activation-group does. The first rule (with the highest 
> salience) fires, the others are cancelled.
>
> Out of interest, what’s the game? Something online we can look at? I have an 
> interest in games development for Drools, and have been slowly adding 
> examples. Space invaders was my latest one:
> https://www.youtube.com/watch?v=wORlAZoxttA
> https://github.com/droolsjbpm/drools/tree/master/drools-examples/src/main/java/org/drools/games/invaders
>
> Mark
> On 6 May 2014, at 23:12, Jan Šťastný  wrote:
>
>> Hi,
>> I came across in my view strange behaviour of rules defined with
>> activation-group and salience. I use this combination to set the
>> priority of exclusively fired rules "Democracy City Tiles Production"
>> and "Basic City Tiles Production".
>> Their definitions:
>> rule "Democracy City Tiles Production"
>>  dialect "mvel"
>>  ruleflow-group "manageProductions"
>>  activation-group "cityProduction"
>>  salience 5
>>  when
>>  PlayerDTO($owner:id, government=="democracy")
>>  $city:CityDTO(
>>  owner==$owner
>>  ,$cityId:id
>>  ,$managedTiles:managedTiles
>>  )
>>  accumulate(
>>  TileDTO (
>>  id memberOf $managedTiles
>>  ,$foodProd:foodProduction
>>  ,$resourcesProd:resourcesProduction
>>  ,$tradeProd:tradeProduction
>>  )
>> @watch(foodProduction,resourcesProduction,tradeProduction)
>>  ,$sumFood : sum($foodProd)
>>  ,$sumResources : sum($resourcesProd)
>>  ,$sumTrade :
>> sum(($tradeProd<1)?$tradeProd:($tradeProd+1))
>>  )
>>  UpdateCityProduction(cityId==$cityId)
>>  then
>>  modify($city){
>>  setFoodProduction($sumFood)
>>  ,setResourcesProduction($sumResources)
>>  ,setTradeProduction($sumTrade)
>>  }
>> end
>>
>> and
>>
>> rule "Basic City Tiles Production"
>>  dialect "mvel"
>>  ruleflow-group "manageProductions"
>>  activation-group "cityProduction"
>>  when
>>  PlayerDTO($owner:id)
>>  $city:CityDTO(
>>  owner==$owner
>>  ,$cityId:id
>>  ,$managedTiles:managedTiles
>>  )
>>  accumulate(
>>  TileDTO (
>>  id memberOf $managedTiles
>>  ,$foodProd:foodProduction
>>  ,$resourcesProd:resourcesProduction
>>  ,$tradeProd:tradeProduction
>>  )
>> @watch(foodProduction,resourcesProduction,tradeProduction)
>>  ,$sumFood : sum($foodProd)
>>  ,$sumResources : sum($resourcesProd)
>>  ,$sumTrade : sum($tradeProd)
>>  )
>>  UpdateCityProduction(cityId==$cityId)
>>  then
>>  modify($city){
>>  setFoodProduction($sumFood)
>>  ,setResourcesProduction($sumResources)
>>  ,setTradeProduction($sumTrade)
>>  }
>> end
>>
>> But problem occurs when two CityDTO objects are in the session. I would
>> like to fire one rule for each CityDTO, but the activation-group cancels
>> all the activations after first is fired. So only one activation in
>> place of two fires. Here is the log:
>>
>> ==>[BeforeActivationFiredEvent:  getActivation()=[[ Democracy City Tiles
>> Production active=false ] [ [fact
>> 0:12:36803987:36803987:12:DEFAULT:NON_TRAIT:UpdateCityProduction(
>> cityId=5 )]
>> [fact
>> 0:16:2083264739:2083264739:16:null:NON_TRAIT:[Ljava.lang.Object;@7c2c18e3]
>> [fact 0:11:792938926:966:11:DEFAULT:NON_TRAIT:CityDTO [id=5,
>> name=marefy, cityCentre=null, owner=1, improvements=[],
>> currentImprovement=null, enabledImprovements=[], homeUnits=[],
>> currentUnit=null, enabledUnitTypes=[], tradeRoutes=[], managedTiles=[1,
>> 2], size=5, weLoveDay=false, disorder=false, foodProduction=0,
>> foodConsumption=0, foodSurplus=0, foodStock=0, resourcesProduction=0,
>> resourcesConsumption=0, resourcesSurplus=null, trade