24 package org.lightvoting.simulation.environment;
26 import cern.colt.bitvector.BitVector;
27 import org.lightjason.agentspeak.language.CLiteral;
28 import org.lightjason.agentspeak.language.CRawTerm;
29 import org.lightjason.agentspeak.language.ILiteral;
30 import org.lightjason.agentspeak.language.ITerm;
31 import org.lightjason.agentspeak.language.instantiable.plan.trigger.CTrigger;
32 import org.lightjason.agentspeak.language.instantiable.plan.trigger.ITrigger;
36 import java.util.LinkedList;
37 import java.util.List;
65 m_agentList.add( p_votingAgent );
66 m_chair = p_votingAgent.getChair();
69 if (
"RANDOM".equals( p_grouping ) )
84 return CLiteral.from(
"group", CRawTerm.from(
m_chair ), CRawTerm.from(
this.open() ), CRawTerm.from(
m_result ),
85 CRawTerm.from( m_agentList.contains( p_votingAgent ) ) );
95 final List<ITerm> l_terms =
new LinkedList<>();
97 for (
int i = 0; i < m_agentList.size(); i++ )
98 l_terms.add( CRawTerm.from(
m_agentList.get( i ) ) );
101 if ( ( this.
m_chair ).equals( p_chairAgent ) )
102 return CLiteral.from(
"group", CRawTerm.from( this ) );
117 System.out.println(
"Adding agent, old size is " + m_agentList.size() );
118 m_agentList.add( p_votingAgent );
134 System.out.println(
"Adding agent, old size is " + m_agentList.size() );
135 m_agentList.add( p_votingAgent );
142 m_agentList.remove( p_votingAgent );
166 m_agentList.forEach( i ->
169 ITrigger.EType.ADDGOAL,
172 CRawTerm.from( p_chairAgent ) )
184 return m_agentList.size();
197 m_agentList.stream().forEach( i ->
198 i.trigger( CTrigger.from(
199 ITrigger.EType.ADDGOAL,
200 CLiteral.from(
"election/result",
201 CRawTerm.from( p_chairAgent ),
202 CRawTerm.from( p_result ) )
208 return this.literal( p_chairAgent );
222 m_agentList.stream().forEach( i ->
224 i.trigger( CTrigger.from(
225 ITrigger.EType.ADDGOAL,
226 CLiteral.from(
"election/result",
227 CRawTerm.from( p_chairAgent ),
228 CRawTerm.from( p_result ),
229 CRawTerm.from( p_iteration ) )
232 System.out.println(
"triggering agent " + i.name() );
236 return this.literal( p_chairAgent );
288 for (
int i = 0; i < m_agentList.size(); i++ )
289 if ( p_agentName.equals(
m_agentList.get( i ).name() ) )
boolean readyForElection()
BitVector result()
return current result
ILiteral literal(final CChairAgent p_chairAgent)
returns literal representation for chair agent, is null if the chair is not the chair of the group ...
void reopen()
reopen group unless capacity is reached
boolean electionInProgress()
boolean m_readyForElection
final CChairAgent m_chair
final List< CVotingAgent > m_agentList
Created by sophie on 21.02.17.
void addCoordinated(final CVotingAgent p_votingAgent)
add voting agent (for coordinated grouping)
CVotingAgent determineAgent(final String p_agentName)
determine agent for given name
CGroup(final CVotingAgent p_votingAgent, final String p_grouping)
constructor
ILiteral updateIterative(final CChairAgent p_chairAgent, final BitVector p_result, final int p_iteration)
update group literal for chair agent ( for random grouping )
void addRandom(final CVotingAgent p_votingAgent)
add voting agent (for random grouping)
ILiteral literal(final CVotingAgent p_votingAgent)
returns literal representation for voting agent
Created by sophie on 24.04.17.
void triggerAgents(final CChairAgent p_chairAgent)
trigger agents in group
BDI agent with voting capabilities.
ILiteral updateBasic(final CChairAgent p_chairAgent, final BitVector p_result)
update group literal for chair agent ( for random grouping )