agents.context

## Class Context

- java.lang.Object
- - agents.Agent
  - - agents.SystemAgent
    - - agents.context.AbstractContext
      - - agents.context.Context

All Implemented Interfaces:
  java.io.Serializable

    public class Context
    extends AbstractContext
    implements java.io.Serializable

The core agent of AMOEBA.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`Context(Context c)` Instantiates a new context.
`Context(World world, Head head)` The main constructor, used by AMOEBA to build new context agent.
`Context(World world, Head controller, java.util.HashMap<java.lang.String,java.lang.Double> mins, java.util.HashMap<java.lang.String,java.lang.Double> maxs, java.util.HashMap<java.lang.String,java.lang.Double> exps, double experimentValue, java.lang.String contextName)` Instantiates a new context.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `analyzeResults(Head ctrl)` Analyze results.
`void` `computeAMessage(Message m)` Compute A message.
`boolean` `computeValidity()` Compute validity.
`void` `die()` Remove all the references in other agents and remove the agent from the scheduler.
`double` `getAction()` Gets the action.
`double` `getActionProposal()` Gets the action proposal.
`double` `getConfidence()` Gets the confidence.
`Head` `getControler()` Gets the controler.
`java.util.ArrayList<Experiment>` `getExperiments()` Gets the experiments.
`LocalModelAgent` `getFunction()` Gets the function.
`int` `getNSelection()` Gets the n selection.
`java.util.HashMap<Percept,Range>` `getRanges()` Gets the ranges.
`java.util.ArrayList<? extends Agent>` `getTargets()` Gets the targets.
`java.lang.Double` `getValueActionProposition()` Gets the value action proposition.
`void` `growRanges(Head head)` Grow every ranges allowing to includes current situation.
`void` `init()` Inits the.
`boolean` `isBestContext()` Checks if is best context.
`boolean` `isFirstTimePeriod()` Checks if is first time period.
`boolean` `isValid()` Checks if is valid.
`void` `play()` Play one agent step.
`void` `playEndCycle()` Play end cycle.
`void` `setAction(double action)` Sets the action.
`void` `setBestContext(boolean bestContext)` Sets the best context.
`void` `setConfidence(double confidence)` Sets the confidence.
`void` `setControler(Head controler)` Sets the controler.
`void` `setExperiments(java.util.ArrayList<Experiment> experiments)` Sets the experiments.
`void` `setFirstTimePeriod(boolean firstTimePeriod)` Sets the first time period.
`void` `setFunction(LocalModelAgent function)` Sets the function.
`void` `setnSelection(int nSelection)` Sets the n selection.
`void` `setRanges(java.util.HashMap<Percept,Range> ranges)` Sets the ranges.
`void` `setValid(boolean valid)` Sets the valid.
`void` `shrinkRanges(Head head)` Shrink one range in order to exclude current situation.
`void` `shrinkRangesToJoinBorders(Head head, Context c)` Shrink ranges to join borders.
`void` `solveNCS_Concurrence(Head head)` Solve NC S concurrence.
`void` `solveNCS_IncompetentHead(Head head)` Solve NC S incompetent head.
`java.lang.String` `toString()`

### Methods inherited from class agents.SystemAgent

`getWorld, setWorld`

### Methods inherited from class agents.Agent

`getID, getMessages, getMessagesBin, getName, isDying, readMessage, sendExpressMessage, sendMessage, sendMessage, setDying, setID, setMessages, setMessagesBin, setName`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### Context

    public Context(World world,
                   Head head)

The main constructor, used by AMOEBA to build new context agent.

Parameters:
  `world` - : the world where the agent must live.
  `head` - : the head agent associated with the next context agent

#### Context

    public Context(World world,
                   Head controller,
                   java.util.HashMap<java.lang.String,java.lang.Double> mins,
                   java.util.HashMap<java.lang.String,java.lang.Double> maxs,
                   java.util.HashMap<java.lang.String,java.lang.Double> exps,
                   double experimentValue,
                   java.lang.String contextName)

Instantiates a new context.

Parameters:
  `world` - the world
  `controller` - the controller
  `mins` - the mins
  `maxs` - the maxs
  `exps` - the exps
  `experimentValue` - the experiment value
  `contextName` - the context name

#### Context

    public Context(Context c)

Instantiates a new context.

Parameters:
  `c` - the c

### Method Detail

#### getValueActionProposition

    public java.lang.Double getValueActionProposition()

