function this = fitBayesOptModels(this, varargin)
% Fit models for objective functions, objective function
% evaluation time, constraints and errors using either Random
% Forests or Gaussian Processes depending on the strategy
% object
%

%   Copyright 2016-2022 The MathWorks, Inc.

if this.PrivOptions.FitModels
    this.ObjectiveFcnModel = fitObjectiveFcnModel(this.ModelStrategy, ...
        this.XTrain, this.FTrain, this.PrivOptions, this.ObjectiveFcnModel, varargin);
    this.ObjectiveEvaluationTimeModel = fitObjectiveEvaluationTimeModel(this.ModelStrategy, ...
        this.XTrain, this.FTrain, this.PrivOptions, ...
        this.ObjectiveEvaluationTimeTrain, this.ObjectiveEvaluationTimeModel, varargin);
    this.ConstraintModels = fitConstraintModels(this.ModelStrategy, ...
        this.XTrain, this.ConstraintTrain, this.ConstraintModels, ...
        this.PrivOptions, varargin);
    this.ErrorModel = fitErrorModel(this.ModelStrategy, this.XTrain, ...
        this.FTrain, this.PrivOptions, this.ErrorTrain, this.ErrorModel, varargin);
else
    this.ObjectiveFcnModel = [];
    this.ObjectiveEvaluationTimeModel = [];
    this.ConstraintModels = cell(1, this.PrivOptions.NumCoupledConstraints);
    this.ErrorModel = [];
end
end
