示例#1
0
env_prog = '!park'
env_safe = set()  # empty set

# System variables and requirements
sys_vars = {'X0reach'}
sys_init = {'X0reach'}
sys_prog = {'home'}  # []<>home
sys_safe = {'(X(X0reach) <-> lot) || (X0reach && !park)'}
sys_prog |= {'X0reach'}

# Create the specification
specs = spec.GRSpec(env_vars, sys_vars, env_init, sys_init, env_safe, sys_safe,
                    env_prog, sys_prog)
specs.moore = False
specs.qinit = r'\A \E'
specs.plus_one = False

# @synthesize_section@
"""Synthesize"""
ctrl = synth.synthesize(specs,
                        sys=disc_dynamics.ts,
                        ignore_sys_init=True,
                        solver='gr1c')
# Unrealizable spec ?
if ctrl is None:
    sys.exit()

# Export Simulink Model
tomatlab.export('robot_continuous.mat', ctrl, sys_dyn, disc_dynamics,
                disc_params)
示例#2
0
sys.transitions.add_comb({'X4'}, {'X3', 'X1', 'X5'})
sys.transitions.add_comb({'X5'}, {'X4', 'X2'})

# Add atomic propositions to the states
sys.atomic_propositions.add_from({'home', 'lot'})
sys.states.add('X0', ap={'home'})
sys.states.add('X5', ap={'lot'})

# Environment variables and specification
env_vars = {'park'}
env_init = set()
env_prog = '!park'
env_safe = set()

# System specification
sys_vars = {'X0reach'}
sys_init = {'X0reach'}          
sys_prog = {'home'}
sys_safe = {'(X (X0reach) <-> lot) || (X0reach && !park)'}
sys_prog |= {'X0reach'} 

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

# Controller synthesis
ctrl = synth.synthesize('gr1c', specs, sys=sys)

# Generate a MATLAB script that generates a Mealy Machine
tomatlab.export('robot_discrete.mat', ctrl)
示例#3
0
sys.transitions.add_comb({'X4'}, {'X3', 'X1', 'X5'})
sys.transitions.add_comb({'X5'}, {'X4', 'X2'})

# Add atomic propositions to the states
sys.atomic_propositions.add_from({'home', 'lot'})
sys.states.add('X0', ap={'home'})
sys.states.add('X5', ap={'lot'})

# Environment variables and specification
env_vars = {'park'}
env_init = set()
env_prog = '!park'
env_safe = set()

# System specification
sys_vars = {'X0reach'}
sys_init = {'X0reach'}
sys_prog = {'home'}
sys_safe = {'(X (X0reach) <-> lot) || (X0reach && !park)'}
sys_prog |= {'X0reach'}

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

# Controller synthesis
ctrl = synth.synthesize(specs, sys=sys, solver='gr1c')

# Generate a MATLAB script that generates a Mealy Machine
tomatlab.export('robot_discrete.mat', ctrl)
示例#4
0
sys_disc_vars = set()

env_init = {'env_actions = normal'}

env_safe = {'no_refuel -> X(env_actions = normal)',
            '(critical & (env_actions = normal)) -> X(env_actions = refuel)',
            '(!critical & env_actions = normal) -> X(env_actions = normal)',
            '(!no_refuel & env_actions = refuel) -> X(env_actions = refuel)'}
env_prog = {'env_actions = refuel'}

# relate switching actions to u_in (env_actions)
sys_init = {'initial'}
sys_safe = {'vol_diff'}
sys_prog = {'True'}

specs = spec.GRSpec(env_vars, sys_disc_vars,
                    env_init, sys_init,
                    env_safe, sys_safe,
                    env_prog, sys_prog)
print(specs.pretty())

"""Synthesis"""
print("Starting synthesis")

ctrl = synth.synthesize(
    'gr1c', specs, sys=sys_ts.ts, ignore_sys_init=True,
)

disc_params = disc_params[('normal', 'fly')]
tomatlab.export('fuel_tank.mat', ctrl, switched_dynamics, sys_ts, disc_params)
示例#5
0
env_vars = {'park'}
env_init = set()                # empty set
env_prog = '!park'
env_safe = set()                # empty set

# System variables and requirements
sys_vars = {'X0reach'}
sys_init = {'X0reach'}
sys_prog = {'home'}               # []<>home
sys_safe = {'(X(X0reach) <-> lot) || (X0reach && !park)'}
sys_prog |= {'X0reach'}

# Create the specification
specs = spec.GRSpec(env_vars, sys_vars, env_init, sys_init,
                    env_safe, sys_safe, env_prog, sys_prog)
specs.moore = False
specs.qinit = '\A \E'
specs.plus_one = False

# @synthesize_section@
"""Synthesize"""
ctrl = synth.synthesize(
    specs, sys=disc_dynamics.ts, ignore_sys_init=True, solver='gr1c')
# Unrealizable spec ?
if ctrl is None:
    sys.exit()

# Export Simulink Model
tomatlab.export('robot_continuous.mat', ctrl, sys_dyn, disc_dynamics,
                disc_params)
示例#6
0
sys_disc_vars = set()

env_init = {'env_actions = normal'}

env_safe = {'no_refuel -> X(env_actions = normal)',
            '(critical & (env_actions = normal)) -> X(env_actions = refuel)',
            '(!critical & env_actions = normal) -> X(env_actions = normal)',
            '(!no_refuel & env_actions = refuel) -> X(env_actions = refuel)'}
env_prog = {'env_actions = refuel'}

# relate switching actions to u_in (env_actions)
sys_init = {'initial'}
sys_safe = {'vol_diff'}
sys_prog = {'True'}

specs = spec.GRSpec(env_vars, sys_disc_vars,
                    env_init, sys_init,
                    env_safe, sys_safe,
                    env_prog, sys_prog)
print(specs.pretty())

"""Synthesis"""
print("Starting synthesis")

ctrl = synth.synthesize(
    'gr1c', specs, sys=sys_ts.ts, ignore_sys_init=True,
)

disc_params = disc_params[('normal', 'fly')]
tomatlab.export('fuel_tank.mat', ctrl, switched_dynamics, sys_ts, disc_params)