Gets the value action proposition.

Returns:
  the value action proposition

#### computeAMessage

    public void computeAMessage(Message m)

Description copied from class: `Agent`
Compute A message.

Overrides:
  `computeAMessage` in class `AbstractContext`
Parameters:
  `m` - the m

#### play

    public void play()

Description copied from class: `Agent`
Play one agent step.

Overrides:
  `play` in class `SystemAgent`

#### solveNCS_IncompetentHead

    public void solveNCS_IncompetentHead(Head head)

Solve NC S incompetent head.

Parameters:
  `head` - the head

#### solveNCS_Concurrence

    public void solveNCS_Concurrence(Head head)

Solve NC S concurrence.

Parameters:
  `head` - the head

#### getActionProposal

    public double getActionProposal()

Gets the action proposal.

Returns:
  the action proposal

#### computeValidity

    public boolean computeValidity()

Compute validity.

Returns:
  true, if successful

#### getRanges

    public java.util.HashMap<Percept,Range> getRanges()

Gets the ranges.

Returns:
  the ranges

#### setRanges

    public void setRanges(java.util.HashMap<Percept,Range> ranges)

Sets the ranges.

Parameters:
  `ranges` - the ranges

#### getControler

    public Head getControler()

Gets the controler.

Returns:
  the controler

#### setControler

    public void setControler(Head controler)

Sets the controler.

Parameters:
  `controler` - the new controler

#### getAction

    public double getAction()

Gets the action.

Returns:
  the action

#### setAction

    public void setAction(double action)

Sets the action.

Parameters:
  `action` - the new action

#### getTargets

    public java.util.ArrayList<? extends Agent> getTargets()

Description copied from class: `SystemAgent`
Gets the targets.

Overrides:
  `getTargets` in class `AbstractContext`
Returns:
  the targets

#### init

    public void init()

Inits the.

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### getNSelection

    public int getNSelection()

Gets the n selection.

Returns:
  the n selection

#### setnSelection

    public void setnSelection(int nSelection)

Sets the n selection.

Parameters:
  `nSelection` - the new n selection

#### isValid

    public boolean isValid()

Checks if is valid.

Returns:
  true, if is valid

#### setValid

    public void setValid(boolean valid)

Sets the valid.

Parameters:
  `valid` - the new valid

#### isFirstTimePeriod

    public boolean isFirstTimePeriod()

Checks if is first time period.

Returns:
  true, if is first time period

#### setFirstTimePeriod

    public void setFirstTimePeriod(boolean firstTimePeriod)

Sets the first time period.

Parameters:
  `firstTimePeriod` - the new first time period

#### isBestContext

    public boolean isBestContext()

Checks if is best context.

Returns:
  true, if is best context

#### setBestContext

    public void setBestContext(boolean bestContext)

Sets the best context.

Parameters:
  `bestContext` - the new best context

#### getFunction

    public LocalModelAgent getFunction()

Gets the function.

Returns:
  the function

#### setFunction

    public void setFunction(LocalModelAgent function)

Sets the function.

Parameters:
  `function` - the new function

#### getExperiments

    public java.util.ArrayList<Experiment> getExperiments()

Gets the experiments.

Returns:
  the experiments

#### setExperiments

    public void setExperiments(java.util.ArrayList<Experiment> experiments)

Sets the experiments.

Parameters:
  `experiments` - the new experiments

#### getConfidence

    public double getConfidence()

Gets the confidence.

Returns:
  the confidence

#### setConfidence

    public void setConfidence(double confidence)

Sets the confidence.

Parameters:
  `confidence` - the new confidence

#### playEndCycle

    public void playEndCycle()

Play end cycle.

#### analyzeResults

    public void analyzeResults(Head ctrl)

Analyze results.

Parameters:
  `ctrl` - the ctrl

#### growRanges

    public void growRanges(Head head)

Grow every ranges allowing to includes current situation.

Parameters:
  `head` - the head

#### shrinkRanges

    public void shrinkRanges(Head head)

Shrink one range in order to exclude current situation.

Parameters:
  `head` - the head

#### shrinkRangesToJoinBorders

    public void shrinkRangesToJoinBorders(Head head,
                                          Context c)

Shrink ranges to join borders.

Parameters:
  `head` - the head
  `c` - the c

#### die

    public void die()

Description copied from class: `AbstractContext`
Remove all the references in other agents and remove the agent from the scheduler.

Overrides:
  `die` in class `AbstractContext`