Results 1 to 4 of 4
  1. #1
    Join Date
    May 2012
    Posts
    2
    Rep Power
    0

    Default Propagate Method

    Can someone help me write this propagate method, what needs to be done is written in comments I am just not so sure about it?




    public class RuleNet {

    private ArrayList<RuleNode> rulenodes; // the nodes in the network
    private ArrayList<String> factsToPropagate; //facts not yet propagated
    private ArrayList<ArrayList<RuleNode>> targetNodeLists; //each element is list of nodes which corresponding fact should be propagated to
    EasyWriter scr = new EasyWriter();

    /**
    * constructor is given the RuleNodes in the network
    */
    public RuleNet (ArrayList<RuleNode> a){ //constructor is given the RuleNodes
    rulenodes = a;
    }

    /**
    * accessor for the RuleNodes
    */
    public ArrayList<RuleNode> getRules() {return rulenodes;}

    /**
    * Initialise all the RuleNodes
    * to contain a single token: all antecedents, empty context
    */
    public void initialise() { //initialise the rules - set initial tokens

    for (RuleNode r: rulenodes){
    r.initialise(); //set initial tokens in each node
    factsToPropagate=new ArrayList<String>(); //set toPropagate & targetNodes empty
    targetNodeLists = new ArrayList<ArrayList<RuleNode>>();
    }
    }
    /**
    * add a fact and make all the deductions
    * by calling self.propagate
    */

    public void addFact(String f){ // add a fact & make all deductions
    factsToPropagate.add(f);
    targetNodeLists.add(rulenodes); //propagate to all nodes
    propagate();
    }

    /**
    * drive the propagation of facts
    * take next fact from factsToPropagate
    * take the list of nodes to propagate it to from targetNodeLists
    * do this using the node's propagate method
    * if this results in deductions, then for each deduction
    * print it out
    * add it to factsToPropagate
    * add the rulenode's successors list to targetNodeLists
    * continue until no more facts to propagate
    */

    public void propagate(){ //drive the propagation of facts

    for fact in factsToPropagate{
    for target in tagetNodeLists{
    if / else
    System.out.println()
    fact


    }
    }



    Any help would be greatly appreciated thank you.

  2. #2
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: Propagate Method

    Implement it and see if it works...? Guess it is called "learning by doing" :)
    I like likes!

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Propagate Method

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    Join Date
    May 2012
    Posts
    2
    Rep Power
    0

Similar Threads

  1. Replies: 2
    Last Post: 03-23-2012, 05:53 AM
  2. Replies: 1
    Last Post: 10-27-2011, 08:16 AM
  3. Replies: 1
    Last Post: 10-17-2011, 02:00 AM
  4. Declaring a method inside a method: Runnable?
    By africanhacker in forum New To Java
    Replies: 8
    Last Post: 03-23-2011, 05:30 AM
  5. Turning Recursion Method into Iterative method
    By mattakuevan in forum New To Java
    Replies: 9
    Last Post: 06-15-2010, 07:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •