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
Beispiel #2
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...")
Beispiel #3
0
        self.X1 = np.hstack((P.reshape(-1, 1), X[:, (nonlinear_chars):]))
        self.X2 = np.hstack((P.reshape(-1, 1), X[:, :nonlinear_chars]))
        self.Z = Z
        self.M = M
        self.S = S
        self.alpha = alpha
        self.beta = beta
        self.sigma = sigma
        self.demand_shock = demand_shock
        return


if __name__ == "__main__":
    market = Faker()
    market.genData(50, 15, 6, 500)
    blp = BLP(market.X1, market.X2, market.Z, market.M, market.S)
    blp.prepareSample()
    a = np.random.rand(market.X2.shape[1])
    ls = np.bincount(market.M, weights=market.S)
    s = ls[market.M]

    res = blp.solve(a, method="Nelder-Mead")

    print("The resulting message is : %s" % res.message)
    print("The flag is: %s" % res.success)
    print("Found theta1 is %s " % res.theta1)
    print("Real theta1 was %s %s" % (market.alpha, market.beta))
    print("Found theta2 is %s" % (res.theta2))
    print("Real theta2 was %s" % market.sigma)
    print("Starting theta2 was %s" % a)