Spark! Fuzzy Logic Editor Help


Variables | Sets | Rules | API | Integration | Tutorial


get_mom_output()

Gets the maxima output value.  

int get_mom_output()

Parameters

none

Return Value

The index of the "winning" output set.  The "winner" is the set with the largest "degree of membership" or "y" value.

If no rules are active 255 is returned.

Remarks

The index of the set should be from the .h file exported from the Spark! model.  The set's index may not coincide with the screen position of the set.  See Export .h File for more details.

This defuzzification method can be used for Fuzzy State Machines (FuSMs).  In FuSMs you are concerned with finding which action to take ("run away", "fight", "hide") rather than a "defuzzified" value that is output from the system (see get_cog_output() for that functionality).

Example

void print_output_vals(SparkModel* model)
{
	int mom_output = model->get_mom_output();

	cout << "MOM Output value is: ";
	cout << mom_output << endl;

	// translate the mom set's index to "human readable" text...
	cout << "Output result is: ";
	if (mom_output == OUTPUT_SET_IDX_0)
		cout << "Set 0 Name" << endl;
	if (mom_output == OUTPUT_SET_IDX_1)
		cout << "Set 1 Name" << endl;
	if (mom_output == OUTPUT_SET_IDX_2)
		cout << "Set 2 Name" << endl;

} // end print_output_vals()