function [IncumbentF, IncumbentX] = findIncumbent(this, BOOptions)
% Find the point that minimizes the mean of the Objective
% function model. Optionally accept modified Options.
%

%   Copyright 2016-2022 The MathWorks, Inc.

if nargin < 2
    BOOptions = this.PrivOptions;
end
if isempty(this.ObjectiveFcnModel) || acqFcnIsNonBayes(this) || (this.PrivOptions.NumCoupledConstraints>0 && any(cellfun(@isempty, this.ConstraintModels)))
    IncumbentF = NaN;
    IncumbentX = [];
else
    VarSpec = this.PrivOptions.VarSpec;
    IncumbentX = fminbndGlobal(this, @(X)GPFMeanOnPoints(this,X), VarSpec.LBTrans, VarSpec.UBTrans, ...
        BOOptions.NumRestartCandidates, BOOptions.NumRestarts, BOOptions.VerboseRestarts, ...
        BOOptions.MaxIterPerRestart, BOOptions.RelTol);
    % XAtMin is not discretized (although it was discretized during optimization)
    IncumbentX = legalizePoints(this, IncumbentX);
    IncumbentF = GPFMeanOnPoints(this, IncumbentX);
    % If no finite incumbent was found, set it to NaN
    if ~isfinite(IncumbentF)
        IncumbentF = NaN;
        IncumbentX = [];
    end
end
end
