kas-lab / rosa

A knowledge-based framework for Robot Self-adaptation (ROSA)
https://kas-lab.github.io/rosa/
Apache License 2.0
0 stars 0 forks source link

Property to indicate how a constrainment should be evaluated #21

Closed Rezenders closed 1 year ago

Rezenders commented 1 year ago

Related to: https://github.com/meta-control/mc_mdl_tomasys/issues/9

Rezenders commented 1 year ago

Added constrainment-operator to constrainment

constrainment-operator sub attribute,
    value string,
    regex "^(<|<=|>|>=)";

Added condition in the constrainment-status rule to check which operator should be used. If no operator is defined, >= is used as default.

rule constrainment-status-violated:
    when{
        $constrainment (constraint: $constraint) isa constrainment, has attribute-value $value;
        $constraint has attribute-measurement $measurement;
        {    
            {
                $constrainment has constrainment-operator ">=";
            } or {
                not {$constrainment has constrainment-operator $op;};
            };
            not {
                $measurement >= $value;
            };
        } or {
            $constrainment has constrainment-operator ">";
             not {
                $measurement > $value;
            };
        }  or {
            $constrainment has constrainment-operator "<=";
             not {
                $measurement <= $value;
            };
        } or {
            $constrainment has constrainment-operator "<";
             not {
                $measurement < $value;
            };
        };            
    } then {
        $constrainment has constrainment-status 'violated';
    };

Done at: 32f50d9