Welcome to MOSH

Self-healing is becoming an important functionality of smart Cyber-Physical Systems (CPSs). With such functionality, a Self-Healing CPS (SH-CPS) has the ability to recover from faults and adapt its behavior accordingly. Given that uncertainty is inherent in CPSs since such systems operate in highly unpredictable physical environment, self-healing behaviors of an SH-CPS must deal with uncertainty gracefully. To check the correctness of self-healing behaviors of SH-CPSs in the presence of uncertainty, a cost-effective testing method is required.

To fulfill this requirement, we have developed MOSH, an eclipse plugin. It uses model execution and reinforcement learning to efficiently test SH-CPSs. In MOSH, the expected behaviors of the SH-CPS under test are specified as executable UML state machines. Via an extended version of Moka (a Papyrus based UML model execution plugin) MOSH can execute the models together with the system under test. By checking the system’s actual behaviors against the expected ones, MOSH manages to find faults in the SH-CPS.

On the other hand, MOSH uses a reinforcement learning based algorithm to learn the likelihood that a fault can be detected, i.e., the system under test is going to fail, after invoking a given operation. The likelihood is defined as fragility, and the highest discounted fragility after firing a transition is defined as the T-value of the transition. Directed by the T-value, MOSH manages to find the optimal operation invocations to effectively detect faults.

Architecture of MOSH

MOSH consists of three packages: software in the loop testing (light gray), uncertainty generation (dark gray), and fragility oriented testing (white).

MOSH tests the software of an SH-CPS in a simulated environment. During testing, sensor data is computed by simulation models in simulators. Based on the simulated data, the software generates actuation instructions to control the system. Uncertainties are added to simulators’ inputs and outputs to simulate the effects of uncertainties. Based on uncertainty specification, an uncertainty generator generates the values of uncertain factors whenever sensor data or actuation instructions are transferred between the software and simulators. By using the values to modify simulators’ inputs and outputs, the specified uncertainties are introduced into the testing environment.

MOSH executes the system under test and corresponding test model together via an execution engine, which is deployed in Moka, a UML model execution platform. During the execution, the engine dynamically derives a dynamic flat state machine from the test model and used it to guide the execution. Meanwhile, the active state’s state invariant is checked by a test inspector (using DresdenOCL). The inspector evaluates the invariant with the actual values of the state variables, which are updated by the execution engine via testing APIs. If the invariant is evaluated to be false, a fault is detected. Otherwise, the inspector calculates the fragility of the SUT in the current state. Taking fragility as input, the fragility oriented testing algorithm updates its estimate of the T-value of last selected transition and uses the softmax policy to select the next transition. Next, the test driver generates a valid test input with EsOCL, a search-based test data generator, for firing the selected transition. The execution engine takes this input to invoke the corresponding operation, causing the test and the system to enter the next state. In this way, T-values are learned from iterations of execution and the learned T-values direct the algorithm to cost-effectively find faults.

Installation Instruction

Download MOSH here!
Note that MOSH is only available for education purpose.

  1. Install Eclipse Modeling Tools. Version: Mars.2. (Due to the limitation of Moka, so far MOSH can only be used in this version). from: http://www.eclipse.org/downloads/packages/eclipse-modeling-tools/mars2
  2. Install Papyrus on eclipse. Update site: http://download.eclipse.org/modeling/mdt/papyrus/updates/releases/mars
  3. Download Moka from branch "bugs/465888-SMExecPrototype" on Papyrus repository https://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/
  4. Import Moka under the folder “extraplugins/moka”
  5. Download MOSH from the above link.
  6. Import “org.simula.mosh” and “org.simula.constraint” from MOSH.

Sample code to use MOSH

// load UML model
ResourceSet resourceSet = new ResourceSetImpl();
				new XMIResourceFactoryImpl());
Resource resource = resourceSet.getResource(URI.createFileURI(UML models' path), true);
Model umlModel = (Model) EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.MODEL);

// locate the object to execute
EList elements = umlModel.allOwnedElements();
for (Element e : elements) {
	if (e instanceof Class) {
		Class c = (Class) e;
		Stereotype s = c.getAppliedStereotype("testing::SystemUnderTest");
		if (s != null) {
			eObjectToExecute = c;

// start execution
TestModelExecutionEngine engine = new TestModelExecutionEngine();
MokaDebugTarget target = new MokaDebugTarget(null, null);
engine.init(eObjectToExecute, args, target, requestPort, replyPort, eventPort);
target.connect(requestPort, replyPort, eventPort);

engineJob = new MokaExecutionEngineJob("Execution Engine Job", engine);

try {
catch (InterruptedException e) {

Related Publications

  • Ma, Tao, Shaukat Ali, Tao Yue, and Maged Elaasar. "Fragility-oriented testing with model execution and reinforcement learning." In IFIP International Conference on Testing Software and Systems, pp. 3-20. Springer, Cham, 2017.