Example #1
0
    solver.Solve(CF, termination = ChangeOverGeneration(generations=300), \
                 CrossProbability=0.5, ScalingFactor=0.5, \
                 sigint_callback = plot_sol)

    solution = solver.Solution()

    return solution, stepmon


if __name__ == '__main__':

    F = CostFactory()
    F.addModel(ForwardMogiFactory,
               'mogi1',
               4,
               outputFilter=PickComponent(2, -1))
    F.addModel(ForwardMogiFactory,
               'mogi2',
               4,
               outputFilter=PickComponent(2, -1))
    myCostFunction = F.getCostFunction(evalpts=stations, observations=data_z)
    print F

    def C2(x):
        "This is the new version"
        return 100000 * myCostFunction(x)

    def C3(x):
        "Cost function constructed by hand"
        from test_mogi2 import cost_function
        return cost_function(x)
Example #2
0
    solver.SetRandomInitialPoints(min = minrange, max = maxrange)
    solver.SetEvaluationLimits(generations=MAX_GENERATIONS)
    solver.SetGenerationMonitor(stepmon)

    solver.Solve(CF, termination = ChangeOverGeneration(generations=300), \
                 CrossProbability=0.5, ScalingFactor=0.5, \
                 sigint_callback = plot_sol)

    solution = solver.Solution()
  
    return solution, stepmon

if __name__ == '__main__':

    F = CostFactory()
    F.addModel(ForwardMogiFactory, 4, 'mogi1', outputFilter = PickComponent(2, -1))
    F.addModel(ForwardMogiFactory, 4, 'mogi2', outputFilter = PickComponent(2, -1))
    myCostFunction = F.getCostFunction(evalpts = stations, observations = data_z)
    print F

    def C2(x):
        "This is the new version"
        return 100000 * myCostFunction(x)

    def C3(x):
        "Cost function constructed by hand"
        from test_mogi2 import cost_function
        return cost_function(x)

    def test():
        "call me to see if the functions return the same thing"
Example #3
0
    maxrange = [1000., 1000., 100., 10.]
    solver.SetRandomInitialPoints(min=minrange, max=maxrange)
    solver.SetEvaluationLimits(generations=MAX_GENERATIONS)
    solver.SetGenerationMonitor(stepmon)

    solver.Solve(CF, termination = ChangeOverGeneration(generations=100), \
                 CrossProbability=0.5, ScalingFactor=0.5)

    solution = solver.Solution()

    return solution, stepmon


if __name__ == '__main__':
    F = CostFactory()
    F.addModel(ForwardMogiFactory, 'mogi1', 4, outputFilter=PickComponent(2))
    myCostFunction = F.getCostFunction(evalpts=stations, observations=data_z)
    print F
    rp = F.getRandomParams()
    print "new Cost Function : %s " % myCostFunction(rp)
    print "orig Cost Function: %s " % cost_function(rp)

    f1 = ForwardMogiFactory(rp)
    f2 = ForwardMogiFactory(rp)

    print 'start cf'
    for i in range(3000):
        xx = cost_function(rp)
    print 'end cf'

    print 'start cf2'