Ejemplo n.º 1
0
                            index_1 - 1] + ' && '
                    if index_2 == 0:
                        new_sys_collision_2 += 'init' + str(other_r) + ' )'
                    else:
                        new_sys_collision_2 += env_vars_list[other_r -
                                                             1][index_2 -
                                                                1] + ' )'
                    new_sys_collision_2 += ' -> (!go' + str(
                        r) + ' || ' + '!go' + str(other_r) + ' )'
                    sys_collision_2 |= {new_sys_collision_2}
# sys_safe |= sys_collision_2
sys_col_simple = {'!(s1a2a1 && s2a2a1)'}
sys_safe |= sys_col_simple

# Create a GR(1) specification
specs = spec.GRSpec(env_vars, sys_vars, env_init, sys_init, env_safe, sys_safe,
                    env_prog, sys_prog)
specs.qinit = '\A \E'  # Moore initial condition synthesized too
specs.moore = False
specs.plus_one = False

print('Start synthesis')
ctrl = synth.synthesize(specs)
print('End synthesis')
assert ctrl is not None, 'unrealizable'

# Generate a graphical representation of the controller for viewing
if not ctrl.save('gr1_set_1111.png'):
    print(ctrl)
machines.random_run(ctrl, N=30)
Ejemplo n.º 2
0
# Create a GR(1) specification
specs = spec.GRSpec(env_vars, sys_vars, env_init, sys_init, env_safe, sys_safe,
                    env_prog, sys_prog)

#
# Controller synthesis
#
# The controller decides based on current variable values only,
# without knowing yet the next values that environment variables take.
# A controller with this information flow is known as Moore.
specs.moore = True
# Ask the synthesizer to find initial values for system variables
# that, for each initial values that environment variables can
# take and satisfy `env_init`, the initial state satisfies
# `env_init /\ sys_init`.
specs.qinit = '\E \A'  # i.e., "there exist sys_vars: forall sys_vars"

# At this point we can synthesize the controller
# using one of the available methods.
strategy = synth.synthesize(specs)
assert strategy is not None, 'unrealizable'

# Generate a graphical representation of the controller for viewing,
# or a textual representation if pydot is missing.
if not strategy.save('gr1.png'):
    print(strategy)

# simulate
print(strategy)
machines.random_run(strategy, N=10)
Ejemplo n.º 3
0
# Create a GR(1) specification
specs = spec.GRSpec(env_vars, sys_vars, env_init, sys_init,
                    env_safe, sys_safe, env_prog, sys_prog)

#
# Controller synthesis
#
# The controller decides based on current variable values only,
# without knowing yet the next values that environment variables take.
# A controller with this information flow is known as Moore.
specs.moore = True
# Ask the synthesizer to find initial values for system variables
# that, for each initial values that environment variables can
# take and satisfy `env_init`, the initial state satisfies
# `env_init /\ sys_init`.
specs.qinit = '\E \A'  # i.e., "there exist sys_vars: forall sys_vars"

# At this point we can synthesize the controller
# using one of the available methods.
strategy = synth.synthesize(specs)
assert strategy is not None, 'unrealizable'

# Generate a graphical representation of the controller for viewing,
# or a textual representation if pydot is missing.
if not strategy.save('gr1.png'):
    print(strategy)

# simulate
print(strategy)
machines.random_run(strategy, N=10)
Ejemplo n.º 4
0
#     [](X (X0reach) <-> X0 || (X0reach && !park))
#

# Augment the system description to make it GR(1)
sys_vars |= {'X0reach'}
sys_init |= {'X0reach'}
sys_safe |= {'(X (X0reach) <-> X0) || (X0reach && !park)'}
sys_prog |= {'X0reach', 'X5'}

# Create a GR(1) specification
specs = spec.GRSpec(env_vars, sys_vars, env_init, sys_init,
                    env_safe, sys_safe, env_prog, sys_prog)

#
# Controller synthesis
#
# At this point we can synthesize the controller
# using one of the available methods.
# Here we make use of gr1c.
#
mealy_controller = synth.synthesize('gr1c', specs)

# Generate a graphical representation of the controller for viewing,
# or a textual representation if pydot is missing.
if not mealy_controller.save('gr1.png'):
    print(mealy_controller)

# simulate
print(mealy_controller)
machines.random_run(mealy_controller, N=10)
Ejemplo n.º 5
0
#     [](X (X0reach) <-> X0 || (X0reach && !park))
#

# Augment the system description to make it GR(1)
sys_vars |= {'X0reach'}
sys_init |= {'X0reach'}
sys_safe |= {'(X (X0reach) <-> X0) || (X0reach && !park)'}
sys_prog |= {'X0reach', 'X5'}

# Create a GR(1) specification
specs = spec.GRSpec(env_vars, sys_vars, env_init, sys_init, env_safe, sys_safe,
                    env_prog, sys_prog)

#
# Controller synthesis
#
# At this point we can synthesize the controller
# using one of the available methods.
# Here we make use of gr1c.
#
mealy_controller = synth.synthesize('gr1c', specs)

# Generate a graphical representation of the controller for viewing,
# or a textual representation if pydot is missing.
if not mealy_controller.save('gr1.png'):
    print(mealy_controller)

# simulate
print(mealy_controller)
machines.random_run(mealy_controller, N=10)
# Constraint 1: []<>([[0, 0], [0, 1], [0, 2]], 2)
# Constraint 2: []!([1, 1], 1)
# Constraint 3: ([]<>[1, 2], 2)

#sys_prog |= {'(x1=0)'}
#sys_safe |= {'!(x1=1 && y1=1)'}
sys_prog |= {'(x1=0) && (x2=0)'}
#sys_prog |= {'x1=1 && y1=0'}
#sys_prog |= {'x2=1 && y2=0'}
#sys_prog |= {'(x1=1) && (x2=1)'}
sys_safe |= {'!(x1=1 && y1=1) && !(x2=1 && y2=1)'}
sys_prog |= {'x1=1 && y1=2'}
sys_prog |= {'x2=1 && y2=2'}

# Create a GR(1) specification
specs = spec.GRSpec(env_vars, sys_vars, env_init, sys_init, env_safe, sys_safe,
                    env_prog, sys_prog)
specs.qinit = '\E \A'  # Moore initial condition synthesized too
specs.moore = False
specs.plus_one = False
print(specs)

specs.check_syntax()

print('Start synthesis')
ctrl = synth.synthesize(specs)
print('End synthesis')
assert ctrl is not None, 'unrealizable'

machines.random_run(ctrl, N=100)