Exemple #1
0
do in each run and it is possible that
this automatic run will fail due to this
lack of tuning. The system will provide
more information on errors if they occur.
"""


if __name__ == "__main__":

    market = Faker()
    market.genData(150, 10, 6, 500)
    a = np.random.rand(market.X2.shape[1])
    bounds = [(-3, 3) for x in a]

    # Test serial unique convergence
    blp = BLP(market.X1, market.X2, market.Z, market.M, market.S)
    blp.prepareSample()
    population = blp.population.copy()
    population_size = blp.population_size  # Keep these for easier comparison
    print("Starting picard serial...")
    start1 = time()
    res1 = blp.solve(a, method="Nelder-Mead", delta_method="picard")
    end1 = time()
    blp = None

    # Test serial multiple convergence
    blp2 = BLP(market.X1, market.X2, market.Z, market.M, market.S, par_cut=2)
    blp2.population = population
    blp2.status = 1
    blp2.population_size = population_size
    print("Starting picard split...")
Note:
----
Don't expect the test to work every
time. There is a lot fine-tuning to
do in each run and it is possible that
this automatic run will fail due to this
lack of tuning. The system will provide
more information on errors if they occur.
"""

if __name__ == "__main__":

    market = Faker()
    market.genData(150, 10, 6, 500)
    blp = BLP(market.X1, market.X2, market.Z, market.M, market.S)
    blp.prepareSample()
    a = np.random.rand(market.X2.shape[1])
    bounds = [(-3, 3) for x in a]

    # Keep initial delta vector
    initial_delta = blp.initial_delta.copy()

    # Test non-accelerated convergence
    print("Starting non-accelerated...")
    blp.delta_method = 0
    start4 = time()
    res4 = blp.solve(a, method="Nelder-Mead", delta_method="picard")
    end4 = time()

    # Test non-accelerated convergence