1 | from typing import Dict, List
|
---|
2 |
|
---|
3 | from tudelft.utilities.immutablelist.AbstractImmutableList import AbstractImmutableList
|
---|
4 | from tudelft.utilities.immutablelist.ImmutableList import ImmutableList
|
---|
5 | from tudelft.utilities.immutablelist.Outer import Outer
|
---|
6 |
|
---|
7 | from geniusweb.issuevalue.Bid import Bid
|
---|
8 | from geniusweb.issuevalue.Domain import Domain
|
---|
9 | from geniusweb.issuevalue.Value import Value
|
---|
10 |
|
---|
11 |
|
---|
12 | class AllBidsList (AbstractImmutableList[Bid]):
|
---|
13 | '''
|
---|
14 | A list containing all complete bids in the space. This is an
|
---|
15 | {@link ImmutableList} so it can contain all bids without pre-computing them.
|
---|
16 | '''
|
---|
17 |
|
---|
18 | def __init__(self, domain:Domain):
|
---|
19 | '''
|
---|
20 | This object contains s list containing all bids in the space. This is an
|
---|
21 | ImmutableList so it can contain all bids without pre-computing them.
|
---|
22 |
|
---|
23 | @param domain the {@link Domain}
|
---|
24 | '''
|
---|
25 | if domain == None:
|
---|
26 | raise ValueError("domain=null");
|
---|
27 | self._issues = list(domain.getIssues())
|
---|
28 |
|
---|
29 | values:List[ImmutableList[Value]] = [domain.getValues(issue) for issue in self._issues]
|
---|
30 | self._allValuePermutations = Outer[Value](values)
|
---|
31 |
|
---|
32 | def get(self, index:int) -> Bid:
|
---|
33 | nextValues = self._allValuePermutations.get(index);
|
---|
34 |
|
---|
35 | issueValues:Dict[str, Value] = {}
|
---|
36 | for n in range(len(self._issues)):
|
---|
37 | issueValues[self._issues[n]] = nextValues.get(n)
|
---|
38 |
|
---|
39 | return Bid(issueValues);
|
---|
40 |
|
---|
41 | def size(self) ->int:
|
---|
42 | return self._allValuePermutations.size();
|
---|
43 |
|
---|