rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
eop_init_values.m
Go to the documentation of this file.
1 function Ut = eop_init_values(model,model_data)
2 %Ut = eop_init_values(model,model_data)
3 %
4 % function which computes the initial values P_ij^0.
5 % 2 differnet functions are supportet, controled via the field
6 % model.init_value_function:
7 % 'standard': P_{i,j}^0 = K - (i*h_1 + j*h_2)_+
8 % 'max' : P_{i,j}^0 = K - max(i*h_1 , j*h_2)_+
9 % In both cases the boundary conditions P_{S1bar,j}^0 = 0 and
10 % P_{i,S2bar}^0 = 0, for all i\in [0, S1bar], j\in [0, S2bar] hold.
11 %
12 % function supports affine decomposition.
13 
14 % Dominik Garmatter 21.12 2011
15 
16 decomp_mode = model.decomp_mode;
17 
18 if decomp_mode == 0 % No decomposition
19  k = model_data.grid.nvertices;
20  Ut = zeros(k,1);
21 % evaluate the function at the inner grid points
22  switch model.init_value_function
23  case 'standard'
24  for j = 1 : model.N2-1
25  Ut((j-1)*model.N1+1:j*model.N1-1,1) = model.K - (model_data.grid.X((j-1)*model.N1+1:j*model.N1-1) + model_data.grid.Y((j-1)*model.N1+1:j*model.N1-1));
26  end
27  case 'max'
28  for j = 1 : model.N2-1
29  Ut((j-1)*model.N1+1:j*model.N1-1,1) = model.K - max(model_data.grid.X((j-1)*model.N1+1:j*model.N1-1), model_data.grid.Y((j-1)*model.N1+1:j*model.N1-1));
30  end
31  otherwise
32  error('init_value_funtion is unknown!');
33  end
34  Ut(Ut<0) = 0; % realises (\cdot)_+
35  Ut(model.N1:model.N1:model.N1*model.N2,1) = 0; % S1bar - boundary
36  Ut(model.N1*(model.N2-1)+1:1:model.N1*model.N2-1,1) = 0; % S2bar - boundary
37 
38 elseif decomp_mode == 1 % Only Components
39  Ut = cell(1); % components are stored in a cell
40  k = model_data.grid.nvertices;
41  Ut_entry = zeros(k,1); % the future cell entry
42 % evaluate the function at the inner grid points
43  switch model.init_value_function
44  case 'standard'
45  for j = 1 : model.N2-1
46  Ut_entry((j-1)*model.N1+1:j*model.N1-1,1) = model.K - (model_data.grid.X((j-1)*model.N1+1:j*model.N1-1) + model_data.grid.Y((j-1)*model.N1+1:j*model.N1-1));
47  end
48  case 'max'
49  for j = 1 : model.N2-1
50  Ut_entry((j-1)*model.N1+1:j*model.N1-1,1) = model.K - max(model_data.grid.X((j-1)*model.N1+1:j*model.N1-1), model_data.grid.Y((j-1)*model.N1+1:j*model.N1-1));
51  end
52  otherwise
53  error('init_value_funtion is unknown!');
54  end
55  Ut_entry(Ut_entry<0) = 0; % realises (\cdot)_+
56  Ut_entry(model.N1:model.N1:model.N1*model.N2,1) = 0; % S1bar - boundary
57  Ut_entry(model.N1*(model.N2-1)+1:1:model.N1*model.N2-1,1) = 0; % S2bar - boundary
58  Ut{1} = Ut_entry;
59 
60 elseif decomp_mode == 2 % Only Coefficients - it is always 1
61  switch model.init_value_function
62  case 'standard'
63  Ut = 1;
64  case 'max'
65  Ut = 1;
66  otherwise
67  error('init_value_funtion is unknown!');
68  end
69 end
function Ut = eop_init_values(model, model_data)
Ut = eop_init_values(model,model_data)