Beispiel #1
0
class InputSimpleShow:
    # linPrefModelConf:LinPrefModelConfiguration
    linPrefModelConf = LinPrefModelConfiguration(1.0, 1.0, 1.0, 1.0)

    # userProfileModelStructured:UserProfileModelStructured
    userProfileModelStructured = UserProfileModelStructured(
        PrefFncRefractedModel(0.5), PrefFncRefractedModel(0.5),
        AggrFnc([0.5, 0.5]))

    # aggrLevel:Float
    aggrLevel = 0.8

    # pointsVisitedDC:list<PointWithID>
    pointsWithIDVisitedDC = [
        PointWithID(Point(0.70, 0.75), "A"),
        PointWithID(Point(0.15, 0.45), "B"),
        PointWithID(Point(0.60, 0.15), "C"),
        PointWithID(Point(0.40, 0.85), "D"),
        PointWithID(Point(0.5, 0.5), "E")
    ]

    # pointsNoVisitedDC:list<PointWithID>
    pointsWithIDNoVisitedDC = [
        PointWithID(Point(0.25, 0.15), "M"),
        PointWithID(Point(0.1, 0.65), "N"),
        PointWithID(Point(0.35, 0.85), "O"),
        PointWithID(Point(0.9, 0.7), "P"),
        PointWithID(Point(0.65, 0.45), "Q")
    ]

    def generatePointsWithIDVisitedDC(count):
        points = []
        for i in range(count):
            x = random.uniform(0, 1)
            y = random.uniform(0, 1)
            pI = PointWithID(Point(x, y), i)
            points.append(pI)
        return points

    def generatePointsWithIDNoVisitedDC(count):
        points = []
        for i in range(count):
            x = random.uniform(0, 1)
            y = random.uniform(0, 1)
            pI = PointWithID(Point(x, y), 100 + i)
            points.append(pI)
        return points
Beispiel #2
0
 def generatePointsWithIDNoVisitedDC(count):
     points = []
     for i in range(count):
         x = random.uniform(0, 1)
         y = random.uniform(0, 1)
         pI = PointWithID(Point(x, y), 100 + i)
         points.append(pI)
     return points
Beispiel #3
0
def paintPreferenceCube(linPrefModelConf, title, pointsWithIDs, aggrFnc,
                        numberOfThresholds):

    # thresholds:(Threshold[], Threshold[])
    candidatesForThresholds, thresholds, itemsFound = countThreshold(
        linPrefModelConf, pointsWithIDs, aggrFnc, numberOfThresholds)

    # pointnsOnX:PointWithID[]
    pointnsOnX = [
        PointWithID(Point(pointWithID.point.x, 0), pointWithID.pointID)
        for pointWithID in pointsWithIDs
    ]

    # pointnsOnY:PointWithID[]
    pointnsOnY = [
        PointWithID(Point(0, pointWithID.point.y), pointWithID.pointID)
        for pointWithID in pointsWithIDs
    ]

    pointFound = [
        pointsWithIDI for pointsWithIDI in pointsWithIDs
        if pointsWithIDI.pointID in itemsFound
    ]

    # painting:PaintingPreferenceCubeModel
    painting = PaintingPreferenceCubeModel(linPrefModelConf, title)
    #painting.paintPreferenceCube(pointsWithIDs)
    painting.paintPreferenceCube(pointFound)
    painting.paintPreferenceCube(pointnsOnX)
    painting.paintPreferenceCube(pointnsOnY)
    painting.paintThreshold(linPrefModelConf,
                            candidatesForThresholds,
                            color="y",
                            linewidth=0.5)
    painting.paintThreshold(linPrefModelConf,
                            thresholds,
                            color="r",
                            linewidth=1.0)

    return painting.graphicalModel.figure
Beispiel #4
0
class InputTwoUsers:
    #linPrefModelConf:LinPrefModelConfiguration
    linPrefModelConf = LinPrefModelConfiguration(2.0, 1.25, 1.0, 1.0)

    #user2D1:User2D
    user2D1 = User2D(1, 1.5, 0.3, 0.66)
    #user2D2:User2D
    user2D2 = User2D(2, 0.5, 0.9, 0.33)

    # aggrLevel1:Float
    aggrLevel1 = 0.667
    # aggrLevel2:Float
    aggrLevel2 = 0.667

    #pointsWithIdVisitedDC:Point[]
    #pointsDataCube = [Point(0.73, 0.755), Point(1.125, 0.45), Point(1.624, 0.15)]
    pointsWithIdVisitedDC = [
        PointWithID(Point(0.5, 0.5), "A"),
        PointWithID(Point(0.75, 0.5), "B"),
        PointWithID(Point(0.5, 0.75), "C"),
        PointWithID(Point(0.75, 0.75), "D")
    ]
Beispiel #5
0
class InputThreshold:
    #linPrefModelConf:LinPrefModelConfiguration
    linPrefModelConf = LinPrefModelConfiguration(2.0, 1.25, 1.0, 1.0)

    #title:String
    title = "Preferenc Cube"

    #points:Point[]
    points = [
        Point(0.1, 0.1),
        Point(0.2, 0.2),
        Point(0.3, 0.4),
        Point(0.9, 0.5)
    ]

    # pointsWithIDs:PointWithID[]
    pointsWithIDs = [
        PointWithID(Point(0.1, 0.9), 'A'),
        PointWithID(Point(0.2, 0.8), 'B'),
        PointWithID(Point(0.3, 0.7), 'C'),
        PointWithID(Point(0.4, 0.6), 'D'),
        PointWithID(Point(0.5, 0.5), 'E')
    ]
