[planner] curriculum course timetable modeling questions
by Joshua Daniel
Hi,
I am a newbie and am currently in the process of evaluating the drools
solver module for generating a timetable. I have couple of questions in this
regard...
1. I have two curriculums (Grade 1 - A, Grade 1 - B) and would like to
allocate a single room for all courses under a curriculum. How do I specify
this constraint?
2. Currently the rules are specified for a single week (i.e. period / time
slot list). How do I specify this for an entire year, does it mean I have to
create additional period / time slot lists for the entire year.
3. There are 5 days and 3 periods per day (i.e. 15 sessions per week) and we
have 6 common subjects and a separate course (German, French) specific to
the curriculum, assuming we equally distribute the load (i.e. if I want all
the courses to be atleast twice a week and just the separate courses
(German, French) to be thrice a week, what should be the lesson size.
Env: I have installed drools-5.0-solver and verifying the above attached XML
via the curriculumcourse sample data.
-jd
15 years, 11 months
Design of Rule Engine
by Manav
Hi,
I am using the 5.x version of Drools and currently new. I am currently
evaluating Drools for an internal
project .
The product's impressive and the support is absolutely superb.
To design a new Rule Engine using Drools as the base are there any
suggested design patters that i can take a look at ? If there are any best
practices that should be followed and gotchas to be avoided it would be
great if i could read about them.
For example if i am writing rules where two files contain a common set of rules,
is it possible to abstract out the common set of rules to a seperate DRL and
have that DRL referenced in other DRL's ?
These and other similar questions are what i am seeking answers to .
Regards,
Manav
15 years, 11 months
Firing Mulitple packages
by Vignesh
Hi,
We tried with a properties file with url of the set of package names in the
applicaiton and by iterating this file and fired the rules with out any
issues, but I want to know whether there is any way to fire all the rules in
multiple packages present in a Guvnor application using any built-in
methods?
Thanks in advance.
Regards,
Vignesh
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Firing-Mulitple-packa...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 11 months
persisting a stateful session
by chris
Hi there,
I apologize in advance if this seems like a trivial question, but I can't
seem to figure out what the issue is. i am trying to serialize a stateful
session to file in a very simple test program. So I am using the code from
Michael Bali's book to define a stateful drools session:
//
package sertest;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import org.drools.KnowledgeBase;
import org.drools.common.DroolsObjectInputStream;
import org.drools.common.DroolsObjectOutputStream;
import org.drools.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.marshalling.Marshaller;
import org.drools.marshalling.MarshallerFactory;
import org.drools.marshalling.ObjectMarshallingStrategy;
import org.drools.marshalling.ObjectMarshallingStrategyAcceptor;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.FactHandle;
/**
*
*
*/
public class DroolsService implements Serializable
{
private static final long serialVersionUID = 3L;
private transient KnowledgeBase knowledgeBase;
private transient StatefulKnowledgeSession statefulSession;
public DroolsService( KnowledgeBase knowledgeBase )
{
this.knowledgeBase = knowledgeBase;
statefulSession = createKnowledgeSession();
}
private StatefulKnowledgeSession createKnowledgeSession()
{
StatefulKnowledgeSession session =
knowledgeBase.newStatefulKnowledgeSession();
return session;
}
public void insertOrUpdate( Object fact )
{
if( fact == null )
{
return;
}
FactHandle factHandle = statefulSession.getFactHandle( fact );
if( factHandle == null )
{
statefulSession.insert( fact );
}
else
{
statefulSession.update( factHandle, fact );
}
}
public void executeRules()
{
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(statefulSession,
"accessPackageLog");
statefulSession.fireAllRules();
logger.close();
}
public void terminate()
{
statefulSession.dispose();
}
private void writeObject( ObjectOutputStream out ) throws IOException
{
out.defaultWriteObject();
DroolsObjectOutputStream droolsOut = new DroolsObjectOutputStream(
(OutputStream) out );
droolsOut.writeObject( knowledgeBase );
Marshaller marshaller = createSerializableMarshaller( knowledgeBase
);
marshaller.marshall( droolsOut, statefulSession );
}
private void readObject( ObjectInputStream in ) throws IOException,
ClassNotFoundException
{
in.defaultReadObject();
DroolsObjectInputStream droolsIn = new DroolsObjectInputStream(
(InputStream) in );
this.knowledgeBase = (KnowledgeBase) droolsIn.readObject();
Marshaller marshaller = createSerializableMarshaller( knowledgeBase
);
statefulSession = marshaller.unmarshall( droolsIn );
}
private Marshaller createSerializableMarshaller( KnowledgeBase
knowledgeBase )
{
ObjectMarshallingStrategyAcceptor acceptor =
MarshallerFactory.newClassFilterAcceptor(
new String[]
{
"*.*"
} );
ObjectMarshallingStrategy strategy =
MarshallerFactory.newSerializeMarshallingStrategy( acceptor );
Marshaller marshaller = MarshallerFactory.newMarshaller(
knowledgeBase,
new ObjectMarshallingStrategy[]
{
strategy
} );
return marshaller;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
In the test client I just do the following:
//
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
DroolsService droolsService = new DroolsService( kbase );
File file = new File("out.ser");
ObjectOutputStream oos = new ObjectOutputStream(
new FileOutputStream(file));
oos.writeObject(droolsService);
oos.close();
///////////////////////////////////////////////////////////////////
The code then trows an exception:
Exception in thread "main" java.io.IOException: Write error
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:260)
at
java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1838)
at
java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1747)
at
java.io.ObjectOutputStream.writeNonProxyDesc(ObjectOutputStream.java:1249)
at
java.io.ObjectOutputStream.writeClassDesc(ObjectOutputStream.java:1203)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1387)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at
java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1538)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:329)
at sertest.Main.main(Main.java:30)
If I take out the last 2 lines in the writeObject method above (i.e. don't
use a marshaller to write out the stateful session) then there is no
exception.
Any ideas what might be causing this??
Kind regards,
Chris
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/persisting-a-stateful...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 11 months
Inserting new Object
by Tina Vießmann
Hi again ...
I would like to insert a new generated object into the knowledge base.
It seems that
insert (new Watcher())
is working. But
Watcher watcher = new Watcher();
insert (watcher);
isn't working?
Why?
Thank you for any explanations. :)
Tina
15 years, 11 months
npe in LogicalRetractCallback when using jpa persistence
by Chris Raschl
Hi guys,
I think I've found a problem in the TruthMaintenanceSystem and would
like to know if its a real bug or if I've made some mistake...
I'm using the latest drools and drools flow snapshot with jpa persistence.
When I'm retracting a fact from the knowledge session (which causes
logical retraction), the session can't be persisted any more.
During retraction a LogicalRetractCallback is instantiated using this
constructor:
public LogicalRetractCallback(final TruthMaintenanceSystem tms,
final LogicalDependency node,
final Set set,
final InternalFactHandle handle,
final PropagationContext context,
final Activation activation) {
this.tms = tms;
this.node = node;
this.set = set;
this.handle = handle;
this.context = context;
}
As you can see an activation object can be passed (and actually is
passed) to the constructor, but is never used. Retraction works though.
The problem occurs when the knowledge session is persisted, because
LogicalRetractCallback.write assumes that activation is not null, which
leads to this npe:
Caused by: java.lang.NullPointerException
org.drools.common.TruthMaintenanceSystem$LogicalRetractCallback.write(TruthMaintenanceSystem.java:251)
org.drools.marshalling.impl.OutputMarshaller.writeActionQueue(OutputMarshaller.java:201)
It would be cool if anyone could have a look at this...
Thanks,
chris
15 years, 11 months
where can I find the drl compiled java file?
by Badrinath, Shyam
Hi
I am facing a weird problem where the rule works fine for the first time
after I start the rule engine. After that, the same set of data causes
the rule engine to give a nullpointerexception when firing the rule
action. It gives the line # in the compiled java file, but I cannot find
that file. The line # doesn't match the drl (obviously), so I can't make
sense of where the exception could be occurring.
So, where can I find this drl compiled java file?
Thanks
Shyam
15 years, 11 months