HyRG: A Random Generation Tool for Affine Hybrid Automata
Luan Viet Nguyen, Christian Schilling, Sergiy Bogomolov, Taylor T. Johnson 
verivital.uta.edu/hyrg/

HyRG has been tested in Matlab 2013b, 2014a, and 2014b.  You call it from a Matlab command prompt as follows.

Function call:
randgen_hybridautomaton(m, n, options)

Inputs:
m	: number of locations
n	: number of variables
options	: string list of options, specified below

Output:
Output SpaceEx model files are generated in ..\examples\rangen

Example calls:

1) The following generates an automaton with 3 state variables and 3 locations, where each mode has unstable dynamic(every mode's A matrix has all eigenvalues are positive real numbers). A generated automaton is state-depedent switching system, and it has no self-transition.

randgen_hybridautomaton(3,3)

2) The following generates an automaton with 4 state variables and 6 locations, where each mode has unstable dynamic(every mode's A matrix has all eigenvalues are positive real numbers). It also generates a SpaceEx model included of this automaton and another time dependent switching system(functions as a global time clock) for sanity checking.  

randgen_hybridautomaton(6,4,'-s')

2) The following generates an automaton with 4 state variables and 20 locations, where each mode has stable dynamic (e.g., every mode's A matrix is Hurwitz). A generated automaton is state-depedent switching sytem, and it has no self-transition.

randgen_hybridautomaton(20,4,'-nr')

3) The following generates an automaton with 3 state variables and 5 locations, where each mode may have different classes of dynamic. A generated automaton is state-depedent switching sytem, and it has no self-transition.

randgen_hybridautomaton(5,3,'-rd')

4) The following generates an automaton with 3 variables and 4 locations. This automaton is time-dependent swithcing('-t'). Each mode may have different classes of dynamic('-rd'). A generated automaton may have self-loop transitions('-g'). Invariants and guard conditions are randomly generated as inequalities of state variables and constant numbers('-ci'). State variables are updated to their random symbolic expression algebra('-sr'). And a generated automaton is also translated to Simulink/Stateflow(SLSF) model('-ss').

Output SLSF files (.mdl) are generated in .\output_SLSF
An SLSF files are automatically hooked up to scopes and can executable without anyadditional manual setting.

randgen_hybridautomaton(4,3,'-rd','-t','-g','-ss','-ci','-sr')


The following options are:
-t 	: randomly generate time-dependent switching system.
-g 	: randomly generate model included self-loop transitions.
-s 	: randomly generate model for sanity checking.
-ss 	: enable translation from SpaceEx XML model to SLSF model.
-ci 	: randomly generate constant invariants, constant guard conditions.
-si 	: randomly generate invariants and guard conditions as symbolic expression algebra of state variables.
-cr 	: update state variables to random constants.
-sr 	: update state variables to their random symbolic expression algebra.


Options for randomly generating different flow dynamics:  

Default	: randomly generate a flow dynamic based on a matrix whose all eigenvalues are positive real numbers. 

-z 	: randomly generate a flow dynamic based on a matrix whose all eigenvalues are zero. 
-n 	: randomly generate a flow dynamic based on a matrix whose all eigenvalues are negative real numbers
-pn 	: randomly generate a flow dynamic based on a matrix whose eigenvalues are either positive or negative real numbers.
-nz	: randomly generate a flow dynamic based on a matrix whose eigenvalues are either zero or negative real numbers.
-pnz 	: randomly generate a flow dynamic based on a matrix whose eigenvalues are positive, zero or negative real numbers.
-pr 	: randomly generate a flow dynamic based on a matrix whose eigenvalues are complex numbers with positive real parts.
-nr 	: generate a flow dynamic based on a matrix whose eigenvalues are complex numbers with negative real parts.
-i 	: generate a flow dynamic based on a matrix whose all eigenvalues are are complex numbers with purely imaginary.
-rd 	: generate a flow dynamic by randomly selecting one of all previous options.

Generating k examples with qualitatively similar behavior to known hybrid systems examples.
Inputs:
* k	: number of trials
* m	: number of locations
* n	: number of variables

Generate bouncing ball examples:

Bouncing ball system has one location and two variables:
ball_production(k,1,2)
E.g if we want to generate 100 examples of bouncing ball system:
ball_production(100,1,2)	


Generate thermostat(heater) system examples:
Themostat system has two locations and one variable
heater_production(k,2,1)
E.g if we want to generate 100 examples of thermostat system:
heater_production(100,2,1)
