def generate_criteria(number, prefix='c', random_direction=False, names=None):
    crits = Criteria()
    for i in range(number):
        cid = names[i] if names is not None else "%s%d" % (prefix, i + 1)
        c = Criterion(cid)
        if random_direction is True:
            c.direction = random.choice([-1, 1])
        crits.append(c)

    return crits
示例#2
0
文件: generate.py 项目: oso/pymcda
def generate_criteria(number, prefix = 'c', random_direction = False,
                      names = None):
    crits = Criteria()
    for i in range(number):
        cid = names[i] if names is not None else "%s%d" % (prefix, i+1)
        c = Criterion(cid)
        if random_direction is True:
            c.direction = random.choice([-1, 1])
        crits.append(c)

    return crits
示例#3
0
    def from_cmda(self, xmcda, id = None):
        xmcda = find_xmcda_tag(xmcda, 'UTA', id)

        self.id = xmcda.get('id')
        setattr(self, 'criteria', Criteria().from_xmcda(xmcda, 'criteria'))
        setattr(self, 'cvs', CriteriaValues().from_xmcda(xmcda, 'cvs'))
        setattr(self, 'cfs', CriteriaFunctions().from_xmcda(xmcda, 'cfs'))

        return self
示例#4
0
    def from_xmcda(self, xmcda, id = None):
        xmcda = find_xmcda_tag(xmcda, 'AVFSort', id)

        self.id = xmcda.get('id')
        setattr(self, 'criteria', Criteria().from_xmcda(xmcda, 'criteria'))
        setattr(self, 'cvs', CriteriaValues().from_xmcda(xmcda, 'cvs'))
        setattr(self, 'cfs', CriteriaFunctions().from_xmcda(xmcda, 'cfs'))
        setattr(self, 'cat_values', CategoriesValues().from_xmcda(xmcda, 'cat_values'))

        return self
示例#5
0
    def from_xmcda(self, xmcda, id=None):
        xmcda = find_xmcda_tag(xmcda, 'ElectreTri', id)

        self.id = xmcda.get('id')
        value = xmcda.find(".//methodParameters/parameter/value[@id='lambda']")
        self.lbda = unmarshal(value.getchildren()[0])

        setattr(self, 'criteria', Criteria().from_xmcda(xmcda, 'criteria'))
        setattr(self, 'cv', CriteriaValues().from_xmcda(xmcda, 'cv'))
        setattr(self, 'bpt', PerformanceTable().from_xmcda(xmcda, 'bpt'))
        setattr(self, 'categories_profiles',
                CategoriesProfiles().from_xmcda(xmcda, 'categories_profiles'))

        return self
def generate_criteria_msjp(number, prefix = 'c', random_direction = False,
                      names = None, random_directions = None):
    crits = Criteria()
    if random_directions is None:
        for i in range(number):
            cid = names[i] if names is not None else "%s%d" % (prefix, i+1)
            c = Criterion(cid)
            if random_direction is True:
                c.direction = random.choice([-1, 1])
            crits.append(c)
    else : # check for the size otherwise raise an error
        for i in range(number):
            cid = names[i] if names is not None else "%s%d" % (prefix, i+1)
            c = Criterion(cid)
            c.direction = random_directions[i]
            crits.append(c)

    return crits
            continue
        elif s2.issubset(s):
            gmaxs.discard(s2)

    return gmaxs

XMCDA_URL = 'http://www.decision-deck.org/2009/XMCDA-2.1.0'

if __name__ == "__main__":
    f = bz2.BZ2File(sys.argv[1])

    tree = ElementTree.parse(f)
    root = tree.getroot()

    xmcda_criteria = root.find(".//criteria")
    c = Criteria().from_xmcda(xmcda_criteria)
    print(c)
    cids = c.keys()

    f.close()

    c_pset = CriteriaSets(set(CriteriaSet(i) for i in powerset(c.keys())))

    xmcda_csets = root.findall(".//criteriaSets")

    i = 0
    xmcda2 = ElementTree.Element("{%s}XMCDA" % XMCDA_URL)
    xmcda2.append(xmcda_criteria)
    xmcda3 = ElementTree.Element("{%s}XMCDA" % XMCDA_URL)
    xmcda3.append(xmcda_criteria)
    for xmcda in xmcda_csets:
                             for c in combinations(s, i)]
    for combi in combis:
        __antichains(CriteriaSets([combi]), combi, combis, antichains)

    return antichains


