function adasblocks_callbackUsesuboptimal(blk)
% Callback function of the "Use suboptimal" checkbox in the Adaptive Cruise
% Control System and Lane Keeping Assist System block dialog.
%
% The checkbox is located in Tab Block -> Panel Optimization.

%   Author: Meng Xia, Rong Chen
%   Copyright 2017-2018 The MathWorks, Inc.

% this parameter is not tunable.
if any(strcmpi(get_param(bdroot(blk),'SimulationStatus'),{'external','running'}))
    return
end
% enable/disable of using suboptimal solutions for MPC optimization
maskObj = Simulink.Mask.get(blk);
selection = get_param(blk,'suboptimal'); % do not use "object.Value'
object = maskObj.getDialogControl('OptimizationPanel');
if strcmp(selection,'on')
    object.Enabled = 'on';
else
    object.Enabled = 'off';
end