Beispiel #6
0
    def pointsWithIdDCToPointsWithIdPC(self, pointsWithIdDC):
        if type(pointsWithIdDC) is not list:
            raise ValueError("Argument pointsDataCube isn't type list.")
        for pI in pointsWithIdDC:
            if type(pI) is not PointWithID:
                raise ValueError(
                    "Argument pointsDataCube don't contain PointWithID.")
        # labels:list<str>
        labels = [pointWithIdI.pointID for pointWithIdI in pointsWithIdDC]
        # pointsDC:list<Point>
        pointsDC = [pointWithIdI.point for pointWithIdI in pointsWithIdDC]

        # pointsPC:list<Point>
        pointsPC = self.pointsDataCubeToPointsPrefCube(pointsDC)
        # list<PointWithID>
        return [
            PointWithID(pointsPC[i], labels[i]) for i in range(len(pointsPC))
        ]
Beispiel #7
0
    def __showModelBasedOnForm(self, cModel):

        #upModel:UserProfileModel
        self.upModel = self.userProfileModelStructured.exportAsUserProfileModel(
            self.linPrefModelConf)

        # pointsVisitedPC:List<PointWithID>
        self.pointsWithIDVisitedPC = self.upModel.pointsWithIdDCToPointsWithIdPC(
            self.pointsWithIdVisitedDC)
        # preferences:list<float>
        self.preferences = self.upModel.aggrFnc.preferenceOfPointsWitIDInPC(
            self.pointsWithIDVisitedPC, self.linPrefModelConf)

        # aggrLine:LineSegment
        aggrLine = self.upModel.aggrFnc.exportAsLineSegment(
            Point(self.aggrLevel, self.aggrLevel), self.linPrefModelConf)
        # contorLines:LineSegment[]
        contorLines = self.upModel.getMorphismOfAggregationFncToDataCubeLines(
            self.aggrLevel, self.linPrefModelConf)

        # pointsWithIdVisitedPXC:List<PointWithID>
        pointsWithIdVisitedPXC = [
            PointWithID(
                Point(self.pointsWithIdVisitedDC[i].point.x,
                      self.pointsWithIDVisitedPC[i].point.y),
                self.pointsWithIdVisitedDC[i].pointID)
            for i in range(len(self.pointsWithIdVisitedDC))
        ]
        # pointsWithIdVisitedPYC:List<PointWithID>
        pointsWithIdVisitedPYC = [
            PointWithID(
                Point(self.pointsWithIDVisitedPC[i].point.x,
                      self.pointsWithIdVisitedDC[i].point.y),
                self.pointsWithIDVisitedPC[i].pointID)
            for i in range(len(self.pointsWithIdVisitedDC))
        ]

        # selectedPointWithIdDC:PointWithId
        selectedPointWithIdDC = None if self.selectedPointIdDC is None else PointsWithID(
            self.pointsWithIdVisitedDC).exportPoint(self.selectedPointIdDC)

        cModel.addPrefFncX(self.upModel.prefFncX, self.colorU1)
        cModel.addPrefFncY(self.upModel.prefFncY, self.colorU1)
        cModel.addAggregationFnc(aggrLine, self.colorU1)
        cModel.addContorLines(contorLines, self.colorU1)
        cModel.addDataCubePoints(self.pointsWithIdVisitedDC,
                                 self.pointLabelsDC, self.colorU1)
        cModel.addDataCubePoints(self.pointsWithIdNoVisitedDC,
                                 self.pointLabelsDC, Qt.yellow)
        cModel.addDataCubePoint(selectedPointWithIdDC, self.pointLabelsDC,
                                Qt.red)

        cModel.addPrefFncXCubePoints(
            [p for p in pointsWithIdVisitedPXC if self.pointsPrefFncX],
            self.colorU1)
        cModel.addPrefFncYCubePoints(
            [p for p in pointsWithIdVisitedPYC if self.pointsPrefFncY],
            self.colorU1)

        cModel.addPrefCubePoints(self.pointsWithIDVisitedPC,
                                 self.pointLabelsPC, self.colorU1)
        cModel.auxiliaryLinesDataCube = self.auxiliaryLinesDataCube
        cModel.auxiliaryLinesPrefCube = self.auxiliaryLinesPrefCube
        cModel.auxiliaryLinesPrefFncXCube = self.auxiliaryLinesPrefFncXCube
        cModel.auxiliaryLinesPrefFncYCube = self.auxiliaryLinesPrefFncYCube
        cModel.diagonalDC = self.diagonalPC
        cModel.contourLineDC = self.contourLineDC
        cModel.pointIDSelected = self.selectedPointIdDC
Beispiel #8
0
 def exportPointWithID(self, dimensionX, dimensionY):
     point = self.point.exportAsPoint(dimensionX, dimensionY)
     return PointWithID(point, self.pointID)