source: geniuswebcore/geniusweb/bidspace/pareto/ParetoLinearAdditive.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.7 KB
Line 
1from typing import List, Set, Optional
2
3from geniusweb import profile
4from geniusweb.bidspace.pareto.ParetoFrontier import ParetoFrontier
5from geniusweb.bidspace.pareto.PartialPareto import PartialPareto
6from geniusweb.issuevalue.Bid import Bid
7from geniusweb.profile.Profile import Profile
8from geniusweb.profile.utilityspace.LinearAdditive import LinearAdditive
9
10
11class ParetoLinearAdditive(ParetoFrontier):
12 '''
13 pareto frontier implementation for {@link LinearAdditive}. This is a highly
14 optimized pareto method for {@link LinearAdditive} spaces
15 '''
16
17 def __init__(self, utilSpaces:List[LinearAdditive]):
18 '''
19 @param utilSpaces. Must contain at least two {@link LinearAdditive}s and
20 all must be defined on the same donain.
21 '''
22 if utilSpaces == None or len(utilSpaces) < 2:
23 raise ValueError("utilSpaces must contain at least 2 spaces")
24
25 domain = utilSpaces[0].getDomain()
26 for space in utilSpaces:
27 if not space.getDomain() == domain:
28 raise ValueError(
29 "Expected all spaces using domain " + domain.getName()
30 +" but found " + space.getDomain().getName());
31 self._utilSpaces = utilSpaces
32 self._points:Optional[Set[Bid] ] = None
33
34 # Override
35 def getProfiles(self) -> List[Profile]:
36 return list(self._utilSpaces)
37
38 # Override
39 def getPoints(self) -> Set[Bid]:
40 if self._points == None:
41 self._points = self._computePareto()
42 return self._points # type:ignore
43
44 # Override
45 def toString(self) -> str:
46 return "Pareto " + str(self.getPoints())
47
48 def _computePareto(self) -> Set[Bid]:
49 issues:List[str] = list(self._utilSpaces[0].getDomain().getIssues())
50 partial = PartialPareto.create(self._utilSpaces, issues)
51 return set([ point.getBid() for point in partial.getPoints() ])
Note: See TracBrowser for help on using the repository browser.