Re: JESS: how to write If else rule

2009-01-28 Thread James C. Owen

Greetings:

I've been criticized by JM recently for not getting more involved in
Jess solutions.  So, here goes.  The example below violates one of the
basic principles of all rulebased systems.  The logic (i.e., the
Conditional Elements, CE) should ALL be in the LHS of the rules.  By
putting IF conditions in the RHS you have put CEs where there should
be nothing but Action Elements, AE.  The one thing that most folks
don't realize is that a rule that states

IF A or B THEN C

is actually two Rules.  IF A THEN C, IF B THEN C

at the same time, an ELSE condition is the negation of the entire LHS
of the rule.  For example

Rule1
IF (A and B and C and D) THEN D

To enter the ELSE you would have

Rule2
IF (A and B and C and D) THEN D ELSE E

which is nothing more than

Rule2a
IF (A and B and C and D) THEN D;
Rule2b
IF !(A and B and C and D) THEN E;

of which the else rule is

Rule2b-1
IF (A or B or C or D) THEN E
which is
Rule2b-1a
IF A THEN E
Rule2b-1b
IF B THEN E
Rule2b-1c
IF C THEN E
Rule2b-1d
IF D THEN E

The OR statements and the ELSE statements are usually handled by the
engine - sometimes called syntatical sugar.  What we need to do is get
back to basics and understand that rules are to solve complex problems
in logic and not used to run through massive sets of numbers looking
for a needle in a haystack - that's something far better handled by
Java, C++, C or even ASM.

Reading through the emails is like reading the old Obfuscated C
programs - most of them wondering how complex to make a procedural
problem and thereby justify using a rulebase?  We should be using
procedural languages for procedural problems, not an inference engine.

Jason Morris used to have a blog called The Zen of Jess wherein he
basically taught how to use a rulebase.  Not sure why he quit writing
except maybe he just got tired of doing the same thing day after day
after day after...  My suggestion is that everyone should Read The
Fabulous Manual (or the Fabulous Book - JIA) BEFORE beginning to write
the first rule for a practical application or asking questions online!

SDG
jco
This above all: to thine own self be true,
And it must follow, as the night the day,
Thou canst not then be false to any man.
Hamlet, Act 1, Scene III
http://www-tech.mit.edu/Shakespeare/hamlet/hamlet.1.3.html

On Dec 11, 2008, at 5:03 AM, Joao Antunes Mourao wrote:


(defrule name-of-the-rule
  (put here your conditions for the rule, if any)
=
(if (condition) then
  (put your things here)
)
(if (condition) then
  (put your things here)
else
  (put your things here)
))

Simple. Good luck.

Joao
---
unclassified email

On 10-12-2008 05:47, hansari wrote:

I need rule for

if (condtion1)
then (acton1)
if else (conditon2)
then   (action2)
if else (condition3)
then (action3)
else (acton4)

how can perform this by using defrule please help me.

thank you.




Disclaimer:

If you are not the intended recipient of this email, please notify
the sender and delete it. Any unauthorized copying, disclosure or
distribution of this email or its attachment(s) is forbidden. Thales
Nederland BV will not accept liability for any damage caused by this
email or its attachment(s). Thales Nederland BV is seated in Hengelo
and is registered at the Chamber of Commerce under number 06061578.


joao.mourao.vcf




Re: JESS: how to write If else rule

2008-12-11 Thread Joao Antunes Mourao

(defrule name-of-the-rule
   (put here your conditions for the rule, if any)
=
(if (condition) then
   (put your things here)
)
(if (condition) then
   (put your things here)
else
   (put your things here)
))

Simple. Good luck.

Joao
---
unclassified email

On 10-12-2008 05:47, hansari wrote:

I need rule for

if (condtion1)
 then (acton1)
if else (conditon2)
then   (action2)
if else (condition3)
then (action3)
else (acton4)

how can perform this by using defrule 
please help me.


thank you. 
  




Disclaimer:

If you are not the intended recipient of this email, please notify the sender and delete it. 
Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden. 
Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s). 
Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578.



