Class MutablePreferenceImpl

    • Method Detail

      • given

        public static MutablePreference given​(Voter voter,
                                              MutableGraph<Alternative> pref)
        Parameters:
        pref - is a mutable graph of alternatives representing the preference. Each node of the graph contains a set, if this set contains several alternatives, it means that those alternatives are ex-aequo
        voter - is the Voter associated to the Preference.
        Returns:
        the mutable preference
        See Also:
        Voter
      • given

        public static MutablePreferenceImpl given​(Voter voter)
        Parameters:
        voter - is the Voter associated to the Preference.
        Returns:
        a MutablePreference with the same voter and an empty graph
      • given

        public static MutablePreferenceImpl given​(Preference pref)
        Factory method making new MutablePreference from an other Preference. It creates a new similar graph instance (mutable). The voter instance of the created preference is the same as the copied preference.
        Parameters:
        pref - a Preference
        Returns:
        a copy of this preference as a MutablePreference, with the same voter.
      • asGraph

        public ImmutableGraph<Alternative> asGraph()
        Description copied from interface: Preference
        In the graph : a relation from a to b means "a is at least as good as b". This graph can’t be modified, but is not necessarily immutable. Reflexive and transitive.
        Specified by:
        asGraph in interface Preference
        Returns:
        the Graph corresponding to the Preference
      • addAlternative

        public void addAlternative​(Alternative alternative)
        Description copied from interface: MutablePreference
        Adds an alternative to the Preference. This alternative is not preferred to any other of the preference, it is being added isolated.
        Specified by:
        addAlternative in interface MutablePreference
        Parameters:
        alternative - to add to the preference.
      • addEquivalence

        public void addEquivalence​(Alternative a1,
                                   Alternative a2)
        Description copied from interface: MutablePreference
        Adds an edge from an alternative a1 to an alternative a2 and from a2 to a1. If one of them is not in the graph, they are added. a1 and a2 are ex-aequo.
        Specified by:
        addEquivalence in interface MutablePreference
        Parameters:
        a1 - first alternative
        a2 - second alternative
      • setAsLeastAsGood

        public void setAsLeastAsGood​(Alternative a1,
                                     Alternative a2)
        Description copied from interface: MutablePreference
        Adds an edge from an alternative a1 to an alternative a2, so that a1 is as least as good as a2 (a1 >= a2). If one of them is not in the graph, they are added.
        Specified by:
        setAsLeastAsGood in interface MutablePreference
        Parameters:
        a1 - preferred alternative to a2
        a2 - "lower" alternative
      • getAlternatives

        public Set<Alternative> getAlternatives()
        Description copied from interface: Preference
        The returned set reads through this object: if this object is mutable, any modification to this object modifies the returned set, and conversely.
        Specified by:
        getAlternatives in interface Preference
        Returns:
        an immutable set of all alternatives of the preference
      • getVoter

        public Voter getVoter()
        Specified by:
        getVoter in interface Preference
        Returns:
        Voter instance of the preference, Returns the voter 0 if no specific voter is associated to this preference