Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multipurpose ITS Implementation Document 20021169 김계현 IM Lab.

Similar presentations


Presentation on theme: "Multipurpose ITS Implementation Document 20021169 김계현 IM Lab."— Presentation transcript:

1 Multipurpose ITS Implementation Document 20021169 김계현 IM Lab.

2 System Overview

3 Completed Modules

4 Main  class ITS  static void main(String[] args)  static void learn(KnowledgeBase kb, KnowledgeGenerator kg)  static void teach(KnowledgeBase kb, KnowledgeGenerator kg, Planner planner)

5 Knowledge Base

6 Knowledge Base (cont’d)  class KnowledgeBase  Concept addConcept(String name);  Relation addRelation(String name);  Fact addFact(String name, String[] premises, String[] conjunction, int n);  Rule addRule(Vector basis, String[] premises, String[][] terms, String conclusion, String[] cterms);  Fact ask(String relation, String[] terms);  void execute();  void print();

7 Fact

8 Fact (cont’d)  class Concept  class Relation  void addRule(Rule rule);  void addFact(Fact fact);  void focusOn();  boolean isTrue(Fact fact);  boolean isAlreadyDerived(Fact fact);  boolean isContradicted(Fact fact);  void on(IEngine ie, Fact fact);  boolean equals(Object item);  void print(Logger log, int depth);

9 Fact (cont’d)  class Fact  void print(Logger log, int depth);  Fact negates();  boolean equals(Object item);  void on(IEngine ie);

10 Rule

11 Rule (cont’d)  class Rule  void print(Logger log, int depth);  void on(IEngine ie, Fact fact);

12 Inference Engine

13 Inference Engine (cont’d)  class IEngine  void setQuery(Fact query)  void infer()  Vector getLies()  Vector getContradictions()  void accept(Fact accepted)  void contradict(Fact contradicted)  void addOn(…)

14 Inference Engine (cont’d)  switch-on 된 node 들에 대해 breadth-first search  각각의 관계는 다음과 같다.  Concept : 그 자신이 속한 모든 Fact 들을 on  Fact : 자신에게 속한 모든 Concept 들과 Relation 을 on  Relation : 해당 relation 이 조건부가 되는 모든 Rule 들 을 on  Rule : 결론부로서 derive 된 Fact 를 on  이 과정을, 더 이상 추가로 on 되는 node 가 없을 때까지 반복한다.

15 Inference Engine (cont’d)  public void on(IEngine ie, Fact fact)  // 새로 들어온 fact 를 print  // 해당 fact 의 concept 들을 substitutes 에 add  // i 번째 premise 와 match 하는 경우  // premise 와 negation 이 반대인 경우 전혀 가치없는 fact 이므로 그대로 종료  // 알맞은 substitutes 공간에 fact 의 concept 들을 각각 add  // 애초에 premise 의 해당 term 이 variable 이 아니라 constant concept 이면 add 안함  // 그 외에도 중복되지 않는 경우에 한해서만 add  // 새로 add 된 concept 이 먼저 check 가 되도록 맨 앞에 add 함  // 다른 premise 에 대해서는 볼 일이 없으므로 loop 를 탈출  // 아직 모든 premise 가 on 되지 않은 경우, conclusion 은 무조건 false 이므로 그대로 종료.  // 단, negative premise 에 대해서는 check 하지 않음. 하나라도 참인 fact 가 derive 되면 해당 premise 가 on 되어 버리므로...  // 각 variable 이 현재 가지고 있는 모든 substitute 들의 조합을 가지고 주어진 rule 을 만족하는지 check 하는 것이므로,  // 아래와 같이 전체 iteration 횟수 n 을 구함  // substitute 가 하나도 없는 variable 이 있으면 rule match 가 안되므로 그대로 종료  // 모든 가능한 substitute 의 조합에 대해 rule match 를 수행  // loopVariable[i] : i 번째 variable 의 substitute 들 중에 몇 번째 concept 을 현재 iteration 에서의 조합으로 취할지를 가리킴  // ex> loopVairable[0], [1], [2] 가 각각 3, 4, 5 라면, substitutes[0], [1], [2] 에서 각각 3, 4, 5 번째 concept 을 취하는 것.  // 이것이 끝까지 true 이면, 해당 iteration 에서의 조합이 올바른 fact 임을 의미  // rule match 는 각 premise 에 대해 수행되며, 모든 premise 에서 true 가 나와야 올바른 fact 가 됨  // 해당 premise 에서 사용되는 variable/concept 들의 index  // test 할 조합을 만듦  // index 값에 따라 usedConcept 또는 substitutes 에서 concept 을 가져와 조합을 만듦  // test 할 조합을 print  // test 를 수행. 이때 isTrue 대신 isAlreadyDerived 를 쓰는 편이 검사할 fact 의 개수가 적어서 더 빠르다.  // Concept-relation network 의 장점 중 하나가 바로, 기존의 모든 fact 들에 대해 검사할 필요가 없다는 점임  // 위에서 선택한 substitute 의 조합이 모든 premise 에 대해 true 가 나온 경우  // conclusion 에 대한 fact 를 만듦  // match 된 이 rule 과, 이 rule 로부터 derive 된 fact 를 print  // 다음 iteration 에서의 concept 의 조합을 계산  // 가장 마지막 variable 부터 개수를 늘려줌  // n 자리 10 진수에 1 을 더했을 때를 생각하면 됨  // 현재 숫자가 1188 이라면, 1188 + 1 = 1189 로 맨 끝자리만 계산하면 되지만, 1189 + 1 = 1190 으로  // 1 의자리는 0 으로 만들고, 다시 10 의자리에 1 을 더해줘야 함. 1199 + 1 = 1200 의 경우도 마찬가지.

