function [ConstraintViolations, SDs] = predictConstraints(this, XTable)
%PREDICTCONSTRAINTS Predict Constraint Violations at a
%set of points.
%   [ConstraintViolations, SDs] =
%   predictConstraints(Results, XTable) returns the
%   posterior means and standard deviations of all Constraints
%   at the points in XTable, according to a Gaussian Process
%   model of each constraint. ConstraintViolations and SDs are
%   both N-by-K matrices, given N rows of XTable and K coupled
%   constraints.
%

%   Copyright 2016-2022 The MathWorks, Inc.

C = bayesoptim.suppressWarnings();
XTable = checkAndPrepareTableForPrediction(this, XTable, 'predictConstraints');
if isempty(XTable) || this.PrivOptions.NumCoupledConstraints == 0
    ConstraintViolations = [];
    SDs = [];
else
    for k = this.PrivOptions.NumCoupledConstraints : -1 : 1
        if isempty(this.ConstraintModels{k})
            ConstraintViolations(:,k) = NaN(height(XTable),1);
            SDs(:,k) = NaN(height(XTable),1);
        else
            [ConstraintViolations(:,k), SDs(:,k)] = predict(...
                this.ConstraintModels{k}, transformPoints(this, XTable));
        end
    end
end
end
