ARL Master Index

# Input and Output Statements

For maximum flexibility, Able rulesets maintain an input buffer and an output buffer through which data can be exchanged with other Java programs. A ruleset's input buffer can be used to set the values of specific variables just before inferencing starts, and the output buffer can be used to make the values of specified variables available to external code after inferencing is complete. Those defined variables that have their values set from and written to the buffers are specified by using the InputVariables and OutputVariables statements.

The InputVariables and OutputVariables statements are required, although they can be empty, and they can appear in any order. The statements must appear immediately after the Variables(...) section of the ruleset, or, if a GoalVariable statement is required, immediately after the GoalVariable statement.

        RuleSet <nameOfRuleSet> (

          <Processing Options Statement>*      // Zero or more statements

          Variables(
            <Variable Declaration Statement>+  // One or more statements
          )

          InputVariables()              // Exactly one statement
          OutputVariables()             // Exactly one statement
          .
          .
          .
        )

On this page...

- InputVariables
- OutputVariables

### InputVariables

Most variables, when declared, can be given an initial value. Thus, when inferencing starts, a variable always start out with the exact same value. But sometimes you may want variables to start out with different values than those with which they are declared. One way to do this is to use assertion statements in an initial rule block and assign a variable a value returned from a function call. For example:

       a1: myVar = someFunction()

where someFunction must determine what the variable's value must be. Sometimes this is necessary, but this technique involves the overhead of a call each time. Another way to acomplish setting a variable is to use an InputVariables statement to tell Able to set the variable's value from its input buffer. Then, it is up to some other code to stuff the buffer before processing the ruleset. However, Able is setup to do this as a normal way of business and is very efficient at it. In fact, you can pump variable values from a file or database so that each inferencing cycle uses new data values.

InputVariables is a required statement although its content may be empty. Note that if you leave the InputVariables statement empty, the ruleset will not expect to have an input buffer at runtime, and will not do any related input buffer processing.

Syntax

       InputVariables ( <variableNames>* )

Parameters

<variableNames>
  Is a list of zero or more identifiers that name previously defined variables. If there is an input buffer at runtime, the first element in the input buffer is assigned to the first named variable, the second element in the input buffer is assigned to the second named variable, and so on. If there is no input buffer at runtime, or if there are not enough values in the input buffer, a runtime error is signaled. Extra values in the buffer are ignored.

Examples

        RuleSet <nameOfRuleSet> (

          Variables(
             ...
           )

           InputVariables()       // No input variables expected at runtime

          .
          .
          .
        )

        RuleSet <nameOfRuleSet> (

          Variables(
             a string("VarA")
             b boolean(true)
             ...
           )

           InputVariables(a, b)   // Input buffer must contain at least two
                                  //   values: the first value is assigned
                                  //   to variable a, the second value to b.

          .
          .
          .
        )

        RuleSet <nameOfRuleSet> (

          Variables(
             c continuous(0, 100)
             d discrete("A", "B", "C")
             ...
           )

           InputVars ( c d )      // Input buffer must contain at least two
                                  //   values: the first value is assigned
                                  //   to variable c, the second value to d.

          .
          .
          .
        )

Return to top

### OutputVariables

Similar to the InputVariables statement is the OutputVariables statement. Use this statement to designate those variables whose values are to be placed into an external output buffer after inferencing is complete, so that the values may be read by another Java program.

OutputVariables is a required statement although its content may be empty. If you leave the OutputVariables statement empty, the inference engine will not write any values to an output buffer.

Finally, you should know that the value of a fuzzy variable is always presented to the external world as a defuzzified crisp value.

Syntax

       OutputVariables ( <variableNames>* )

Parameters

<variableNames>
  Is a list of zero or more identifiers that name previously defined variables. At the end of inferencing, the first element placed in the output buffer is the value of the first named variable, the second element placed in the output buffer is the value of the second named variable, and so on.

Examples

        RuleSet <nameOfRuleSet> (

          Variables(
             c continuous(0, 100)
             d discrete("A", "B", "C")
             ...
           )

           InputVariables()       // No input variables expected at runtime
           OutputVariables()      // No output variables written at runtime

          .
          .
          .
        )

        RuleSet <nameOfRuleSet> (

          Variables(
             c continuous(0, 100)
             d discrete("A", "B", "C")
             ...
           )

           InputVariables()       // No input variables expected at runtime
           OutputVariables(c, d)  // Output buffer will contain two elements:
                                  //   the first element is the value of
                                  //   variable c, the second element the
                                  //   value of variable d.

          .
          .
          .
        )

        RuleSet <nameOfRuleSet> (

          Variables(
             c continuous(0, 100)
             d discrete("A", "B", "C")
             ...
           )

           InputVars  (     )     // No input variables expected at runtime
           OutputVars ( c c )     // Output buffer will contain two elements:
                                  //   the first element is the value of
                                  //   variable c, the second element is
                                  //   also the value of variable c.

          .
          .
          .
        )

Return to top

Able Rule Language master index.
Able RuleSet Editor master index.
Rules package table of contents.

Last modified: Thu Mar 29 10:12:19 CST 2001