function linear
global Tk
Tk = 273.15;
name = label;
fd = fopen('lin.csv', 'w');
for i=1:length(name)
  fprintf(fd, '\t%s', name(i, :));
end
fprintf(fd, '\n');
perturb(fd);
fclose(fd);

function perturb(fd)
global Tk
load optimal_operation
load scaling
load conditions
load data

i_com = length(sc.com.x);
i_con = length(sc.con.x);
i_val = length(sc.val.x);
i_vap = length(sc.vap.x);
con = x(1:i_con);
val = x(i_con+1:i_con+i_val);
vap = x(i_con+i_val+1:i_con+i_val+i_vap);
com = x(i_con+i_val+i_vap+1:end);

Avap = vap(2);
Acon = sum(con(6:10));
Qvap = vap(3)
UA = Qvap/(u(2)-u(1));
Ntot = sum(con(16:21))+sum(vap(4:5));
A = xlsread('A.xls', 'operation')
SCALER = [];
for i=1:size(A,1)
  SCALER = [SCALER; sc.x'];
end
A=A.*SCALER;
Xcon_L = [zeros(5,1); zeros(5,1); -inf*ones(5,1); zeros(4,1); zeros(2,1); 0; 0]./sc.con.x;
Xcon_U = [inf*ones(5,1); inf*ones(5,1); inf*ones(5,1); inf*ones(4,1); inf*ones(2,1); 1; inf]./sc.con.x;
Xval_L = [zeros(2,1); -inf]./sc.val.x;
Xval_U = [1; inf; inf]./sc.val.x;
Xvap_L = [0; 0; -inf; zeros(2,1); 0; 0]./sc.vap.x;
Xvap_U = [inf; inf; inf; inf*ones(2,1); inf; inf]./sc.vap.x;
Xcom_L = [0; 0]./sc.com.x;
Xcom_U = [inf; inf]./sc.com.x;
f = 'objfun';
g = [];
H = [];
HessPattern = [];
x_L = [Xcon_L; Xval_L; Xvap_L; Xcom_L];
x_U = [Xcon_U; Xval_U; Xvap_U; Xcom_U];
pSepFunc = [];
fLowBnd = [];
dc = [];
c = 'nonlcon';
d2c = [];
ConsPattern = [];
c_L = zeros(size(sc.res));
c_U = zeros(size(sc.res));
x_min = [];
x_max = [];
f_opt = [];
x_opt = [];
for nd=0:2
  if nd==0
    Name = 'Nominal opt.'
  elseif nd==1
    Name = 'Tamb + 0.1 degree'
    u(2) = u(2)+0.1;
  elseif nd==2
    Name = 'Troom + 0.05'
    u(1) = u(1)+0.05;
  else
    error('Not valid')
  end
  Qvap = UA*(u(2)-u(1));
  b_L = [Qvap;
         Acon;
         Avap;
         Ntot;
         -inf];
  b_U = [Qvap;
         Acon;
         Avap;
         Ntot;
         inf];
  Prob = ProbDef;
  Prob = conAssign(f, g, H, HessPattern, x_L, x_U, Name, x./sc.x, pSepFunc, fLowBnd, A, b_L, b_U, c, dc, d2c, ConsPattern, c_L, c_U, x_min, x_max, f_opt, x_opt);
  Prob.d = d;
  Prob.sc = sc;
  Prob.u = u;
  Result = tomRun('minos', Prob);
  x = Result.x_k.*sc.x;
  fprintf(fd, '%s\t', Name);
  for i=1:length(sc.x)
     fprintf(fd, '%0.5f\t', x(i));
  end
  fprintf(fd, '%s', Result.ExitText);
  fprintf(fd, '\n');
end

