BDI agent with voting capabilities.
More...
Inherits IBaseAgent< CVotingAgent >.
org.lightvoting.simulation.agent.CVotingAgent.CVotingAgent |
( |
final String |
p_name, |
|
|
final IAgentConfiguration< CVotingAgent > |
p_configuration, |
|
|
final IBaseAgent< CChairAgent > |
p_chairagent, |
|
|
final CEnvironment |
p_environment, |
|
|
final int |
p_altNum, |
|
|
final String |
p_grouping, |
|
|
final String |
p_fileName |
|
) |
| |
- Parameters
-
p_name | name of the agent |
p_configuration | agent configuration of the agent generator |
p_chairagent | corresponding chair agent |
p_environment | environment reference |
p_altNum | number of alternatives |
p_grouping | grouping algorithm |
p_fileName | h5 file |
Definition at line 132 of file CVotingAgent.java.
References org.lightvoting.simulation.agent.CVotingAgent.m_altNum, org.lightvoting.simulation.agent.CVotingAgent.m_atomicPrefValues, org.lightvoting.simulation.agent.CVotingAgent.m_bitVote, org.lightvoting.simulation.agent.CVotingAgent.m_chair, org.lightvoting.simulation.agent.CVotingAgent.m_environment, org.lightvoting.simulation.agent.CVotingAgent.m_fileName, org.lightvoting.simulation.agent.CVotingAgent.m_grouping, org.lightvoting.simulation.agent.CVotingAgent.m_joinThreshold, org.lightvoting.simulation.agent.CVotingAgent.m_name, org.lightvoting.simulation.agent.CVotingAgent.m_vote, and org.lightvoting.simulation.agent.CVotingAgent.m_voted.
Referenced by org.lightvoting.simulation.agent.CVotingAgent.CVotingAgentGenerator.generatesingle().
139 super( p_configuration );
143 m_chair = (CChairAgent) p_chairagent;
144 m_storage.put(
"chair", p_chairagent.raw() );
149 CRawTerm.from( p_chairagent )
154 p_chairagent.sleep( Long.MAX_VALUE );
boolean m_voted
variable indicating if agent already submitted its vote
CChairAgent m_chair
associated chair agent;
final int m_altNum
number of alternatives
AtomicIntegerArray m_vote
agent's vote
final CEnvironment m_environment
environment
final AtomicDoubleArray m_atomicPrefValues
agent's preferences
Integer m_joinThreshold
threshold for joining a group in the case of coordinated grouping
String m_grouping
grouping algorithm: "RANDOM" or "COORDINATED"
final String m_name
name of the agent
final BitVector m_bitVote
final CVotingAgent org.lightvoting.simulation.agent.CVotingAgent.call |
( |
| ) |
throws Exception |
double org.lightvoting.simulation.agent.CVotingAgent.computeDiss |
( |
final int[] |
p_resultValues | ) |
|
|
private |
- Parameters
-
- Returns
- dissatisfaction with committee
Definition at line 429 of file CVotingAgent.java.
433 for (
int i = 0; i < p_resultValues.length; i++ )
435 if ( p_resultValues[i] == 1 )
436 l_diss = l_diss + ( 1 - m_atomicPrefValues.get( i ) );
Double org.lightvoting.simulation.agent.CVotingAgent.computeDissBV |
( |
final BitVector |
p_result | ) |
|
|
private |
AtomicIntegerArray org.lightvoting.simulation.agent.CVotingAgent.convertPreferences |
( |
final AtomicDoubleArray |
p_atomicPrefValues | ) |
|
|
private |
BitVector org.lightvoting.simulation.agent.CVotingAgent.convertPreferencesToBits |
( |
final AtomicDoubleArray |
p_atomicPrefValues | ) |
|
|
private |
List<CGroup> org.lightvoting.simulation.agent.CVotingAgent.determineActiveGroups |
( |
| ) |
|
|
private |
Definition at line 321 of file CVotingAgent.java.
323 final AtomicReference<List<CGroup>> l_groupList =
new AtomicReference<>();
325 m_beliefbase.beliefbase().literal(
"groups" ).stream().forEach( i ->
326 l_groupList.set( ( (ILiteral) i ).values().findFirst().
get().raw() ) );
328 final List<CGroup> l_activeGroups =
new LinkedList<>();
330 for (
int i = 0; i < l_groupList.get().size(); i++ )
331 if ( l_groupList.get().get( i ).open() )
333 l_activeGroups.add( l_groupList.get().
get( i ) );
336 return l_activeGroups;
void org.lightvoting.simulation.agent.CVotingAgent.determineGroupCoordinated |
( |
final List< CGroup > |
p_activeGroups | ) |
|
|
private |
Definition at line 388 of file CVotingAgent.java.
References org.lightvoting.simulation.agent.CVotingAgent.m_joinThreshold.
390 final CGroup l_group;
392 final Map<CGroup, Integer> l_groupDistances =
new HashMap<>();
393 final BitVector l_vote = this.getBitVote();
394 System.out.println(
"Vote: " + l_vote );
395 for (
int i = 0; i < p_activeGroups.size(); i++ )
397 final BitVector l_com = p_activeGroups.get( i ).result();
398 System.out.println(
"Committee: " + l_com );
400 System.out.println(
"Vote: " + l_vote );
401 System.out.println(
"Committee: " + l_com );
403 final int l_HD = l_com.cardinality();
404 System.out.println(
"Hamming distance: " + l_HD );
405 l_groupDistances.put( p_activeGroups.get( i ), l_HD );
407 final Map l_sortedDistances = this.sortMapDESC( l_groupDistances );
408 final Map.Entry<CGroup, Integer> l_entry = (Map.Entry<CGroup, Integer>) l_sortedDistances.entrySet().iterator().next();
409 l_group = l_entry.getKey();
417 m_environment.addAgentCoordinated( l_group, this );
418 this.beliefbase().add( l_group.literal(
this ) );
419 System.out.println( this.name() +
" joins group " + l_group );
Integer m_joinThreshold
threshold for joining a group in the case of coordinated grouping
AtomicDoubleArray org.lightvoting.simulation.agent.CVotingAgent.generatePreferences |
( |
final int |
p_altNum | ) |
|
|
private |
BitVector org.lightvoting.simulation.agent.CVotingAgent.getBitVote |
( |
| ) |
|
CChairAgent org.lightvoting.simulation.agent.CVotingAgent.getChair |
( |
| ) |
|
AtomicIntegerArray org.lightvoting.simulation.agent.CVotingAgent.getVote |
( |
| ) |
|
void org.lightvoting.simulation.agent.CVotingAgent.joinGroup |
( |
| ) |
|
|
private |
void org.lightvoting.simulation.agent.CVotingAgent.joinGroupCoordinated |
( |
| ) |
|
|
private |
void org.lightvoting.simulation.agent.CVotingAgent.joinGroupRandom |
( |
| ) |
|
|
private |
Definition at line 353 of file CVotingAgent.java.
356 final List<CGroup> l_activeGroups = this.determineActiveGroups();
358 if ( l_activeGroups.isEmpty() )
364 final Random l_rand =
new Random();
366 final CGroup l_randomGroup = l_activeGroups.get( l_rand.nextInt( l_activeGroups.size() ) );
367 m_environment.addAgentRandom( l_randomGroup, this );
368 this.beliefbase().add( l_randomGroup.literal(
this ) );
final String org.lightvoting.simulation.agent.CVotingAgent.name |
( |
| ) |
|
void org.lightvoting.simulation.agent.CVotingAgent.openNewGroup |
( |
| ) |
|
|
private |
Definition at line 339 of file CVotingAgent.java.
References org.lightvoting.simulation.agent.CVotingAgent.m_grouping.
341 final CGroup l_group;
344 l_group = m_environment.openNewGroupRandom( this );
347 l_group = m_environment.openNewGroupCoordinated( this );
349 this.beliefbase().add( l_group.literal(
this ) );
350 System.out.println(
"opened new group " + l_group );
String m_grouping
grouping algorithm: "RANDOM" or "COORDINATED"
void org.lightvoting.simulation.agent.CVotingAgent.perceiveEnv |
( |
| ) |
|
|
private |
double org.lightvoting.simulation.agent.CVotingAgent.sigmoidValue |
( |
double |
p_var | ) |
|
|
private |
Map org.lightvoting.simulation.agent.CVotingAgent.sortMapDESC |
( |
final Map< CGroup, Integer > |
p_valuesMap | ) |
|
|
private |
Definition at line 443 of file CVotingAgent.java.
445 final List<Map.Entry<CGroup, Integer>> l_list =
new LinkedList<>( p_valuesMap.entrySet() );
449 Collections.sort( l_list, ( p_first, p_second ) ->
450 p_second.getValue().compareTo( p_first.getValue() ) );
454 final Map<CGroup, Integer> l_sortedMap =
new LinkedHashMap<>();
455 for (
final Map.Entry<CGroup, Integer> l_entry : l_list )
457 l_sortedMap.put( l_entry.getKey(), l_entry.getValue() );
void org.lightvoting.simulation.agent.CVotingAgent.submitDiss |
( |
final CChairAgent |
p_chairAgent, |
|
|
final Integer |
p_iteration, |
|
|
final BitVector |
p_result |
|
) |
| throws InterruptedException |
|
private |
Definition at line 252 of file CVotingAgent.java.
254 p_chairAgent.trigger(
256 ITrigger.EType.ADDGOAL,
259 CRawTerm.from( this.name() ),
260 CRawTerm.from( this.computeDissBV( p_result ) ),
261 CRawTerm.from( p_iteration )
void org.lightvoting.simulation.agent.CVotingAgent.submitVote |
( |
final CChairAgent |
p_chairAgent | ) |
|
|
private |
final int org.lightvoting.simulation.agent.CVotingAgent.m_altNum |
|
private |
final AtomicDoubleArray org.lightvoting.simulation.agent.CVotingAgent.m_atomicPrefValues |
|
private |
final BitVector org.lightvoting.simulation.agent.CVotingAgent.m_bitVote |
|
private |
CChairAgent org.lightvoting.simulation.agent.CVotingAgent.m_chair |
|
private |
final CEnvironment org.lightvoting.simulation.agent.CVotingAgent.m_environment |
|
private |
final String org.lightvoting.simulation.agent.CVotingAgent.m_fileName |
|
private |
String org.lightvoting.simulation.agent.CVotingAgent.m_grouping |
|
private |
Integer org.lightvoting.simulation.agent.CVotingAgent.m_joinThreshold |
|
private |
final String org.lightvoting.simulation.agent.CVotingAgent.m_name |
|
private |
AtomicIntegerArray org.lightvoting.simulation.agent.CVotingAgent.m_vote |
|
private |
boolean org.lightvoting.simulation.agent.CVotingAgent.m_voted |
|
private |