OptaPlanner: unsolved score & constraint failure messages
by Sandeep Bandela
Hi,
I have some experience with drools 5 and now experimenting on planner &
drools 6.
I have 'unsolved' PlanningSolution that could be given to a solver and it
successfully solves it. (its just the curriculum example with few more
variables like teachingAssistant, equipment etc)
I need to know few things about this unsolved solution.
1) I want to know the score of this unsolved before starting to solve it.
can I do this without instantiating my own drools session with my score
holder and execute the rules for score? i.e only using optaplanner-api and
not depend on underlying rules engine used by planner.
2) I also want to have some information on what all rules got fired in
calculation of score (the negative ones). to print the conflicting planning
entities & their variables. I could put a message from each rule to some
object in workingMem. but how can I get those objects back after the solver
is done but didnt have a feasible solution/ or even for any given solution.
or is there any better way?
--
Regards,
Sandeep Bandela.
12 years, 8 months
Strange behaviour when adding rules during run-time
by IK81
Dear all,
I am encountering a strange issue that rules fire based on events, which I
already considered as expired. As far as I learned from the documentation
Drools automatically determines the expiration time of an event based on
analyzing the rules (e.g. if there's a temporal operator or aggregation
using the event). Ok, i do not use anything of that. My scenario is as
follows - for testing purposes I use a pseudo session clock and of course
the STREAM mode.
- At time 0 I insert an Event A and call fireAllRules
- Then I advance the time for 100 seconds
- Now I add a further rule by parsing a drl file and adding it to the
Knowledge base of my current session
- Then, still at time 100 I insert another Event B and call fireAllRules
again
The rule that I've inserted previously fires but unfortunately twice. Once
for event A (which I already considered as expired) and for event B (which
is that what I wanted).
Even if i use the @expires annotation in my drl this does not work
correctly. Do I have to call another method to trigger the expiration in the
session. Any suggestions?
Ingo
p.s. I am using Drools 5.5 final
--
View this message in context: http://drools.46999.n3.nabble.com/Strange-behaviour-when-adding-rules-dur...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
Re: [rules-users] Convert GuidedDecisionTable to DRL
by learnbrms
Use http://<hostname>:<port>/jboss-brms/rest/packages/{packageName}/source to
get the DRL file source.
I guess GDST is like an excel sheet on top of which rules are written. So if
you are migrating it from one repo to another, you have to migrate this
asset as gdst but if you just need DRL, get it from package source.
You can get the source of GDST with
http://<hostname>:<port>/jboss-brms/rest/packages/{packageName}/assets/{assetName}/source
I will wait to see if someone corrects my thinking but you can try the REST
approach and it works fine.
Thanks,
SR
--
View this message in context: http://drools.46999.n3.nabble.com/Convert-GuidedDecisionTable-to-DRL-tp40...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
OptaPlanner Guvnor integration
by Bartek
Hello,
How Optaplanner and Guvnor should be integrated? I am using Drools
5.5.0.Final. I have configuration with spring so I have access to
KnowledgeBase.
I found in documentation:
5.3.4.2.2. A RuleBase (possibly defined by Guvnor)
solverFactory.getSolverConfig().getScoreDirectorFactoryConfig.setRuleBase(ruleBase);
How I can get rule base? (If it is correct way do integrate with guvnor)
Thanks,
12 years, 8 months
Create KieBase from Jar/Zip
by Daniel Straub
If we create a KieBase from a Jar, all rules has to be placed in
"src/main/resources" (why ?).
That means, it is not possible to build a "jar" with maven, beacuse maven
puts all resouces in the root folder of fhe jar.
Ok, we build a "zip", using the maven assembly plugin.
But there is an error in
org.drools.compiler.compiler.io.memory.MemoryFileSystem :
This implementation expected every file is placed in a folder - that's true,
except the pom.xml.
But if we place the pom.xml in another folder (like META-INF), the pom isn't
found.
As workaround to this and the previous errors, we create now the
KieFileSystem itself :
--
View this message in context: http://drools.46999.n3.nabble.com/Create-KieBase-from-Jar-Zip-tp4024536.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
Unable to initialize KieBase from Windows file system
by Daniel Straub
We try try to initialize a KieBase like this:
but no rule files where found.
Spending some time for debugging, we realized that in KieBuilderImpl (and
other places) file names are compared with linux path delimiter
but - as usally known - Windows file system uses '\' .
We made the followin hack in
org.drools.compiler.commons.jci.readers.DiskResourceReader :
and everything runs.
Please respect that some people have to use windows (unfortunatly ...)
--
View this message in context: http://drools.46999.n3.nabble.com/Unable-to-initialize-KieBase-from-Windo...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
External storage and timers
by didierC
Hi,
We want to use the external storage API for our Fusion project (Drools 6.0 -
beta2).
We have temporal based rules and when we load an existing session, we get:
...
Caused by: java.lang.NullPointerException
at
org.drools.core.common.Scheduler$ActivationTimerInputMarshaller.deserialize(Scheduler.java:238)
at
org.drools.core.marshalling.impl.ProtobufInputMarshaller.readTimer(ProtobufInputMarshaller.java:627)
at
org.drools.core.marshalling.impl.ProtobufInputMarshaller.readSession(ProtobufInputMarshaller.java:282)
at
org.drools.core.marshalling.impl.ProtobufInputMarshaller.readSession(ProtobufInputMarshaller.java:154)
at
org.drools.core.marshalling.impl.ProtobufMarshaller.unmarshall(ProtobufMarshaller.java:114)
at
org.drools.core.marshalling.impl.ProtobufMarshaller.unmarshall(ProtobufMarshaller.java:56)
at
org.drools.persistence.SessionMarshallingHelper.loadSnapshot(SessionMarshallingHelper.java:83)
... 35 more
I can reproduce the problem in a simple test case:
public class TestStorage {
private SimpleKnowledgeSessionStorage storage;
@Before
public void initStorage() {
storage = new SimpleKnowledgeSessionStorage();
}
@Test
public void testStorageWithTimer() throws InterruptedException {
KieSession session = getSession(null);
int id = session.getId();
String rule = "package test\n";
rule += "import erdf.poc.cep.*;\n";
rule += "rule \"test\"\n";
rule += "timer (cron:0/2 * * * * ?)\n";
rule += "when\n";
rule += "then\n";
rule += "insert(\"test\"+System.currentTimeMillis());\n";
rule += "end";
addRule(session, rule);
session.fireAllRules();
Thread.sleep(2000);
session.fireAllRules();
final int facts = session.getFactHandles().size();
Assert.assertTrue(facts>=1);
session.dispose();
Thread.sleep(2000);
session = getSession(id);
addRule(session, rule);
session.fireAllRules();
Assert.assertTrue(session.getFactHandles().size()>facts);
session.dispose();
}
private KieSession getSession(Integer i) {
final Environment env = KnowledgeBaseFactory.newEnvironment();
EnvironmentBuilder envBuilder = new
KnowledgeSessionStorageEnvironmentBuilder(storage);
env.set(EnvironmentName.TRANSACTION_MANAGER,
envBuilder.getTransactionManager());
env.set(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER,
envBuilder.getPersistenceContextManager());
KieStoreServices storeS = KieServices.Factory.get().getStoreServices();
final KieBase kieBase = KnowledgeBaseFactory.newKnowledgeBase();
if (i != null) {
return storeS.loadKieSession(i, kieBase, null, env);
}
return storeS.newKieSession(kieBase, null, env);
}
private static class SimpleKnowledgeSessionStorage implements
KnowledgeSessionStorage {
public Map<Integer, SessionInfo> ksessions = new HashMap<Integer,
SessionInfo>();
public Map<Long, WorkItemInfo> workItems = new HashMap<Long,
WorkItemInfo>();
public SessionInfo findSessionInfo(Integer id) {
return ksessions.get(id);
}
public void saveOrUpdate(SessionInfo storedObject) {
ksessions.put(storedObject.getId(), storedObject);
}
public void saveOrUpdate(WorkItemInfo workItemInfo) {
workItems.put(workItemInfo.getId(), workItemInfo);
}
public Long getNextWorkItemId() {
return new Long(workItems.size() + 1);
}
public WorkItemInfo findWorkItemInfo(Long id) {
return workItems.get(id);
}
public void remove(WorkItemInfo workItemInfo) {
workItems.remove(workItemInfo.getId());
}
public Integer getNextStatefulKnowledgeSessionId() {
return ksessions.size() + 1;
}
}
}
Any idea ?
Thanks for your help
Didier
--
View this message in context: http://drools.46999.n3.nabble.com/External-storage-and-timers-tp4024486.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
Memory-Problemwith instance of "ReteooStatefulSession"
by anniejoseph
Hi,
I'm using jBoss Rules.But I run in to memory issues after using JBoss
rules. Using a profiling tool I collected heap dump
and I got the result as :
/One instance of "org.drools.reteoo.ReteooStatefulSession" loaded by
"sun.misc.Launcher$AppClassLoader @ 0x7f899fdb6d88" occupies 657,328,888
(78.91%) bytes.
The memory is accumulated in one instance of
*"org.drools.reteoo.ReteooStatefulSession"*
loaded by "sun.misc.Launcher$AppClassLoader @ 0x7f899fdb6d88".
Keywords
sun.misc.Launcher$AppClassLoader @ 0x7f899fdb6d88
org.drools.reteoo.ReteooStatefulSession/
The code I used for JBoss rules is given below.
kbase= KnowledgeBaseFactory.newKnowledgeBase();
ksession= kbase.newStatefulKnowledgeSession();
final String str =
CISMSRemotingUtils.getFullConfigFilePath("change-set.xml") ;
final String filePath = str.replaceAll(" ", "%20");
aconf = KnowledgeAgentFactory .newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.newInstance", "false");
kagent = KnowledgeAgentFactory.newKnowledgeAgent( "Agent", aconf);
kagent.applyChangeSet( ResourceFactory.newFileResource(filePath) );
kbase = kagent.getKnowledgeBase();
ksession= kbase.newStatefulKnowledgeSession();
sconf
=ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty( "drools.resource.scanner.interval", "3600");
ResourceFactory.getResourceChangeScannerService().configure( sconf );
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
This piece of code is given in the class constructor and rules are fired
inside this class
ksession.insert(data);
ksession.fireAllRules();
Can anyone help me to identify the problem?
--
View this message in context: http://drools.46999.n3.nabble.com/Memory-Problemwith-instance-of-ReteooSt...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months