function h = getOptimMessenger(Model)
% return optim messenger, if one exists for various SITB models

% Copyright 2007-2016 The MathWorks, Inc.

h = [];
if isa(Model,'idnlmodel')
   h = pvget(Model,'OptimMessenger');
elseif isa(Model,'idnlfun')
   h = Model(1).OptimMessenger; %Model may be vector valued
elseif isa(Model,'idlti')
   ut = pvget(Model,'Utility');
   if isfield(ut,'OptimMessenger')
      h = ut.OptimMessenger;
   end
end
