Ejemplo n.º 1
0
def optimise():
    testCases = testcollection.readTests()
    #grouping.redefineGroupingConditions(dataselect.conditionBreakHigh)
    #grouping.redefineGroupingConditions(dataselect.conditionDoubleTopsFiltered)

    ### Objective Function.
    ### An input for pyswarm.pso. Returns a float utility score from testing with a set of weights.
    def testWithWeights(weights):
        arrLen = len(parametersToOptimise)
        weightDict = {}
        for i in range(0,arrLen):
            weightDict[parametersToOptimise[i]] = weights[i]
        result = testAlgorithmsForAverageScore(testCases, weightDict)
        print(str(result) + ' <- ' + str(weights)) # print as we go.
        return (result - 1)*100
   
    ### Uncomment this to test the running time of weight optimisation.
    # testWeightOptimisationRunningTime(testWithWeights)

    ub = [1]*5 # Upper bound = 1
    lb = [0]*5 # Lower bound = 0
    xopt, fopt = pyswarm.pso(testWithWeights, lb, ub, maxiter=20)
    
    # If we reach this point, it means the weight optimisation process is complete.
    print('Final Weights:')
    print(xopt)
    print('Score = ' + str(fopt))
Ejemplo n.º 2
0
def runTests():
    #grouping.redefineGroupingConditions(dataselect.conditionBreakHigh, dataselect.conditionDoubleTops, dataselect.conditionDoubleTopsFiltered)
    #grouping.redefineGroupingConditions(dataselect.conditionBreakHigh)
    #grouping.redefineGroupingConditions(dataselect.conditionDoubleTopsFiltered)
    #grouping.changeToShiftedMonthsGroups()

    testCases = testcollection.readTests()
    testalgos.compareAlgorithmsWithData(testCases)