Exemple #1
0
def closedloop_accumul( kp, ki ):
    def setpoint( t ):
        global accumul_goal
        
        if t > 1000:
            accumul_goal += 125
        else:
            accumul_goal += 100
        return accumul_goal
    
    k = 1.0/20.0

    p = AdPublisher( 100, 2 )
    c = fb.PidController( k*kp, k*ki )

    fb.closed_loop( setpoint, c, p, returnfilter=fb.Integrator() )
def closedloop_jumps():
    def demand(t):
        if t < 3000:
            return int(random.gauss(0, 15))
        elif t < 5000:
            return int(random.gauss(0, 35))
        else:
            return int(random.gauss(100, 15))

    def setpoint(t):
        return 0.7

    p = SmoothedCache(0, demand, 100)
    c = fb.PidController(270, 7.5)  # Ziegler-Nichols - closedloop1
    #   c = fb.PidController( 100, 4.3 ) # Cohen-Coon - 2
    #   c = fb.PidController( 80, 2.0 )  # AMIGO - 3
    #   c = fb.PidController( 150, 2 )   # 4

    fb.closed_loop(setpoint, c, p, 10000)
def closedloop1():
    # Closed loop, setpoint 0.6-0.8, PID Controller

    def loadqueue():
        global global_time
        global_time += 1

        if global_time > 2100:
            return random.gauss(1200, 5)

        return random.gauss(1000, 5)

    def setpoint(t):
        if t > 2000:
            return 0.6
        else:
            return 0.8

    p = ServerPool(8, consume_queue, loadqueue)
    c = fb.PidController(1, 5)
    fb.closed_loop(setpoint, c, p, 10000)