Planner: Packing items together
by JimK
Working from the cloud computing example I am modifying it as a learning
exercise that might have real world use for a client. The client makes items
that vary in size and weight. I have built rules to handle the weight and
size constraints to optimize loading of a box. Planner does a great job of
optimizing loading of the boxes with those rules. The one sticking point is
a sales order line must be packed in the same box or series of boxes. Can’t
quite get my head around how to craft rule(s) to enforce it.
1. Each order line is a job.
2. Each job is run complete from start to finish.
3. Jobs can be manufactured in any sequence.
4. Weight varies from order line to order line
5. Thickness varies from order line to order line.
6. Items on same order line are identical in thickness and weight.
7. Items are loaded into box as they come off line.
8. Items from different sales order lines can be packed in the same box.
Rules:
1. Total thickness of items in box must not exceed depth of box.
2. Total weight of items in box must not exceed weight capacity of box.
3. All items on the same order line must be packed in same box or sequential
boxes.
Thickness and weight are not always connected in the same direction. A
thicker item can be heavier or lighter than a thinner item.
Goal: Optimize the sequence that sales order lines come off the
manufacturing line to minimize the number of boxes needed without exceeding
depth or weight limitations of box.
Example:
• Order line X for Quantity 100
All in one box, OK
Box 1 100
Box 2 0
Started in Box 1, rest in box 2, OK
Box 1 25
Box 2 75
Box 3 0
Spread over multiple sequential boxes, OK
Box 1 25 (could have other sales order lines)
Box 2 50 (box can only contain Line X)
Box 3 25 (could have other sales order lines)
Some in one box, rest in a non-adjacent box, Not Allowed.
Box 1: 25
Box 2: 0 (box has items from other order lines)
Box 3: 75
This looks to be similar to the lecture compactness goal in the examination
problem. I can almost see what needs to be done but can’t quite articulate
it into rule(s) to ensure an order line has been packed sequentially in a
contiguous series of boxes.
Thanks much for any assistance
Jim Kinneman
--
View this message in context: http://drools.46999.n3.nabble.com/Planner-Packing-items-together-tp326226...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
dialect java is not loading the facts in Drools
by santhosh kumar
Hi,
Can some one help in resolving the below issue or if there is any work
around for this?
There is a strange behaviour in terms of loading the facts using dialect
java and mvel.
Our requirement is that we should support dynamic changes to fact objects in
the application without a restart. So, to achieve that I am using jar
classloader to load the fact objects into memory. So before constructing
RuleBase I am switching the current class loader context to jar classloader.
By doing this, all the imported facts getting resolved if I use mvel dialect
where as if I use java dialect it's not able to resolve the fact. Can
someone help on how to resolve this issue.
I can't use mvel dialect as it's behaving strangely in case of accumulate.
So I need to use java dialect only.
Please let me know why java dialect is considering the facts only from
classpath. It's not loading from current classloader's context
Below is the code to switch classloader context
Thread.currentThread().setContextClassLoader(
jarClassLoader);
InputStream is = //reads from jar content
RuleBase ruleBase = RuleBaseLoader.getInstance().loadFromReader(
new InputStreamReader(is));
StatelessSession statelessSession = ruleBase.newStatelessSession();
statelessSession.executeWithResults(facts);
Thanks
Santhosh
14 years, 8 months
dialect java is not loading the facts
by sanintel3
Hi,
There is a strange behaviour in terms of loading the facts using dialect
java and mvel.
Our requirement is that we should support dynamic changes to fact objects in
the application without a restart. So, to achieve that I am using jar
classloader to load the fact objects into memory. So before constructing
RuleBase I am switching the current class loader context to jar classloader.
By doing this, all the imported facts getting resolved if I use mvel dialect
where as if I use java dialect it's not able to resolve the fact. Can
someone help on how to resolve this issue.
I can't use mvel dialect as it's behaving strangely in case of accumulate.
So I need to use java dialect only.
Please let me know why java dialect is considering the facts only from
classpath. It's not loading from current classloader's context
Below is the code to switch classloader context
Thread.currentThread().setContextClassLoader(jarClassLoader);
InputStream is = //reads from jar content
RuleBase ruleBase = RuleBaseLoader.getInstance().loadFromReader(
new InputStreamReader(is));
StatelessSession statelessSession = ruleBase.newStatelessSession();
statelessSession.executeWithResults(facts);
--
View this message in context: http://drools.46999.n3.nabble.com/dialect-java-is-not-loading-the-facts-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
Guvnor Sample Rule
by Sumeet Karawal
Hi,
I am trying to create rule in Guvnor and runnig it in Java Application on
Eclipse.
I have gone through the mortgages example provided in the distribution. I
am not sure that I am doing it correctly The steps I did are as follows :
1) Uploaded a POJO jar in Guvnor
2) Created a rule for checking the value of POJO data member
3) Built the package
4) Downloaded the ChangeSet.xml provided
5) Imported that ChangeSet.xml in Eclipse project under com.test package.
6) Created KnowledgeBase and fired the rules
My POJO :
package com.test;
public class CardHolder {
private int accno;
private double discount;
public int getAccno() {
return accno;
}
public void setAccno(int accno) {
this.accno = accno;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
}
My Rule Running Class :
package com.test;
import org.drools.KnowledgeBase;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.io.Resource;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
public class Discount_Provider {
public static void main(String[] args) {
CardHolder c1 = new CardHolder();
c1.setAccno(1005);
try{
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
ksession.insert(c1);
ksession.fireAllRules();
System.out.println("The discount applied is : "+
c1.getDiscount());
}
catch (Exception ex)
{
System.out.println("Exception is : "+ex);
}
}
private static KnowledgeBase readKnowledgeBase()
{
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent
("DiscAgent");
Resource changeset = ResourceFactory.newClassPathResource
("com/test/ChangeSet.xml");
kagent.applyChangeSet(changeset);
KnowledgeBase kbase = kagent.getKnowledgeBase();
kagent.dispose();
return kbase;
}
}
My Rule Content :
1.|rule "Discount_CardHolder"
2.| dialect "mvel"
3.| when
4.| $c : CardHolder( accno > 1001 )
5.| then
6.| $c.setDiscount( 10 );
7.| update( $c );
8.|end
Link from where I download the ChangeSet from Guvnor :
Change Set:
|-------------------------------------------------------------------------------------------------------------------------------------------->
|http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/TestPackage/LATEST/ChangeSet.xml |
|-------------------------------------------------------------------------------------------------------------------------------------------->
>-------------|
|(Embedded |
|image moved |
|to file: |
|pic19477.gif)|
>-------------|
Contents of ChangeSet.xml :
<change-set xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...'
>
<add>
<resource
source='http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Test...'
type='PKG' />
</add>
</change-set>
Errors that I get :
(null: 3, 175): schema_reference.4: Failed to read schema document
'http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...',
because 1) could not find the document; 2) the document could not be read;
3) the root element of the document is not <xsd:schema>.
(null: 3, 175): cvc-elt.1: Cannot find the declaration of element
'change-set'.
(null: 4, 10): schema_reference.4: Failed to read schema document
'http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...',
because 1) could not find the document; 2) the document could not be read;
3) the root element of the document is not <xsd:schema>.
(null: 5, 130): schema_reference.4: Failed to read schema document
'http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...',
because 1) could not find the document; 2) the document could not be read;
3) the root element of the document is not <xsd:schema>.
The discount applied is : 0.0
I am not able to get what should be done to make it run properly. Earlier
also I had tried to do this but faced many issues. By referring the
Mortgages example I tried to create the calling class. It would be very
helpful if some body could help me on this.
Thanks & Regards,
Sumeet
Mailto: sumeet.karawal(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
14 years, 8 months
[guvnor] Formula builder (or freeform drl builder) for Guided Editor (business rule)
by dhartford
Hey all,
I'm using only Guvnor for my rule creation and testing to feel-out how well
it would handle being the sole BRMS for the 80% scenarios. I understand the
Drools IDE definitely has more power and features, but I'm looking at ways
to give Business Analyst/non-coders more access and ability to interact with
rules.
One of the tricky areas I've run into is trying to always look back to the
model to know what fields are accessible when I'm trying to do any
checks/calculations/expressions/formulas using other fields or other models.
Is there something already on the burner for a formula builder where, at the
very least, provide available models and their attributes for use in
calculating a value modification or a WHEN expression? I see there is an
'expression builder', but that seems to only handle explicit 'field'
{equal|greater|less|not equal} 'field', where I'm looking for a editor pane
(kind of a like a sql builder) where you can see the available models and
fields.
This would also be useful here, but this has to do with web decision tables
and adding the ability to take formulas in their Action:
https://issues.jboss.org/browse/GUVNOR-1596
thanks for any feedback,
-Darren
--
View this message in context: http://drools.46999.n3.nabble.com/guvnor-Formula-builder-or-freeform-drl-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
A small doubt
by Manohar Kokkula
Hi
I am new to drools and going through its documentation on the website. I
have installed Drools - Expert and Guvnor (BRMS). My question is : Is
Drools Guvnor also a rule engine or do we use Guvnor just to manage the
rules, packages etc. How does Guvnor link with the Drools Rule Engine.
Thanks & Regards,
Manohar
Mailto: manohar.kokkula(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
14 years, 8 months
declaring attributes for an existing class
by Neel
Hi,I've following class defined:public class User {
private String id;
//get,set, equals & hashCode method are defined
}
If I add more attributes using declare syntax as below:declare User name : Stringend
it gives error "Error creating field accessors for 'User' for type 'User'". Is there a way, more attributes can be added in existing class using declare syntax?
Alternatively, if a class is created by using only declare syntax, can we add equals/hasCode methods dynamically?
Thanks & Regards,Neel
14 years, 8 months