[optaplanner] Nurse rostering questions
by Karri Niemelä
1) So for example when using toy1.xml there is 140 shifts/assigments.
This means each nurse(11 of them) will get about 10-15 assignments.
(= DayOfWeekCover/cover/shift/preferred is 2)
But what if I want to make sure in contract MinNumAssignments = 20 is met?
DayOfWeekCover/Cover/shift would need to have minimum/maximum instead of preferred?
2) So I solve/make shifts for february using nurserostering. Then I want to do march.
a) How to load old data? (Load feb solution and then advance 30 days?)
b) What if my march data has employee/contract changes?
Thanks,
Karri
12 years, 1 month
not able to use map as global variable to get the object
by Avin
Hi,
I know some questions are raised regarding using map in drools. But most of
them have answered that Map to be added as part of working memory and not
global.
My question is based on same lines. I have global variable of the the type
map. I insert my facts in working memory. This facts are basically keys for
the entities in map. Map will contain elements whose keys will be met or
not.
If element in map is found then i have to assign it to the variable so that
i can use it ahead. I have tried may ways but i didnt get how to work with
it. Similiarly i have multiple maps of different elements and i have to be
sure which map to be used to retrieve element hence i dont want to set map
in working memory.
Below is the *trace of code* that fires Null pointer exception
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import domainObjects.ConcPercentRef;
import domainObjects.EncapsulatingObject;
global java.util.Map encapsulationMap;
rule "test rule"
no-loop
when
$key : EncapsulatingObject(id != 0 )
$object : *EncapsulatingObject(encapsulationMap[$key]* != null)
then
System.out.println("value is ::: "+encapsulationMap.get($key));
end
*Exception trace *
Exception in thread "main" [Error: null pointer: encapsulationMap[$key]]
[Near : {... encapsulationMap[$key] != null ....}]
^
[Line: 1, Column: 1]
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain
i have also tried using Map(encapsulationMap[$key] !=null but it fails. It
does not throws exception but it dosent enters in then clause because some
of the keys are present. Be sure of that.
Any help will be highly appreciated
Thanks
Avin
--
View this message in context: http://drools.46999.n3.nabble.com/not-able-to-use-map-as-global-variable-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 1 month
Passing List in declaredTypes object constructor
by lukes
Hi all,
I am new to drools and trying to write some basic rules. My rules works
fine as long as i don't have a list in the declaredTypes, but as i declare
one of the member as List, it throws errors in runTime. I am assuming the
List can be passed as [] but looks like i am wrong. Below is my drools file,
should be great if someone can point me on how to create the list.
package com.sample
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
declare Customer
@propertyReactive
name : String
seniority : int
discount : double
list : java.util.ArrayList
end
rule \"kickoff\"
salience 100
when
then
Customer c = new Customer( "Bob", 10, 0.0d, ["asa"]); //
Error is thrown here at runTime.
insert(c);
insert( new Integer(1000) );
System.out.println(\"new Customer created\");
end
Thanks in advance.
--
View this message in context: http://drools.46999.n3.nabble.com/Passing-List-in-declaredTypes-object-co...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 1 month
Re: [rules-users] Stateless session in drools server keeping classes around?
by dunnlow
Hello, sorry, I do not remember if/how I resolved the issue. I currently use
a persisted stateful session (Drools 5.5) retracting the facts I insert with
a rule with high salience and everything works fine.
I did bump into an issue recently where a rule with a bad mvel expression (a
variable in a regex matches that contained an invalid value) was causing an
exception in the bowels of mvel/drools and keeping my rule from firing that
retracts the objects I insert (so eventually I'd run out of memory). My
point: make sure you test with a simple / value rule.
hth.
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Stateless-session-in-drools-server-keep...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 1 month
Drools Language Enhancements
by Raja Sekhar
Hi All,
I came across this link
https://community.jboss.org/wiki/DroolsLanguageEnhancements#jive_content_...
select location, age, avg(income), min(income), max(income) from Person
group by location, age //SQL
acc( $p : Person();
[$l, $a] : distinct( $p.location, $p.age) )
acc( $p : Person( location == $l, age == $a );
$avgIncome : avg( $p.income ) ,
$minIncome : min( $p.income ),
$maxIncome : max( $p.income ) )
If we wanted to make a list of lists we could add:
acc( $l : List() from [$avgIncome, $minIncome, $maxIncome],
list( $l )
Can some give me specific example with this
Regards,
--
Raja Sekhar Amirapu
------------------------------------------------------
"If any anyone can do it, i can do it. If no one else can do it, i must do
it"
12 years, 1 month
Obtain contents of global variable java.util.List results after rules have fired.
by mvanders
Hi all,
I'm attempting to output the results of action results embedded in Decision
Tables (Excel)
Our ACTION's in the excel table creates a HashMap<String, Object> and then
this HashMap is added to a global variable java.util.List results variable,
as can be seen below (ie column1 & column2)
*/ACTION (Column 1)/*
Map result = new HashMap();
results.add(result);
result.put(""itemCode"",""$param"");"
*/ACTION (Column 2)/*
result.put("quantity",calculateQuantity(incomingDataMap,"$param"));
calculateQuantity is a function that determines a quantity based on
Conditions and values in the incomingDataMap
This works well, and the results variable is populated and available for use
in code works.
/Now the Problem Im facing/ is ni regards to business user testing.
When running regression testing I would like to somehow display the contents
of the List of HashMap.
It is important to the Business User to see that correct quantities are also
being generated, not just the correct rule was fired.
The approach I've been searching for is this; Is it possible to output extra
lines of text into the file generated when clicking on the *URL for running
tests*. A text file generates with SUCCESS or FAIL and the Test Scenario
name.
Is this possible?
Otherwise i may need to somehow create a separate FACT Model and alter my 2
ACTION column in the decision table to also output information into a FACT
model then use it to trigger another rule, that can read the value generated
in the calculateQuantity function.
Hopefully you can work out what im attempting to do here and offer some
advice, im not sure on the best practice on presenting this sort of
information and have trouble finding much info with dealing with the output
of actions in this way.
Cheers and thanks for you help in advance
Mark
--
View this message in context: http://drools.46999.n3.nabble.com/Obtain-contents-of-global-variable-java...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 1 month
Hide a Rule that has fired
by mvanders
Hi all,
This is more visual aid when reviewing Test Scenarios than a must have but,
is it possible to "hide" a rule that has fired from the list of fired rules.
If you look at the below Rule "JobMapRule", once it has fired and populated
the incomnigData Map it is no longer necessary to know if the rule fired or
not. Its purely a rule to setup up Fact details.
The below rule will appear in every Test Scenario but it is not necessary to
be seen, is there a way to "remove" it from the "fired rules" list that
appears. Just trying to make this as simple as possible for the business
user so they don't see things that they don't need to worry about when
creating to Test Scenarios
rule "JobMapRule"
dialect "mvel"
when
job : Job( )
then
Map incomingData = new HashMap();
incomingData.put('workType', job.workType);
incomingData.put('status', job.status);
insert(incomingData)
retract(job)
end
Cheers
Mark
--
View this message in context: http://drools.46999.n3.nabble.com/Hide-a-Rule-that-has-fired-tp4028051.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 1 month
[Drools Activation-group] / how to set many activation groups
by jcarpene
Hello,
I am trying to implement some rules that need more that a unique
Activation-group.
My case is related to some Voucher codes for online shopping. A simple case
works great, by defining an Activation-group to make sure 2 Voucher codes
cannot be used at the same time.
But now I need 2 Voucher codes (say Code 1, Code 2) to be compatible (no
activation-group) and a 3rd code (Code 3) to be disabled if Code 1 or Code 2
is used. If I use a XOR group name as an Activation-group, then Code 1 and
Code 2 will have a same Activation-group and will be exclusive (which I do
not want).
Do you know a way of setting multiple Activation-Groups for example, or any
workaround for that case ?
Regards,
Jerome
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Activation-group-how-to-set-many...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 1 month