begin:vcard
fn;quoted-printable:Jo=C3=A3o Mour=C3=A3o
n;quoted-printable;quoted-printable:Mour=C3=A3o;Jo=C3=A3o
org:Thales;Above Water Systems
adr:;;;Hengelo;;;Netherlands
email;internet:[EMAIL PROTECTED]
title:THALES NETHERLANDS B.V.
tel;work:2640
note:-unclassified mail-
version:2.1
end:vcard



Re: JESS: how to write If else rule

2008-12-11 Thread Dusan Sormaz

Joao,

I beg here to differ from this approach.

This approach shows how to write if-then-else  in Lisp, which is not 
different from writing them in any language with if-then-else 
conditional statements (and all of them support IF logic).


Writing your conditions in a rule language like Jess assumes that you 
utilize benefits of rule-based approach, which includes data-driven 
order of execution.


Dusan Sormaz

Joao Antunes Mourao wrote:

(defrule name-of-the-rule
   (put here your conditions for the rule, if any)
=
(if (condition) then
   (put your things here)
)
(if (condition) then
   (put your things here)
else
   (put your things here)
))

Simple. Good luck.

Joao
---
unclassified email

On 10-12-2008 05:47, hansari wrote:

I need rule for

if (condtion1)
 then (acton1)
if else (conditon2)
then   (action2)
if else (condition3)
then (action3)
else (acton4)

how can perform this by using defrule please help me.

thank you.   



 


Disclaimer:

If you are not the intended recipient of this email, please notify the 
sender and delete it. Any unauthorized copying, disclosure or 
distribution of this email or its attachment(s) is forbidden. Thales 
Nederland BV will not accept liability for any damage caused by this 
email or its attachment(s). Thales Nederland BV is seated in Hengelo 
and is registered at the Chamber of Commerce under number 06061578.
 





--
***
* Dusan Sormaz, PhD, Associate Professor
* Ohio University
* Department of Industrial and Systems Engineering
* 284 Stocker Center, Athens, OH 45701-2979
* phone: (740) 593-1545 
* fax:nbsp;nbsp; (740) 593-0778
* e-mail: [EMAIL PROTECTED] 
* url: http://www.ent.ohiou.edu/~sormaz

***




To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]




Re: JESS: how to write If else rule

2008-12-10 Thread Dusan Sormaz

Hasan,

Jess (and other rule-based languages) is not procedural, but more 
declarative.


rules are in the form:

(defrule myrule
   (condition 1)
(condition 2)
(condituin 3)
=
(action 1)
(action 2 ))

Each rule is independent of others. All of them are evaluated for their 
conditions and one is selected to run. Conditions are in the from of 
patterns which are defined using facts. Order of execution of the  rules 
is defined by set of facts.


for more details read Jess manual and books or rule-based programming.

Dusan Sormaz
hansari wrote:

I need rule for

if (condtion1)
 then (acton1)
if else (conditon2)
then   (action2)
if else (condition3)
then (action3)
else (acton4)

how can perform this by using defrule 
please help me.


thank you. 
  


--
***
* Dusan Sormaz, PhD, Associate Professor
* Ohio University
* Department of Industrial and Systems Engineering
* 284 Stocker Center, Athens, OH 45701-2979
* phone: (740) 593-1545 
* fax:nbsp;nbsp; (740) 593-0778
* e-mail: [EMAIL PROTECTED] 
* url: http://www.ent.ohiou.edu/~sormaz

***




To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]




Re: JESS: how to write If else rule

2008-12-10 Thread Kartik Tadanki


The way one should do it in JESS is not procedurally has been expected here.

The conditions should be used to build the rules separately,
If you need an else if structure, it ideally is what  JESS does naturally.
However , if your requirement is :
   if(c1)
   {
   a1.
   if(c2)
   {
  a2.
   }
   }
 Then you could simply use both the conditions in the rule for firing 
a2 and only c1 for a1.



hansari wrote:

I need rule for

if (condtion1)
 then (acton1)
if else (conditon2)
then   (action2)
if else (condition3)
then (action3)
else (acton4)

how can perform this by using defrule 
please help me.


thank you. 
  





To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]