public Candidate(ServerIdentifier serverIdentifier, IElectionTimer electionTimer, IObserver<RequestVoteMessage> requestVote, IObservable<RequestVoteResultMessage> voteReply, IVotingSystem votingSystem, IElection election, ILogReplication logReplication, Nodes nodes, ILoggerFactory loggerFactory, RaftOptions options) { isDispose = false; _electionTimer = electionTimer; _requestVote = requestVote; _voteReply = voteReply; _votingSystem = votingSystem; _serverIdentifier = serverIdentifier; _election = election; _options = options; _logger = loggerFactory.CreateLogger(nameof(Candidate) + " " + serverIdentifier); _election.CurrentTerm++; _election.VotedFor = _serverIdentifier.Id; _logReplication = logReplication; _nodes = nodes; if (_options.UseLogging) _logger.LogInformation($"{nameof(ServerStateType.Candidate)}"); RequestElection(); }
public ModelNearestNeighborList( IDataContext data_contex, IFunctionDistance <DomainType[], DistanceType> distance_function, IVotingSystem <Tuple <DomainType[], DistanceType, LabelType> > voting_system, int neighbor_count) : this(data_contex, new List <Tuple <DomainType [], LabelType> >(), distance_function, voting_system, neighbor_count) { }
public ModelNearestNeighborKDTree( IDataContext data_contex, IAlgebraReal <DomainType> algebra, IFunctionDistance <DomainType[], DistanceType> distance_function, IVotingSystem <Tuple <DomainType[], DistanceType, LabelType> > voting_system, int neighbor_count) : this(data_contex, new KDTree <DomainType, DistanceType, LabelType>(algebra, data_contex.FeatureCount), distance_function, voting_system, neighbor_count) { }
public ModelNearestNeighborKDTree( IDataContext data_contex, KDTree <DomainType, DistanceType, LabelType> kdtree, IFunctionDistance <DomainType[], DistanceType> distance_function, IVotingSystem <Tuple <DomainType[], DistanceType, LabelType> > voting_system, int neighbor_count) : this("ModelNearestNeighborKDTree", data_contex, kdtree, distance_function, voting_system, neighbor_count) { this.kdtree = kdtree; this.DistanceFunction = distance_function; this.voting_system = voting_system; this.neighbor_count = neighbor_count; }
public ModelNearestNeighborList( IDataContext data_contex, IList <Tuple <DomainType[], LabelType> > list, IFunctionDistance <DomainType[], DistanceType> distance_function, IVotingSystem <Tuple <DomainType[], DistanceType, LabelType> > voting_system, int neighbor_count) : base(data_contex, "ModelNearestNeighborList") { this.list = list; this.distance_function = distance_function; this.voting_system = voting_system; this.neighbor_count = neighbor_count; }
/// <summary> /// Returns the winner. /// </summary> /// <param name="candidates">The candidates.</param> /// <param name="votes">The population's votes. Each individual's votes is ranked with the highest rank as the first element.</param> /// <returns>The winner.</returns> public static async Task <Result> GetWinnerAsync(this IVotingSystem votingSystem, ISet <Candidate> candidates, IEnumerable <IEnumerable <Candidate> > votes) => (await votingSystem.GetRankedResultsAsync(candidates, votes)).FirstOrDefault();