Package tulip :: Package interfaces :: Module gr1c
[frames] | no frames]

Module gr1c

Interface to gr1c

In general, functions defined here will raise CalledProcessError (from the subprocess module) or OSError if an exception occurs while interacting with the gr1c executable.

Use the logging module to throttle verbosity.

Classes
  GR1CSession
Manage interactive session with gr1c.
Functions
GRSpec
load_aut_xml(x, namespace='http://tulip-control.sourceforge.net/ns/1')
Return GRSpec and MealyMachine constructed from output of gr1c.
 
check_syntax(spec_str)
Check whether given string has correct gr1c specification syntax.
 
check_realizable(spec, init_option='ALL_ENV_EXIST_SYS_INIT')
Decide realizability of specification.
 
synthesize(spec, init_option='ALL_ENV_EXIST_SYS_INIT')
Synthesize strategy realizing the given specification.
networkx.Digraph
load_mealy(filename)
Load gr1c strategy from xml file.
Variables
  logger = logging.getLogger(__name__)
  GR1C_BIN_PREFIX = ''
  DEFAULT_NAMESPACE = 'http://tulip-control.sourceforge.net/ns/1'
  __package__ = 'tulip.interfaces'
Function Details

load_aut_xml(x, namespace='http://tulip-control.sourceforge.net/ns/1')

 

Return GRSpec and MealyMachine constructed from output of gr1c.

Parameters:
  • x - a string or an instance of xml.etree.ElementTree._ElementInterface
  • spec0 (GRSpec) - GR(1) specification with which to interpret the output of gr1c while constructing a MealyMachine, or None if the output from gr1c should be used as is. Note that spec0 may differ from the specification in the given tulipcon XML string x. If you are unsure what to do, try setting spec0 to whatever gr1cint.synthesize was invoked with.
Returns: GRSpec

check_syntax(spec_str)

 

Check whether given string has correct gr1c specification syntax.

Return True if syntax check passed, False on error.

check_realizable(spec, init_option='ALL_ENV_EXIST_SYS_INIT')

 

Decide realizability of specification.

Consult the documentation of synthesize about parameters.

Returns:
True if realizable, False if not, or an error occurs.

synthesize(spec, init_option='ALL_ENV_EXIST_SYS_INIT')

 

Synthesize strategy realizing the given specification.

Parameters:
  • spec (GRSpec) - specification, which is incomplete without an interpretation of initial conditions (init_option).
  • init_option (str) - string declaration of the initial condition interpretation to use. This parameter corresponds to that of the -n command-line flag of gr1c. It is one of:
    • "ALL_ENV_EXIST_SYS_INIT" (default) - For each initial valuation of environment variables that satisfies spec.env_init, the strategy must provide some valuation of system variables that satisfies spec.sys_init. Only environment variables (spec.env_vars) may appear in spec.env_init, and only system variables (spec.sys_vars) may appear in spec.sys_init.
    • "ALL_INIT" - Any state that satisfies the conjunction of spec.env_init an spec.sys_init can occur initially.
    • "ONE_SIDE_INIT" - At most one of spec.env_init and spec.sys_init is nonempty, and the nonempty one can include both environment and system variables (spec.env_vars and spec.sys_vars, respectively). Both being empty is equivalent to spec.env_init=["True"]. If spec.env_init is nonempty, then any state satisfying it is possible initially. If spec.sys_init is nonempty, then the strategy need only choose one initial state satisfying it.

    Consult the documentation of gr1c for detailed descriptions.

Returns:
strategy as MealyMachine, or None if unrealizable or error occurs.

load_mealy(filename)

 

Load gr1c strategy from xml file.

Parameters:
  • filename (str) - xml file name
Returns: networkx.Digraph
loaded strategy as an annotated graph.