16 Knowledge Generator

17 Knowledge Generator (cont’d)  class KnowledgeGenerator  Vector conjunctConcepts(Vector conjuncted, String added)  Fact[] addFacts(KnowledgeBase kb, Vector premises)  Vector premiseZero(Vector conjuncted, String relation, boolean isNegated);  Vector premiseN(Vector conjuncted, String rconj, String relation, String[] tconj, Vector[] targets, boolean isNegated);  Vector buildRule(Vector conditions, Vector matched, Vector unmatched);  Rule[] addRule(KnowledgeBase kb, Vector vectoredRules);  int setN(Vector conjuncted);  String negates(String relation);  int readInt();

18 Natural Language Recognizer

19 NLR (cont’d)  ({LETTER}|{DIGIT}|_)* {  …  else if(yytext().equals("if") | yytext().equals("If"))  tokenID = sym.IF;  else if(yytext().equals("but") |  yytext().equals("But") |  yytext().equals("However") |  yytext().equals("however") |  yytext().equals("even though")  | yytext().equals("Even though")  | yytext().equals("Nevertheless")  | yytext().equals("nevertheless"))  tokenID = sym.BUT;  …  }

20 NLR (cont’d)  paragraph ::= statementList  statementList ::= statementList statement | statement  statement ::= facts:fs endmark {: parser.kg.addFacts(parser.kb, fs); :} | rule:r endmark {: parser.kg.addRule(parser.kb, r); :} | error endmark

21 NLR (cont’d)  concept ::= concept ID | ID  facts ::= facts ANDOP fact | fact  conjunctedConcepts ::= conjunctedConcepts COMMA concept

22 NLR (cont’d)  fact ::= conjunctedConcepts IS concept | conjunctedConcepts IS concept OF conjunctedConcepts | conjunctedConcepts DO ID conjunctedConcepts …  rule ::= IF facts THEN facts | IF facts THEN facts ELSE facts

23 Planner  class Planner  Fact[] addQueries(KnowledgeBase kb, Vector premises);

24 Example  C:\...\code>java ITS  (0: load, 1: save, 2: learn, 3: teach, 4: exit) ? 2  West and is American.  East is criminal & East did sell sugar to China.  sugar is food.  China is hostile.  Scud, DaePoDong and Patriot are missile & Axe and Knife, Sasimi are weapon.  Nono is enemy of America.  West did sell Scud to Nono.  if _x is missile then _x is weapon.  if _x is enemy of America then _x is hostile.  if _x did sell _y to _z & _x is American & _y is weapon & _z is hostile then _x is criminal.

25 Example (cont’d)  *** Contents of Knowledge Base ***  Facts:  West is American ...  Scud is missile  Axe is weapon  East did sell sugar to China  sugar is food  China is hostile  Nono is enemy of America  West did sell Scud to Nono  Rules:  ( missile ) => weapon  ( enemy ) => hostile  ( sell American weapon hostile ) => criminal  (0: load, 1: save, 2: learn, 3: teach, 4: exit) ? 1

26 Example (cont’d)  (0: load, 1: save, 2: learn, 3: teach, 4: exit) ? 3  West is criminal.  On Concept: West  On Relation:  West is American  On Relation:  West did sell Scud to Nono ...  Iteration 0:  Scud is missile  *** On ConnectPremise ***  ( missile ) => weapon  *** Newly Derived Fact ***  Scud is weapon

27 Example (cont’d)  On Concept: America  Newly Added:  Nono is enemy of America  Iteration 0:  Nono is enemy of America  *** On ConnectPremise ***  ( enemy ) => hostile  *** Newly Derived Fact ***  Nono is hostile ...

28 Example (cont’d)  Iteration 0:  West did sell Scud to Nono  West is American  Scud is weapon  Nono is hostile  *** On ConnectPremise ***  ( sell American weapon hostile ) => criminal  *** Newly Derived Fact ***  West is criminal ...  On Relation:  West is criminal  ** TrulyAccepted **  West is criminal  ALL TRUE  (0: load, 1: save, 2: learn, 3: teach, 4: exit) ? 4  C:\...\code>


Download ppt "Multipurpose ITS Implementation Document 20021169 김계현 IM Lab."

Similar presentations


Ads by Google