@ Override public BtrpOperand go ( BtrPlaceTree parent ) { String cname = getText ( ) ; if ( catalog == null ) { return ignoreError ( "No constraints available" ) ; } SatConstraintBuilder b = catalog . getConstraint ( cname ) ; if ( b == null ) { ignoreError ( "Unknown constraint '" + cname + "'" ) ; } //Get the params int i = 0 ; boolean discrete = false ; if ( ">>" . equals ( getChild ( 0 ) . getText ( ) ) ) { i = 1 ; discrete = true ; } List < BtrpOperand > params = new ArrayList <> ( ) ; for ( ; i < getChildCount ( ) ; i ++ ) { params . add ( getChild ( i ) . go ( this ) ) ; } if ( b != null ) { List < ? extends SatConstraint > constraints = b . buildConstraint ( this , params ) ; for ( SatConstraint c : constraints ) { if ( c != null ) { if ( discrete ) { if ( ! c . setContinuous ( false ) ) { return ignoreError ( "Discrete restriction is not supported by constraint '" + cname + "'" ) ; } } else { //force the continuous mode, if available c . setContinuous ( true ) ; } script . addConstraint ( c ) ; } } } return IgnorableOperand . getInstance ( ) ; }
Build the constraint . The constraint is built if it exists in the catalog and if the parameters are compatible with the constraint signature .