1 | from decimal import Decimal
|
---|
2 | from typing import Collection, List, Dict
|
---|
3 | import unittest
|
---|
4 |
|
---|
5 | from tudelft.utilities.immutablelist.Range import Range
|
---|
6 |
|
---|
7 | from geniusweb.bidspace.AllBidsList import AllBidsList
|
---|
8 | from geniusweb.issuevalue.Bid import Bid
|
---|
9 | from geniusweb.issuevalue.DiscreteValue import DiscreteValue
|
---|
10 | from geniusweb.issuevalue.DiscreteValueSet import DiscreteValueSet
|
---|
11 | from geniusweb.issuevalue.Domain import Domain
|
---|
12 | from geniusweb.issuevalue.NumberValue import NumberValue
|
---|
13 | from geniusweb.issuevalue.NumberValueSet import NumberValueSet
|
---|
14 | from geniusweb.issuevalue.ValueSet import ValueSet
|
---|
15 |
|
---|
16 |
|
---|
17 | class AllBidsListTest(unittest.TestCase):
|
---|
18 | I1V2 = DiscreteValue("i1v2")
|
---|
19 | I1V1 = DiscreteValue("i1v1")
|
---|
20 | I2V1 = NumberValue(Decimal("2.00"))
|
---|
21 | I2V2 = NumberValue(Decimal("2.45"))
|
---|
22 |
|
---|
23 | I2V3 = NumberValue(Decimal("2.90"))
|
---|
24 | DOMAINNAME = "testdomain"
|
---|
25 |
|
---|
26 | ISSUE1 = "issue1"
|
---|
27 | ISSUE2 = "issue2"
|
---|
28 | issues:Dict[str, ValueSet] = {}
|
---|
29 |
|
---|
30 |
|
---|
31 | discretevalues1:List[DiscreteValue] = [I1V1, I1V2]
|
---|
32 | values1 = DiscreteValueSet(discretevalues1)
|
---|
33 |
|
---|
34 | issues[ISSUE1]= values1
|
---|
35 |
|
---|
36 | values2 = NumberValueSet(Range(Decimal("2"), Decimal("3"), Decimal("0.45")))
|
---|
37 | issues[ISSUE2]=values2
|
---|
38 |
|
---|
39 | domain = Domain(DOMAINNAME, issues)
|
---|
40 | allBidsList = AllBidsList(domain)
|
---|
41 |
|
---|
42 | print(str(allBidsList))
|
---|
43 |
|
---|
44 | def testListElements(self):
|
---|
45 | self.assertEqual(6, self.allBidsList.size())
|
---|
46 | allbids = [bid for bid in self.allBidsList]
|
---|
47 | self.assertTrue(Bid({self.ISSUE1:self.I1V1, self.ISSUE2:self.I2V1}) in allbids)
|
---|
48 | self.assertTrue(Bid({self.ISSUE1:self.I1V1, self.ISSUE2:self.I2V2}) in allbids)
|
---|
49 | self.assertTrue(Bid({self.ISSUE1:self.I1V1, self.ISSUE2:self.I2V3}) in allbids)
|
---|
50 | self.assertTrue(Bid({self.ISSUE1:self.I1V2, self.ISSUE2:self.I2V1}) in allbids)
|
---|
51 | self.assertTrue(Bid({self.ISSUE1:self.I1V2, self.ISSUE2:self.I2V1}) in allbids)
|
---|
52 | self.assertTrue(Bid({self.ISSUE1:self.I1V2, self.ISSUE2:self.I2V3}) in allbids)
|
---|
53 |
|
---|