To jest stara wersja strony!


Opis

Szymon Frenkel sfrenkel@student.bez-spamu.agh.edu.pl

Analyze how to design Drools rules with XTT2

  • Pokrewny projekt: Drools_X - Grzegorz Stopa

Spotkania

20090402

  • kategoryzacja przykładów, opis, ile reguł, atr, etc, czego dotyczą

20090326

* …

20090319

20090312

20090225

Zapoznanie z działaniem Drools.

Projekt

1. Przykłady systemów ekspertowych w Drools

Zastosowanie w zarządzaniu

www.ibm.com/developerworks/java/library/j-drools

  • Opis

The problem to solve

  • A company named XYZ builds two types of computer machines: Type1 and Type2. A machine's type is defined by its architecture.
  • An XYZ computer can serve multiple functions. Four functions are currently defined: DDNS Server, DNS Server, Gateway, and Router.
  • XYZ performs several tests on each machine before it is shipped out.
  • The tests performed on each machine depend on each machine's type and functions. Currently, five tests are defined: Test1, Test2, Test3, Test4, and Test5.
  • When tests are assigned to a computer, a tests due date is also assigned to the machine. Tests assigned to the computer should be conducted no later than this due date. The due date's value depends on the tests that were assigned to the machine.
  • XYZ has automated much of the process for executing the tests using an internally developed software application that can determine a machine's type and functions. Then, based on these properties, the application determines which tests to execute and their due date.
  • Currently, the logic that assigns the tests and tests due date to a computer is part of this application's compiled code. The component that contains this logic is written in the Java language.
  • The logic for assigning tests and due dates is changed more than once a month. The developers must go through a tedious process every time they need to implement it in the Java code.
  • Własności
  • 10 reguł
  • 5 jedno-atrybutowych
  • 5 dwu-atrybutowych
  • kod źródłowy
rule "Tests for type1 machine"
 
salience 100
when
	machine : Machine( type == "Type1" )
then	
	Test test1 = testDAO.findByKey(Test.TEST1);
	Test test2 = testDAO.findByKey(Test.TEST2);
	Test test5 = testDAO.findByKey(Test.TEST5);
	machine.getTests().add(test1);
	machine.getTests().add(test2);
	machine.getTests().add(test5);
	insert( test1 );
	insert( test2 );
	insert( test5 );
end
 
rule "Tests for type2, DNS server machine"
salience 100
when
	machine : Machine( type == "Type2", functions contains "DNS Server")
then	
	Test test5 = testDAO.findByKey(Test.TEST5);
	Test test4 = testDAO.findByKey(Test.TEST4);
	machine.getTests().add(test5);
	machine.getTests().add(test4);
	insert( test4 );
	insert( test5 );		
end
 
rule "Tests for type2, DDNS server machine"
salience 100
when
	machine : Machine( type == "Type2", functions contains "DDNS Server")
then	
	Test test2 = testDAO.findByKey(Test.TEST2);
	Test test3 = testDAO.findByKey(Test.TEST3);
	machine.getTests().add(test2);
	machine.getTests().add(test3);
	insert( test2 );
	insert( test3 );		
end
 
rule "Tests for type2, Gateway machine"
salience 100
when
	machine : Machine( type == "Type2", functions contains "Gateway")
then		
	Test test3 = testDAO.findByKey(Test.TEST3);
	Test test4 = testDAO.findByKey(Test.TEST4);
	machine.getTests().add(test3);
	machine.getTests().add(test4);
	insert( test3 );
	insert( test4 );		
end
 
rule "Tests for type2, Router machine"
salience 100
when
	machine : Machine( type == "Type2", functions contains "Router")
then	
	Test test3 = testDAO.findByKey(Test.TEST3);
	Test test1 = testDAO.findByKey(Test.TEST1);
	machine.getTests().add(test3);
	machine.getTests().add(test1);
	insert( test1 );
	insert( test3 );					
end
 
rule "Due date for Test 5"
salience 50
when
	machine : Machine()
	Test( id == Test.TEST5 )
then	
	setTestsDueTime(machine, 14);				
end
 
rule "Due date for Test 4"
salience 40
when
	machine : Machine()
	Test( id == Test.TEST4 )
then	
	setTestsDueTime(machine, 12);				
end
 
rule "Due date for Test 3"
salience 30
when
	machine : Machine()
	Test( id == Test.TEST3 )
then	
	setTestsDueTime(machine, 10);				
end
 
rule "Due date for Test 2"
salience 20
when
	machine : Machine()
	Test( id == Test.TEST2 )
then	
	setTestsDueTime(machine, 7);				
end
 
Rule "Due date for Test 1"
salience 10
when
	machine : Machine()
	Test( id == Test.TEST1 )
then	
	setTestsDueTime(machine, 3);				
end

Przykład systemu dla firmy

Przykład systemu dla firmy

  • Opis
  • Własności
  • 8 reguł
  • 1 jedno-atrybutowa
  • 5 dwu-atrybutowych
  • 2 trój-atrybutowe
  • kod źródłowy
    rule "Age verification"
        when
            Borrower(age < 18)
            $loanApp : LoanApplication()
        then
            $loanApp.addFeedbackMessage(FeedbackMessages.MIN_AGE);
    end
 
    rule "Credit score"
 
        when
            Borrower(creditScore <= 600)
            $loanApp : LoanApplication()
        then
            $loanApp.addFeedbackMessage(FeedbackMessages.MIN_CREDIT_SCORE);
    end
 
    rule "Loan Amount limits"
        when
            $loanApp : (LoanApplication(loanAmount <= 100000.0) or
            LoanApplication(loanAmount >= 400000.0))
        then
            $loanApp.addFeedbackMessage(FeedbackMessages.LOAN_AMOUNT_LIMITS);
    end
 
    rule "Maximum Loan-to-value ratio"
        when
            $loanApp : LoanApplication(loanToValueRatio > 80.0)
        then
            $loanApp.addFeedbackMessage(FeedbackMessages.LTV);
    end
 
    rule "Income multiples"
        salience -3
        when
            Borrower( $grossIncome : grossIncome )
            Property( value > (new Double($grossIncome.doubleValue()*3)))
            $loanApp : LoanApplication()
        then
            $loanApp.setAffordabilityFlag(Flag.NOT_AFFORDABLE);
    end
 
    rule "Affordability Model"
        salience -4
        when
            Borrower( $affordableLoanAmount : affordableLoanAmount )
            Property( value > (new Double($affordableLoanAmount.doubleValue())))
            $loanApp : LoanApplication()
        then
            $loanApp.setAffordabilityFlag(Flag.NOT_AFFORDABLE);
    end
    rule "Property type"
        when
            Property(purpose != Flag.OWNER_OCCUPIED)
            $loanApp : LoanApplication()
        then
            $loanApp.addFeedbackMessage(FeedbackMessages.PROP_TYPE);
    end
 
    rule "Property age"
        when
            Property(yearBuilt < 1965)
            $loanApp : LoanApplication()
        then
            $loanApp.addFeedbackMessage(FeedbackMessages.PROP_YEAR_BUILT);
    end

Przykład reguł biznesowych

Bilety

Bilety

 wykorzystanie zależności czasowych w prostym systemie przydzielania biletów klientom\\ 

TroubleTicket.drl

Sprawozdanie

Prezentacja

Materiały

pl/miw/2009/miw09_xtt_drools.1240428321.txt.gz · ostatnio zmienione: 2019/06/27 15:58 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0