source: geniuswebcore/geniusweb/voting/VotingEvaluator.py@ 100

Last change on this file since 100 was 100, checked in by ruud, 19 months ago

python installs also wheel to avoid error messages

File size: 1.9 KB
Line 
1from abc import ABC, abstractmethod
2from pyson.JsonSubTypes import JsonSubTypes
3from pyson.JsonTypeInfo import Id, As
4from pyson.JsonTypeInfo import JsonTypeInfo
5from geniusweb.inform.Agreements import Agreements
6from geniusweb.voting.CollectedVotes import CollectedVotes
7
8
9@JsonSubTypes(["geniusweb.voting.votingevaluators.LargestAgreement.LargestAgreement",
10 "geniusweb.voting.votingevaluators.LargestAgreementsLoop.LargestAgreementsLoop"])
11@JsonTypeInfo(use=Id.NAME, include=As.WRAPPER_OBJECT)
12class VotingEvaluator(ABC) :
13 '''
14 Evaluates the {@link CollectedVotes}, determining the agreements and if the
15 negotiation should continue.
16
17 Implementations should be immutable and not serialize internal variables (eg
18 @JsonIgnore them).
19 '''
20 @abstractmethod
21 def create(self, votes:CollectedVotes)->"VotingEvaluator" :
22 '''
23 This function is the effective constructor. This mechanism serves several
24 purposes:
25 <ul>
26 <li>It defines the constructor at interface level, so that we can ensure
27 it's available and can call it given an instance,
28 <li>We can use a (typically blank) instance of this to make more
29 instances
30 <li>You can cache intermediate results in the object for caching
31 </ul>
32
33 @param votes the Votes made by parties in the round to be evaluated.. All
34 active parties in the negotiation must be available, even if
35 they did not vote, to ensure that {@link #isFinished()} can
36 work properly.
37
38 @return new VotingEvaluation object containing the given votes.
39 '''
40
41 @abstractmethod
42 def getAgreements(self)-> Agreements:
43 '''
44 @return the agreements that is contained in the current available votes.
45 The exact procedure varies with the implementation.
46 '''
47
48 def isFinished(self )->bool:
49 '''
50 @return true iff the negotiation is finished after taking the agreement
51 returned by {@link #getAgreements()}
52 '''
53
Note: See TracBrowser for help on using the repository browser.