Exemplo n.º 1
0
void BaseSolver::set_model(Model const& new_model) {
    is_solved = false;
    model = new_model;

    if (strategy) {// try to assign a new Hamiltonian to the existing Solver strategy
        bool success = strategy->change_hamiltonian(model.hamiltonian());
        if (!success) { // fails if the they have incompatible scalar types
            strategy.reset();
        }
    }

    if (!strategy) { // creates a SolverStrategy with a scalar type suited to the Hamiltonian
        strategy = make_strategy(model.hamiltonian());
    }
}
Exemplo n.º 2
0
    assert(high - low > 0.0001);
    return low + (random() * (high - low) / ((double) RAND_MAX));
}

static void run_reset_test(CTEST_DATA(reset_test) *data,
                           enum EvalMethod method)
{
    instruments_strategy_t strategies[3];
    int i;

    // use enough estimators to look like intnw
    struct test_data tdata[2] = {
        { &data->dummy[0], 2, data->mid_estimator },
        { &data->dummy[2], 1, data->hilo_estimator },
    };
    strategies[0] = make_strategy(estimator_value, NULL, high_cost, (void*) &tdata[0], NULL);
    ASSERT_NOT_NULL(strategies[0]);
    set_strategy_name(strategies[0], "mid");
    strategies[1] = make_strategy(estimator_value, NULL, high_cost, (void*) &tdata[1], NULL);
    ASSERT_NOT_NULL(strategies[1]);
    set_strategy_name(strategies[1], "hilo");
    strategies[2] = make_redundant_strategy(strategies, 2, NULL);
    ASSERT_NOT_NULL(strategies[2]);
    set_strategy_name(strategies[2], "both");

    set_estimator_range_hints(data->mid_estimator, 0.5, 20.5, 20);
    set_estimator_range_hints(data->hilo_estimator, 0.5, 20.5, 20);
    for (i = 0; i < 3; ++i) {
        set_estimator_range_hints(data->dummy[i], 0.5, 20.5, 20);
    }