[Optaplanner] No-arg constructor for BendableScoreDefinition
by jonathan.labin
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-Bend...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 7 months
G+ HashTags
by Mark Proctor
G+ now supports hashtags.
https://marketingland.com/up-close-with-the-new-google-related-hashtags-4...
This means anyone can write a small Drools or jBPM article, and get association via the use of a hashtag. So if you write anything about Drools, jBPM, OptaPlanner, Uberfire etc, please do hashtag it. Here is the list we are using now:
#Drools
#jBPM
#Guvnor
#UberFire
#OptaPlanner
I'm currently trying to encourage all developers to keep small diary entries, and use hashtags, so people can get a feel for work being done.
Mark
11 years, 7 months
entry-point + accumulate in same rule using BRL (Guided Rule Editor)
by Ravi Gupta
I can't seem to re-create the below in BRL (entry-point + accumulate)
I want to combine an entry-point and an accumulate function such as (the
below is DRL, which works)
*rule "GSS-Sev1-Monitor"*
* no-loop true*
* dialect "mvel"*
* when*
* $ticketStatistics : TicketStatistics( $ID : ID == null )*
* accumulate($supportTicket:SupportTicket( ticketStatisticsID ==
$ID , severity == "Sev-1" ) over window:time (5m) from entry-point
"gss-support-stream", $num : count( $supportTicket ))*
* then*
* $ticketStatistics.currentTicketCount = $num;*
* update( $ticketStatistics );*
* end*
I can't seem to re-create this in Guvnor (BRL)
11 years, 7 months
Shadow fax
by ronan.quintin
Hello,
First of all i have to appologise for this horrible joke, but i think you
understand that i'm interrested in shadow facts.
I read that theses lazy facts proxy were introduced in Drools 4 in order to
make the rule engine/working memory consistent. I have some questions about
the general implentation of shadow facts in drools 5.4 :
- Did the shadow facts been implemented since version 4, or was it earlyier?
- Are the shadow facts still implemented in drools 5.4 final?
- How the mapping between the fact fields and the proxy fields is
implemented ? By this i want to know all fields are copy when the fact is
insert into the session.
- Is there the possibility to disable shadow facts ?
You have to know that we get the knowledgeBase through a knowledgeAgent
which
Thank you.
--
View this message in context: http://drools.46999.n3.nabble.com/Shadow-fax-tp4023948.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 7 months
Drools eval and variable assigning.
by droolsNewbie
I need a little help with Drools eval and variable assigning.
rule "check that no previously submitted requests exist"
when
$user : UserFormField( name == 'employeeId', value != null )
$repository : Repository( )
$activeRequests : List( ) from $repository.findActiveRequestsByEmployee(
$user.getValue() ) # call to repository
eval( $activeRequests.size() > 0 )
then
System.err.println(' You have active requests: ' +
((Request)$activeRequests.get(0)).getTitle);
insert(Boolean.TRUE);
end
In this rule I try to access repository and get active requests for current
user. Rule compiles and executes without any exceptions or warnings. In
debug mode it can be seen that repository returns non empty list and I
expect to see console message 'You have active requests' but this doesn't
happen. I think the problem is in this line
$activeRequests : List( ) from $repository.findActiveRequestsByEmployee(
$user.getValue() )
because this rule works fine
rule "check that no previously submitted requests exist"
when
$user : UserFormField( name == 'employeeId', value != null )
$repository : Repository( )
eval( $repository.findActiveRequestsByEmployee($user.getValue()).size()
> 0 )
then
System.err.println(' You have active requests !' );
insert(Boolean.TRUE);
end
So could someone point me how to solve this problem?
Thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-eval-and-variable-assigning-tp40...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 7 months
Fire rule only upon change of particular event (or fact)
by Jörg Henne
Hi all,
after using drools for some time now, I have repeatedly stumbled upon
situations where it would have been useful to be able to tell Drools to fire
a rule only upon the insertion of a particular event, but not other
events/facts on which the rule depends. It might be that I am hopelessly
mis-guided, but I would like to float an idea and see what you think.
To illustrate what I am talking about, please consider the following rules:
------------------------------------------------------------------------------------------------------------
package test
declare SomeEvent
@role(event)
name: String
end
declare SomeFact
@role(fact)
name: String
end
rule "Trigger on some event when there is some fact"
when
e: SomeEvent()
f: SomeFact()
then
System.out.println("=> Got Event '" + e.getName() + "' and Fact '" +
f.getName() + "'");
end
rule "Discard 'used' events"
salience -99999
when
e: SomeEvent()
then
retract(e);
end
------------------------------------------------------------------------------------------------------------
Now we insert facts and events, for example like this
------------------------------------------------------------------------------------------------------------
rule "Insert fact"
when
then
System.out.println("Inserting initial Fact");
insert(new SomeFact("initial fact"));
end
rule "Insert an event"
timer(int: 5s)
when
then
System.out.println("Inserting initial Event");
insert(new SomeEvent("initial event"));
end
rule "Insert yet another fact"
timer(int: 10s)
when
then
System.out.println("Inserting yet another fact");
insert(new SomeFact("yet another"));
end
rule "Insert yet another event"
timer(int: 10s)
when
then
System.out.println("Inserting yet another event");
insert(new SomeEvent("yet another"));
end
------------------------------------------------------------------------------------------------------------
The result of running those rules is, of course:
------------------------------------------------------------------------------------------------------------
Inserting initial Fact
Inserting initial Event
=> Got Event 'initial event' and Fact 'initial fact'
Inserting yet another fact
=> Got Event 'initial event' and Fact 'yet another'
Inserting yet another event
=> Got Event 'yet another' and Fact 'yet another'
=> Got Event 'yet another' and Fact 'initial fact'
------------------------------------------------------------------------------------------------------------
Please note the output does not match the name of the rule "Trigger on some
event when there is some fact". In fact, this rule fires irrespective of
whether an event is inserted or a fact. But what I really want is, that it
just fires upon the 'arrival' of events. A possible syntax extension whould
be something along the lines of:
------------------------------------------------------------------------------------------------------------
rule "Trigger on some event when there is some fact"
when
upon(e: SomeEvent())
f: SomeFact()
then
System.out.println("=> Got Event '" + e.getName() + "' and Fact '" +
f.getName() + "'");
end
------------------------------------------------------------------------------------------------------------
The expected output of that would be:
------------------------------------------------------------------------------------------------------------
Inserting initial Fact
Inserting initial Event
=> Got Event 'initial event' and Fact 'initial fact'
Inserting yet another fact
Inserting yet another event
=> Got Event 'yet another' and Fact 'yet another'
=> Got Event 'yet another' and Fact 'initial fact'
------------------------------------------------------------------------------------------------------------
There are work-arounds that let me achieve the desired behaviour, for
example this one:
------------------------------------------------------------------------------------------------------------
rule "Focus on 'process SomeEvent'"
agenda-group "process SomeEvent"
auto-focus
when
e: SomeEvent()
then
// nothing to do but focus the agenda-group
end
rule "Trigger on some event when there is some fact"
agenda-group "process SomeEvent"
when
e: SomeEvent()
f: SomeFact()
then
System.out.println("=> Got Event '" + e.getName() + "' and Fact '" +
f.getName() + "'");
end
------------------------------------------------------------------------------------------------------------
However, I think the hypothetical 'upon'-keyword would be a lot clearer. Is
there any fundamental reason (e.g. rooted in the rete-algorithm or the way
Drools implements it) that would preclude the implementation of 'upon'? And,
more importantly, do you even agree with me that it would be a useful
extension?
Please note that while I always spoke of events in conjunction with 'upon' I
don't see a reason why it should not behave this way with plain facts as
well. Please not as well that the inverse of upon would also be conceivable:
"don't fire this rule just because <some pattern> triggered", e.g. maybe
simply "not(upon(Pattern()))".
Thanks
Joerg Henne
--
View this message in context: http://drools.46999.n3.nabble.com/Fire-rule-only-upon-change-of-particula...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 7 months
Just found a way to stop fact insert time evaluation (tested in 5.5)
by Sonata
Originally I was asking for a method to stop LHS evaluation for a bunch of
rules in some other agenda-groups which I am not intended to trigger. But it
turned out that agenda-group filtering will only happen when you fire your
rules. *ALL* rules in *ANY* agenda-groups are evaluated anyway when you are
inserting fact.
Then according to this post
http://drools.46999.n3.nabble.com/Agenda-group-in-fact-insert-time-tp4023...,
Wolfgang suggested to use an extra object to control the LHS evaluation by
changing the value, e.g. Focus( value == "one" ). After many tests in
5.5.0.Final, this has no effect.
Say if you have a rule:
public static class MyClass {
private Integer i;
public MyClass(Integer i) {
this.i = i;
}
public Integer getMyInteger() {
System.out.println("getMyInteger is called for " + i);
return i;
}
}
rule test agenda-group "one"
when
String ( toString == "agenda-group one")
MyClass ( myInteger == 10 )
then end
when you call ksession.insert(new MyClass(10)); in your java code, no matter
what the value of Focus() is, or even you dont have Focus() object inserted,
getMyInteger() of MyClass is still called/evaluated to match with == 10.
This is highly undesired when you actually only want to trigger rules in
agenda-group "two".
And then finally I found that if you use the keyword "from", it seems it is
way smarter because *it will not be evaluated unless all the preceding
conditions are matched!*
Try the following example:
rule try agenda-group "one"
when
not Object() from System.out.println(1)
MyClass ( myInteger == 10 )
not Object() from System.out.println(2)
MyClass ( myInteger == 9 )
not Object() from System.out.println(3)
then end
If you call ksession.insert(new MyClass(10)), you will only see the output
1, 2 but not 3 because MyClass ( myInteger == 9 ) does not match. This is
really smart!
Now we just need a dummy function to return us the object we want then we
can use the agenda-group blocker to stop "fact insert time evaluation" as
follow:
function Object dummy(Object o) {
return o;
}
rule smart agenda-group "one"
when
String ( toString == "agenda-group one")
m : MyClass()
MyClass ( myInteger == 10 ) from dummy(m)
then end
rule blocker agenda-group "one"
when
then
insert(new String("agenda-group one"));
end
There! No more unwanted evaluations during fact insert time! In fact, all
the evaluations are pushed back to rule firing time and that can be *truly*
filtered by agenda-group.
Please let me know if I am doing stupid thing or if there is a big price or
consequence to pay for when I use this technique?
Thank you
--
View this message in context: http://drools.46999.n3.nabble.com/Just-found-a-way-to-stop-fact-insert-ti...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 7 months
entry-point and accumulate in a guided rule (BRL)
by Ravi Gupta
See screenshot, I want to combine an entry-point and an accumulate function
such as (the below is DRL, which works)
*rule "GSS-Sev1-Monitor"*
* no-loop true*
* dialect "mvel"*
* when*
* $ticketStatistics : TicketStatistics( $ID : ID == null )*
* accumulate($supportTicket:SupportTicket( ticketStatisticsID ==
$ID , severity == "Sev-1" ) over window:time (5m) from entry-point
"gss-support-stream", $num : count( $supportTicket ))*
* then*
* $ticketStatistics.currentTicketCount = $num;*
* update( $ticketStatistics );*
* end*
I can't seem to re-create this in Guvnor (BRL)
11 years, 7 months