source: geniuswebcore/geniusweb/bidspace/AllBidsList.py@ 99

Last change on this file since 99 was 96, checked in by Bart Vastenhouw, 2 years ago

Fixed small issues in domaineditor.

File size: 1.5 KB
Line 
1from typing import Dict, List
2
3from tudelft.utilities.immutablelist.AbstractImmutableList import AbstractImmutableList
4from tudelft.utilities.immutablelist.ImmutableList import ImmutableList
5from tudelft.utilities.immutablelist.Outer import Outer
6
7from geniusweb.issuevalue.Bid import Bid
8from geniusweb.issuevalue.Domain import Domain
9from geniusweb.issuevalue.Value import Value
10
11
12class 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
Note: See TracBrowser for help on using the repository browser.