Drools parser error accessing ArrayList.
by groovenarula
Hi,
I have a situation where I need to iterate over an ArrayList in the RHS of a
rule. The ArrayList is created in the LHS of the rule as follows :
rule "Hello World"
dialect "mvel"
when
$cur : Message()
$others : ArrayList ( size > 0 ) from collect(Message(status ==
$cur.status, this != $cur ))
then
for ( int ctr = 0; ctr < $others.size(); ctr++)
{
System.out.println((Message) $others.get(ctr));
}
end
This works in Drools 5.1.1.
However it gives the following parser error in Drools 5.2.X :
Unable to Analyse Expression for ( int ctr = 0; ctr < $others.size();
ctr++);
{
System.out.println((Message) $others.get(ctr));
} ;:
[Error: was expecting type: java.lang.Object; but found type:
<Unknown>]
[Near : {... for ( int ctr = 0; ctr < $othe ....}]
^
[Line: 6, Column: 0] : [Rule name='Hello World']
java.lang.IllegalArgumentException: Could not parse knowledge.
at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:50)
at com.sample.DroolsTest.main(DroolsTest.java:23)
What am I missing here ? Any insight on a possible solution is appreciated.
This has become a big stumbling block for us to move from 5.1.1 to 5.2.1.
Thanks in advance,
Gurvinder
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-parser-error-accessing-ArrayList...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
WS Custom Form not working in Guvnor
by sams
I can provide all the info - select a Fact type, select a field, provide and
URL, and provide height and width. Click OK then File | Save changes.
However, it doesn't look like my form is actually getting saved. When I go
back to the tab its not there, and it doesn't appear in the guided editor
when working with the field that its mapped to.
Am using version 5.3.0 in Tomcat on Windows.
Any help is appreciated.
Thanks,
Sam
--
View this message in context: http://drools.46999.n3.nabble.com/WS-Custom-Form-not-working-in-Guvnor-tp...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Writing really short rules
by Adam Warski
Hello,
I have some near-tabular data which I would like to write down as rules.
There about 100 rows. Using a custom DSL, the shortest form I now have for
each entry is:
rule "..."
when some condition with data from row
then always the same action
end
so 4 lines.
Is it possible to somehow write it in one line? If I simply try to do that,
the parser complains (as I have a .dslr file).
Alternatively, is it possible to write down a decision table not in excel,
but using plain text? As this would work for me as well.
Thanks,
Adam
--
View this message in context: http://drools.46999.n3.nabble.com/Writing-really-short-rules-tp3903485p39...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Getting Exception while using Array in rules template
by Manikandan Subramanian
I am getting exception when using Array in combination with "in (...)".
Below is the exception
[Error: unable to resolve method: java.util.HashMap.countyName()
[arglength=0]]
and below is the template I have created
template header
stateName
countyName[]
totalPremium
package org.drools.bpmn2
template "Premium"
stateName
totalPremium
rule "Premium_(a){row.rowNumber}"
ruleflow-group "insurance premium"
when
Input(stateName == @{stateName}, countyName in (@{countyName}))
then
System.out.println("total premium " + @{totalPremium});
end
end template
the excel sheet is having the data, the column corresponds to countyName as
CSV value with variable number of variables either empty or 1 or 2 and so
on.
If I give the when like below it works (with countyName0 instead of
countyName).
when
Input(stateName == @{stateName}, countyName in (@{countyName0}))
Do I need to use foreach to generate the countyName sequence like
countyName0, countyName1 .. etc to put it in the "in (...)" condition?
I didnt find much documention about templates that covers foreach with in.
Please help. Any examples or samples would be helpful.
--
Thanks,
Mani
14 years
is there any 'followed by' in Drools as we have in esper
by skatta1986
Hi,
Please any one let me know if there is any followed by operator in Drools. I
want to correlate an event with another event which follows the first event.
Esper supports this by using followed by (->) operator.
Example in esper:
"select r1.name as name,r1.userIPAddress as ipaddress,count(*) as
usr_success_count, (r2.getTimeStamp()-r1.getTimeStamp()) as delta_time from
pattern" +
"[ (every r1=EventRecord(eventNumber=105, eventType='EVENT_REQUEST'))-> " +
"(r2=EventRecord(eventNumber=110, eventType='EVENT_SUCCES',
id.getCallId()=r1.getId(), name=r1.name)) where
timer:within(usr_timeout_interval sec)]";
Can you please providesimilar kind of rule in Drools.
--
View this message in context: http://drools.46999.n3.nabble.com/is-there-any-followed-by-in-Drools-as-w...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Objects from Working Memory not available in drl
by Magublafix
Hey guys,
I'm playing with the drools planner a few days now and got stuck.
I have a Solution with an PlanningEntity Ambulance and a normal Class
SendAmbulance.
I add a List SendAmbulance to the Working Memory with the getProblemFacts()
method. The Ambulance objects are loaded automatically.
The problem now is that i can access the Ambulance Objects within the drl
correctly but nut the SendAmbulance objects.
Has somebody an advice for me to solve this?
thanks,
Magublafix
--
View this message in context: http://drools.46999.n3.nabble.com/Objects-from-Working-Memory-not-availab...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Employee Shift Rostering: algorithm details
by HarrySimons
Hi,
I'm new both to Drools Planner and to metaheuristic algorithms like Tabu
Search. Though I have done some preliminary reading on the Net on how this
algorithm 'generally' works -- including reading the 'plain-English'
portions of Chapter 8 of the 'Essentials of Metaheuristics' book -- it still
isn't perfectly clear to me how an actual implementation of the algorithm
would code the 'Tweak' / 'Next Move' function (other than via a random
combination of planning variables) in an application such as Employee Shift
Rostering with a very large search space and with multiple planning
variables.
On the page (http://www.jboss.org/drools/drools-planner.html) where Drools
Planner is compared side-by-side to other naive (greedy algorithms-based)
approachesfor various kinds of problems, could it be the case that the
algorithms used in Drools Planner were able to perfectly solve the
highlighted problems only because of the use of extremely small search
spaces / input datasets?! A wikipedia entry related to metaheuristic
algorithms says that not only is it possible that such an algorithm may not
give an optimal solution, it may not even give any solution at all(!!) due
to the algorithm reaching its timeout limit specified by the user. I'm
assuming it won't be possible to specify a timeout value in days or even
hours for any metaheuristics-based approach to a real-world problem of a
real-world scale.
Lastly, from looking at the pseudocode of Tabu Search, it *appears* that the
core, 'driver portion' of the algorithm may itself be not all that hard to
implement; it is rather the call-back portion of the algorithm (such as the
problem-specific Tweak / Next Move function, which the driver portion calls
back) that may be hardest to implement. Given this, what would be the
advantages of using Drools Planner over a from-scratch, hand-coded version
of Tabu Search (other than its declarative, rule-based flexibility which a
hand-coded, from-scratch version may not want to implement due to its focus
on solving a specific planning problem vs. a whole slew of generic planning
problems requiring a generic piece of code such as Drools Planner)?
Would greatly appreciate if someone more knowlegeable than me could clarify
/ elaborate on the above getting-started questions of mine.
Regards,
/HS
--
View this message in context: http://drools.46999.n3.nabble.com/Employee-Shift-Rostering-algorithm-deta...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
[Drools Planner] Proof-of-Concept Stock-planning System
by Reinis
Hello,
I want to ask you, guys, if you could guess if it is possible or
probable to build such a System with Drools Planner:
The system shall plan the best time where the transport unit (TU) has to
be input into stock system to reach set delivery deadlines, utilization
of resources and load balancing of bottle necks (all expressed as rules).
Most of things (resource capacity, route within the stock system, etc.)
are given and constant facts. Actually there is only one planning
variable - time interval of a transport unit characterizing retention
period within a given Resource. Like this:
TU#1 is in Resource #A from 11:00 till 11:30 <- the optimal interval has
to be planned
TU#1 is in Resource #B from 11:45 till 12:00 <- the optimal interval has
to be planned
TU#1 is in Resource #C from 12:30 till 13:00 <- the optimal interval has
to be planned
I have following problem size and constraints:
- TUs per day: 160'000
- Amount of resources a TU travel through: 3
- Average smallest time interval: 15 Min
- Planning period: 09:00 - 16:00 = 8 hours = 32 intervals
- Initial planning window: 4-6 hours
- continuous planning multiple batch execution time during the day after
addition and/or retraction of number of TUs: 20 minutes
So the problem size would be(?):
(TUs * resources) ^ intervals = (160'000 * 3) ^ 32 = 6.305500958×10¹⁸¹
I know there is no one answer to this question. I would like only to get
your feeling on this problem. Would you take on solving this sort of
problem with drools planner?
thanks and br
Reinis
14 years