Multiple planning variables in optaplanner 6.0.1
by lloydstockman
Hi Guys,
I am trying to get a basic program going using Optaplanner 6.0.1 I have come
across a problem because I am using two planning variables within a single
planning entity. I have checked other examples, such as the examination
example, and it seems fine to have multiple planning variables within a
single planning entity. I also tried to add another planning variable to the
cloud balancing example and the same error occurs so I believe there is
something I need to do to be able to use multiple planning variables in a
single entity. The error is as follows.
Exception in thread "main" java.lang.IllegalArgumentException: The
selectorConfig (ValueSelectorConfig(null)) has no configured variableName
(null) for planningEntityClass (class domain.Provisional) and because there
are multiple in the variableNameSet ([date, morning, technician]), it can
not be deducted automatically.
at
org.optaplanner.core.config.heuristic.selector.SelectorConfig.deduceVariableDescriptor(SelectorConfig.java:108)
I haven't found anything in the manual to suggest what needs to be done in
this scenario, or found any posts of the forum regarding this topic. If
anyone can point me in the right direction I would greatly appreciate it.
best regards,
- Lloyd Stockman
--
View this message in context: http://drools.46999.n3.nabble.com/Multiple-planning-variables-in-optaplan...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 9 months
real world examples wanted
by Mark Proctor
Real wold examples wanted. If you can help, please let us know.
We have a large user base now, and over the years a number of people have said they would help with contributing real world examples. Alas after 10 years, except for the small banking example, we are still waiting for a single user example contribution.
Mark
10 years, 9 months
irrational behaviour by drools engine
by Avin
Hi,
I have a hashmap inserted as global variable and some objects as facts.
In drools i try to locate object from hashmap using facts. It behaves
differently and i dont know why. I will post my code and then try to
describe the behaviour
global java.util.Map encapsulationMap;
rule "test rule"
no-loop
when
EncapsulatingObject($key : id == 7)
EncapsulatingObject( encapsulationMap[$key+""] !=null)
//eval( encapsulationMap.get($key+"") != null) working
then
System.out.println("key is "+$key +" value is :::
"+encapsulationMap.get($key+""));
end
Out put
key is 7 value is ::: Encapsulating object key 7
key is 7 value is ::: Encapsulating object key 7
key is 7 value is ::: Encapsulating object key 7
key is 7 value is ::: Encapsulating object key 7
key is 7 value is ::: Encapsulating object key 7
key is 7 value is ::: Encapsulating object key 7
key is 7 value is ::: Encapsulating object key 7
key is 7 value is ::: Encapsulating object key 7
key is 7 value is ::: Encapsulating object key 7
Explanation :
I have objects of Encapsulating as facts. same type of objects are present
in hashmap. Field id is getting used for hashcode and for equals to store it
in hashmap.
I am inserting 9 facts and all of them are unique. Number of occurance if
you see are 9.
1. I dont know why it behaves like this? i think there should have been
just 1 object.
2. If I *comment out EncapsulatingObject( encapsulationMap[$key+""]
!=null)*
and *uncomment eval* i get proper results i.e only one output. BZut i want
to assign object to a variable hence i have to use *EncapsulatingObject(
encapsulationMap[$key+""] !=null)*
Can any one explain me this behaviour ?
What am i missing or where am i going wrong.
Please help
Thanks and Regards
Avin
--
View this message in context: http://drools.46999.n3.nabble.com/irrational-behaviour-by-drools-engine-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 9 months
[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
10 years, 9 months
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.
10 years, 9 months
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.
10 years, 9 months
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.
10 years, 9 months
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"
10 years, 9 months