function this = recordFEvalResults(this, X, Objective, ConstraintViolations, UserData, ErrorConstraintViolation, ...
    TotalJobTime, ObjectiveNargout)
% Store the results of an feval in the training sets
%

%   Copyright 2016-2022 The MathWorks, Inc.

this.PrivOptions.ObjectiveNargout        = ObjectiveNargout;
this.XTrain(end+1, :)                    = legalizePoints(this, X);
this.FTrain(end+1)                       = Objective;
this.PrivUserDataTrace{end+1,1}          = UserData;
this.ErrorTrain(end+1,1)                 = ErrorConstraintViolation;
this.ObjectiveEvaluationTimeTrain(end+1) = TotalJobTime;
if this.PrivOptions.NumCoupledConstraints > 0
    this.ConstraintTrain(end+1,:)        = ConstraintViolations;
end
% If ASHA, store additional properties
if isequal(this.PrivOptions.AcquisitionFunctionName, 'asha')
    XTable = untransformPoints(this, X, true);
    this.ASHARungNum(end+1) = XTable.ASHARung;
    this.ASHAIsPromoted(end+1) = false;                 % Set promoted=false when a job is newly added to a rung
end
end
