예제 #1
0
파일: run.py 프로젝트: bcoppens/pyqucs
def sensitivity(netlist, component_name, sweep_components, trials_per_value):
    # This is needed in addition to the set_component_to_random_sample, because I want to sweep over the component values, updating their nominal values
    net = copy.deepcopy(netlist)

    component = net.circuit.get_component(component_name)

    sampled_net_component = pyqucs.netlist_for_sampling(net) # Because equally_spaced needs a netlist_for_sampling, meh. TODO
    sampled_component = sampled_net_component.circuit.get_component(component_name)

    x_vals = []
    y_vals = []

    for comp_val in pyqucs.equally_spaced(sampled_component.value, 20): # This range is created before the component value is updated
        component.value.value = comp_val

        sampled_net = pyqucs.netlist_for_sampling(net)

        success = 0

        for i in range(0, trials_per_value):
            for other in sweep_components:
                pyqucs.set_component_to_random_sample(sampled_net, other)

            sim.simulate(sampled_net)

            if acceptable_circuit(sim):
                success += 1
        x_vals.append(comp_val)
        y_vals.append(float(success)/float(trials_per_value))

    return (x_vals, y_vals)
예제 #2
0
파일: run.py 프로젝트: bcoppens/pyqucs
def sample(netlist, components, nr_trials, callback=None):
    success = 0

    sampled_net = pyqucs.netlist_for_sampling(netlist)

    for trial in range(0, nr_trials):
        for comp in components:
            pyqucs.set_component_to_random_sample(sampled_net, comp)

        sim.simulate(sampled_net)

        if callback is not None:
            callback(sim)

        if acceptable_circuit(sim):
            success += 1

    #...
    return float(success) / float(nr_trials)
예제 #3
0
파일: run.py 프로젝트: bcoppens/pyqucs
def sweep(netlist):
    total   = 0
    success = 0

    sampled_net = pyqucs.netlist_for_sampling(netlist)

    for r1_range in range(0,70):
        pyqucs.set_component_to_random_sample(sampled_net, "R1")

        for r2_range in range(0,70):
            pyqucs.set_component_to_random_sample(sampled_net, "R2")

            sim.simulate(sampled_net)

            total += 1
            if acceptable_circuit(sim):
                success += 1

    return float(success) / float(total)