XMCDA_URL = 'http://www.decision-deck.org/2009/XMCDA-2.1.0'

if __name__ == "__main__":
    if len(sys.argv) != 3:
        print("usage: %s n filename" % sys.argv[0])
        sys.exit(1)

    n = int(sys.argv[1])
    c = Criteria([Criterion("c%d" % i) for i in range(1, n + 1)])
    print(c)

    a = antichains(c.keys())

    f = bz2.BZ2File("%s" % sys.argv[2], "w")
    xmcda = ElementTree.Element("{%s}XMCDA" % XMCDA_URL)
    xmcda.append(c.to_xmcda())

    i = 1
    for anti in a:
        if anti is None:
            continue

        print(anti)
        xmcda.append(anti.to_xmcda(str(i)))
示例#9
0
文件: antichains.py 项目: oso/pymcda
    combis = [CriteriaSet(c) for i in range(1, len(s) + 1) \
                             for c in combinations(s, i)]
    for combi in combis:
        __antichains(CriteriaSets([combi]), combi, combis, antichains)

    return antichains

XMCDA_URL = 'http://www.decision-deck.org/2009/XMCDA-2.1.0'

if __name__ == "__main__":
    if len(sys.argv) != 3:
        print("usage: %s n filename" % sys.argv[0])
        sys.exit(1)

    n = int(sys.argv[1])
    c = Criteria([Criterion("c%d" % i) for i in range(1, n + 1)])
    print(c)

    a = antichains(c.keys())

    f = bz2.BZ2File("%s" % sys.argv[2], "w")
    xmcda = ElementTree.Element("{%s}XMCDA" % XMCDA_URL)
    xmcda.append(c.to_xmcda())

    i = 1
    for anti in a:
        if anti is None:
            continue

        print(anti)
        xmcda.append(anti.to_xmcda(str(i)))
示例#10
0
    dialog.resize(640, 480)
    dialog.show()

    app.exec_()


if __name__ == "__main__":
    from pymcda.types import Criterion, Criteria
    from pymcda.types import CriterionValue, CriteriaValues
    from pymcda.types import PiecewiseLinear, Segment, Point
    from pymcda.types import CriterionFunction, CriteriaFunctions

    c1 = Criterion("c1")
    c2 = Criterion("c2")
    c3 = Criterion("c3")
    c = Criteria([c1, c2, c3])

    cv1 = CriterionValue("c1", 0.5)
    cv2 = CriterionValue("c2", 0.25)
    cv3 = CriterionValue("c3", 0.25)
    cvs = CriteriaValues([cv1, cv2, cv3])

    f1 = PiecewiseLinear([
        Segment('s1', Point(0, 0), Point(2.5, 0.2)),
        Segment('s2', Point(2.5, 0.2), Point(5, 1), True, True)
    ])
    f2 = PiecewiseLinear([
        Segment('s1', Point(0, 0), Point(2.5, 0.8)),
        Segment('s2', Point(2.5, 0.8), Point(5, 1), True, True)
    ])
    f3 = PiecewiseLinear([
示例#11
0
from pymcda.types import Criterion, Criteria
from pymcda.types import CriterionValue, CriteriaValues
from pymcda.types import Alternative, Alternatives
from pymcda.types import AlternativePerformances, PerformanceTable
from pymcda.types import Threshold, Thresholds, Constant
from pymcda.types import AlternativeAssignment, AlternativesAssignments
from pymcda.types import Category, Categories
from pymcda.types import CategoryProfile, CategoriesProfiles, Limits

# Criteria
prix = Criterion('prix', 'prix', False, -1, 25)
transport = Criterion('transport', 'transport', False, -1, 45)
envir = Criterion('envir', 'environment', False, 1, 10)
residents = Criterion('residents', 'residents', False, 1, 12)
competition = Criterion('competition', 'competition', False, 1, 8)
c = Criteria([prix, transport, envir, residents, competition])

# Criteria values
cv_prix = CriterionValue('prix', 25)
cv_transport = CriterionValue('transport', 45)
cv_envir = CriterionValue('envir', 10)
cv_residents = CriterionValue('residents', 12)
cv_competition = CriterionValue('competition', 8)
cv = CriteriaValues(
    [cv_prix, cv_transport, cv_envir, cv_residents, cv_competition])

# Actions
a1 = Alternative('a1', 'a1')
a2 = Alternative('a2', 'a2')
a3 = Alternative('a3', 'a3')
a4 = Alternative('a4', 'a4')