public final class EmasAgent extends java.lang.Object implements Agent
Implementation of agent for EMAS.
This type of agent requires identity (thus we have ID field).
EMAS model requires that an agent is described by: * its energy, * its solution.
This implementation is immutable and untyped in regards to the solution instance.
Modifier and Type | Field and Description |
---|---|
double |
energy |
java.util.UUID |
id |
private static long |
serialVersionUID |
Solution<?> |
solution |
Modifier | Constructor and Description |
---|---|
private |
EmasAgent(double energy,
Solution<?> solution) |
private |
EmasAgent(java.util.UUID id,
double energy,
Solution<?> solution) |
Modifier and Type | Method and Description |
---|---|
static EmasAgent |
create(double energy,
Solution<?> solution)
Creates a new agent.
|
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
java.lang.String |
toString() |
EmasAgent |
withEnergy(double newEnergy)
Create a copy of this agent with a new energy value.
|
EmasAgent |
withSolution(Solution<?> newSolution)
Create a copy of this agent with a new solution value.
|
private static final long serialVersionUID
public final java.util.UUID id
public final double energy
public final Solution<?> solution
private EmasAgent(double energy, Solution<?> solution)
private EmasAgent(java.util.UUID id, double energy, Solution<?> solution)
public static EmasAgent create(double energy, Solution<?> solution)
Creates a new agent.
energy
- initial energysolution
- initial solutionpublic EmasAgent withEnergy(double newEnergy)
Create a copy of this agent with a new energy value.
The agent identity is preserved.
newEnergy
- new energy for this agentpublic EmasAgent withSolution(Solution<?> newSolution)
Create a copy of this agent with a new solution value.
The agent identity is preserved.
newSolution
- new solution for this agentpublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object