Exemple #1
0
    def getModel(self, userID:int, argsDict:dict):

        status:float = argsDict[ASequentialSimulation.ARG_STATUS]
        print("status: " + str(status))

        mGlobal:DataFrame = self.getModelGlobal()

        if self.modeSkip:
            print("aaaaaaaaaaaaaaaaa")
            numberOfClick:int = self.getModelPersonAllUsers().getNumberOfClick(userID)
            print("numberOfClick: " + str(numberOfClick))
            if numberOfClick < self.skipClickThreshold:
                return mGlobal

        mGlobal.linearNormalizing()
        #print("GLOBAL:")
        #print(mGlobal.head(10))
        mGlobal = PModelDHondt.multiplyModel(mGlobal, 1.0 - status)

        mPerson:DataFrame = self.getModelPerson(userID)
        mPerson.linearNormalizing()
        mPerson = PModelDHondt.multiplyModel(mPerson, status)

        rPModel:DataFrame = PModelDHondt.sumModels(mGlobal, mPerson)
        rPModel.linearNormalizing()

        #print("VYSLEDNY:")
        #print(rPModel.head(10))

        return rPModel
def test02():
    print("Test 02")

    # methods parametes
    portfolioModelData1: List[tuple] = [['metoda1', 100], ['metoda2', 80],
                                        ['metoda3', 60]]
    portfolioModel1: DataFrame = pd.DataFrame(portfolioModelData1,
                                              columns=["methodID", "votes"])
    portfolioModel1.set_index("methodID", inplace=True)
    portfolioModel1.__class__ = PModelDHondt

    #portfolioModel1.linearNormalizing()

    portfolioModelData2: List[tuple] = [['metoda2', 20], ['metoda3', 40],
                                        ['metoda1', 0]]
    portfolioModel2: DataFrame = pd.DataFrame(portfolioModelData2,
                                              columns=["methodID", "votes"])
    portfolioModel2.set_index("methodID", inplace=True)
    portfolioModel2.__class__ = PModelDHondt

    #print(portfolioModel1.head())
    #print(portfolioModel2.head())

    rModel = PModelDHondt.sumModels(portfolioModel1, portfolioModel2)
    print(rModel)
    print()

    PModelDHondt.linearNormalizingPortfolioModelDHondt(rModel)
    print(rModel)