Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uchicago.src.sim.network
Class Linker

    java.lang.Object
      uchicago.src.sim.network.Linker

    public class Linker

extends java.lang.Object

Creates links between nodes based on some `ProbabilityRule`. The idea here is that a Node will have an associated Linker. It will use Linker to create links with the other Nodes in the network. The appropriate calling sequence, assuming the Linker is already constructed, is: ``

     linker.init();
     linker.makeLink(this, new SomeEdge());

`where this is the node that contains the linker, and SomeEdge is whatever sort of Edge is being used in the model.

Version:
  $Revision: 1.9 $ $Date: 2004/11/03 19:51:01 $

Constructor Summary
`Linker(ProbabilityRule probRule)` Creates a Linker that uses the specified ProbabilityRule to determine link creation.

Method Summary
`RangeMap` | `getMap()` Returns the probability map.
`java.lang.Object` | `getNodeForLink()` Returns a random object from the probabililty map created by the ProbabilityRule.
`double` | `getProbabilityFor(java.lang.Object o)` Gets the probability for the specified object according to the Probability Rule passed in the constructor.
`void` | `init()` Initializes this Linker for link creation and getting probabilties.
`Node` | `makeLink(Node from, Edge edge)` Makes a link between the specified Node using the specified Edge and a Node chosen at random from the probability map, and calls this Linker's update method with this random node and a value of 1 as the arguments.
`Node` | `makeLink(Node from, Edge edge, float amtToUpdate)` Makes a link between the specified Node using the specified Edge and a Node chosen at random from the probability map and calls this Linker's update method with this random node and the specified value as arguments.
`void` | `setProbabilityRule(ProbabilityRule probRule)` Sets the ProbabilityRule used by this Linker.
`void` | `update(java.lang.Object o)` Updates the probability of the specified object in the probability map.
`void` | `update(java.lang.Object o, float amt)` Updates the probability of the specified object in the probability map with the specified amount.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Linker

    public Linker(ProbabilityRule probRule)

  Creates a Linker that uses the specified ProbabilityRule to determine link creation.

  Parameters:
    `probRule` - the ProbabilityRule to use in link creation

Method Detail

### setProbabilityRule

    public void setProbabilityRule(ProbabilityRule probRule)

  Sets the ProbabilityRule used by this Linker.

  Parameters:
    `probRule` - the ProbabilityRule to use in link creation

### init

    public void init()

  Initializes this Linker for link creation and getting probabilties. This recreates the probability map incorporating any changes that resulted from calls to update. This should be called before any calls to makeLink, getProbabilityFor, or getNodeForLink if the result of those calls is to reflect any updates.

### getNodeForLink

    public java.lang.Object getNodeForLink()

  Returns a random object from the probabililty map created by the ProbabilityRule.

### getMap

    public RangeMap getMap()

  Returns the probability map.

### update

    public void update(java.lang.Object o)

  Updates the probability of the specified object in the probability map. This calls the corresponding update method in the ProbabilityRule passed in the constructor. The results of this call are not reflected in the probability map until init() is called.

  Parameters:
    `o` - the object whose probability is to be updated.

### update

    public void update(java.lang.Object o,
                       float amt)

  Updates the probability of the specified object in the probability map with the specified amount. This calls the corresponding update method in the ProbabilityRule passed in the constructor. The results of this call are not reflected in the probability map until init() is called.

  Parameters:
    `o` - the object whose probability is to be updated.
    `amt` - the amt to update.

### getProbabilityFor

    public double getProbabilityFor(java.lang.Object o)

  Gets the probability for the specified object according to the Probability Rule passed in the constructor.

### makeLink

    public Node makeLink(Node from,
                         Edge edge)

  Makes a link between the specified Node using the specified Edge and a Node chosen at random from the probability map, and calls this Linker's update method with this random node and a value of 1 as the arguments. Note that this only adds an OutEdge to the from node, and nothing to the toNode.

  Parameters:
    `from` - the node to make the link from.
    `edge` - the Edge to make the link out of.
  Returns:
    the random node that is the target of the link.

### makeLink

    public Node makeLink(Node from,
                         Edge edge,
                         float amtToUpdate)

  Makes a link between the specified Node using the specified Edge and a Node chosen at random from the probability map and calls this Linker's update method with this random node and the specified value as arguments. Note that this only adds an OutEdge to the from node, and nothing to the toNode.

  Parameters:
    `from` - the node to make the link from.
    `edge` - the Edge to make the link out of.
    `amtToUpdate` - the amount to pass to this Linker's update method.
  Returns:
    the random node that is the target of the link.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

`