%
  function [ub,lb,z0,options] = initial_post(DATA);
%
% initialize problem data and parameters
%
% set simple bounds for the states and controls
%
  DATA.N_z = DATA.N_panels*(DATA.N_states+DATA.N_controls);
%
  if isfield(DATA,'U_lower')
      bu =  DATA.U_lower;
  else
      bu = -inf*ones(DATA.N_controls,1);
  end
%
  if isfield(DATA,'X_lower')
      bx =  DATA.X_lower;
  else
      bx = -inf*ones(DATA.N_states,1);
  end
%
  lb  = repmat([bu ; bx],DATA.N_panels,1);
%
  if isfield(DATA,'U_upper')
      bu =  DATA.U_upper;
  else
      bu =  inf*ones(DATA.N_controls,1);
  end
%
  if isfield(DATA,'X_upper')
      bx =  DATA.X_upper;
  else
      bx =  inf*ones(DATA.N_states,1);
  end
%
  ub  = repmat([bu ; bx],DATA.N_panels,1);
%
% initial estimates for controls and states
%
  if (isfield(DATA,'U_guess'))
    u0 =  DATA.U_guess;
  else
    u0 = zeros(DATA.N_controls,1);
  end
%
  if (isfield(DATA,'X_guess'))
    x0 =  DATA.X_guess;
  else
    x0 =  DATA.X_initial;
  end
%
  z0 =  repmat([u0(:) ; x0(:)],DATA.N_panels,1);
%
  options = optimset('fmincon');
%
% Test to see if constraint types and their jacobian are included
  test_eq = ( (isfield(DATA,'Phi_eq') & isfield(DATA,'Phi_eqj') ) | ~isfield(DATA,'Phi_eq') );
  test_in = ( (isfield(DATA,'Phi_in') & isfield(DATA,'Phi_inj') ) | ~isfield(DATA,'Phi_in') );
% 
  if  isfield(DATA,'Mayerj')
     options.GradObj    = 'on';
  else
     disp(['Mayer Jacobian not available '])
  end
%
  if ( isfield(DATA,'Rhsj') & test_eq & test_in)
     options.GradConstr = 'on';
  else
     disp(['Not all Jacobians are available for constraint Jacobian'])
  end
%
% Pass through any OPTIONS settings
%
 if isfield(DATA,'DerivativeCheck')
    options.DerivativeCheck = DATA.DerivativeCheck;
 end
%
 if isfield(DATA,'Diagnostics')
    options.Diagnostics = DATA.Diagnostics;
 end
%
 if isfield(DATA,'DiffMaxChange')
    options.DiffMaxChange = DATA.DiffMaxChange;
 end
%
 if isfield(DATA,'DiffMinChange')
    options.DiffMinChange = DATA.DiffMinChange;
 end
%
 if isfield(DATA,'Display')
    options.Display = DATA.Display;
 end
%
 if isfield(DATA,'LargeScale')
    options.LargeScale = DATA.LargeScale;
 end
%
 if isfield(DATA,'MaxFunEvals')
    options.MaxFunEvals = DATA.MaxFunEvals;
 end
%
 if isfield(DATA,'MaxIter')
    options.MaxIter = DATA.MaxIter;
 end
%
 if isfield(DATA,'MaxPCGIter')
    options.MaxPCGIter = DATA.MaxPCGIter;
 end
%
 if isfield(DATA,'TolCon')
    options.TolCon = DATA.TolCon;
 end
%
 if isfield(DATA,'TolFun')
    options.TolFun = DATA.TolFun;
 end
%
 if isfield(DATA,'TolPCG')
    options.TolPCG = DATA.TolPCG;
 end
%
 if isfield(DATA,'TolX')
    options.TolX = DATA.TolX;
 end
%
 if isfield(DATA,'TypicalX')
    options.TypicalX = DATA.TypicalX;
 end
%
% return
%
