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
 
check_gr1c()
Return `True` if `gr1c >= require_version` found in PATH.
 
get_version()
Get version of gr1c as detected by TuLiP.
 
load_aut_xml(x, namespace='http://tulip-control.sourceforge.net/ns/1')
Return strategy constructed from output of gr1c.
 
load_aut_json(x)
Return strategy constructed from output of gr1c
 
check_syntax(spec_str)
Check whether given string has correct gr1c specification syntax.
 
check_realizable(spec)
Decide realizability of specification.
 
synthesize(spec)
Synthesize strategy realizing the given specification.
 
select_options(spec)
Return `gr1c` initial option based on `GRSpec` inits.
networkx.Digraph
load_mealy(filename, fformat='tulipxml')
Load gr1c strategy from file.
Variables
  GR1C_MIN_VERSION = '0.9.0'
  GR1C_BIN_PREFIX = ''
  DEFAULT_NAMESPACE = 'http://tulip-control.sourceforge.net/ns/1'
  logger = logging.getLogger(__name__)
  __package__ = 'tulip.interfaces'
Function Details

get_version()

 

Get version of gr1c as detected by TuLiP.

Failure to find the gr1c program or errors in parsing the received version string will cause an exception.

Returns:
(major, minor, micro), a tuple of int

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

 

Return strategy 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:
if a strategy is given in the XML string, return it as networkx.DiGraph. Else, return (GRSpec, None), where the first element is the specification as read from the XML string.

load_aut_json(x)

 

Return strategy constructed from output of gr1c

Parameters:
  • x - string or file-like object
Returns:
strategy as networkx.DiGraph, like the return value of load_aut_xml

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)

 

Decide realizability of specification.

Consult the documentation of synthesize about parameters.

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

synthesize(spec)

 

Synthesize strategy realizing the given specification.

Parameters:
Returns:
strategy as networkx.DiGraph, or None if unrealizable or error occurs.

load_mealy(filename, fformat='tulipxml')

 

Load gr1c strategy from file.

Parameters:
  • filename (str) - file name
  • fformat (str) - file format; can be one of "tulipxml" (default), "json". Not case sensitive.
Returns: networkx.Digraph
loaded strategy as an annotated graph.