easiest way to prototype a symbolic orthogonal matrix - matlab

I have 8 sins and cosines that I try to symbolically define as shown below using Matlab. My goal is to symbolically build a matrix H (accumulated Givens rotations matrix) of 8x8 using all these sins and cosines and end up seeing what the formula for this H orthogonal projection matrix is. I can do that using the code below conceptually G7*G6*...*G0*I where I is the Identity 8x8 and the Gi are the Givens rotation corresponding to elements (i:i+1,i:i+1).
c_0 = sym('c_0');
c_1 = sym('c_1');
c_2 = sym('c_2');
c_3 = sym('c_3');
c_4 = sym('c_4');
c_5 = sym('c_5');
c_6 = sym('c_6');
c_7 = sym('c_7');
s_0 = sym('s_0');
s_1 = sym('s_1');
s_2 = sym('s_2');
s_3 = sym('s_3');
s_4 = sym('s_4');
s_5 = sym('s_5');
s_6 = sym('s_6');
s_7 = sym('s_7');
% create H orthogonal matrix using the sin and cos symbols
% filling in the first rotation
I=eye(9,9)
H = I;
H(1:2,1:2) = [c_0 -s_0; s_0 c_0]
% build the 2nd rotation and update H
G = I;
G(2:3,2:3) = [c_1 -s_1; s_1 c_1]
H = G*H
% build the 3rd rotation and update H
G = I;
G(3:4,3:4) = [c_2 -s_2; s_2 c_2]
H = G*H
% build the 4rth rotation and update H
G = I;
G(4:5,4:5) = [c_3 -s_3; s_3 c_3]
H = G*H
% build the 5th rotation and update H
G = I;
G(5:6,5:6) = [c_4 -s_4; s_4 c_4]
H = G*H
% build the 6th rotation and update H
G = I;
G(6:7,6:7) = [c_5 -s_5; s_5 c_5]
H = G*H
% build the 7th rotation and update H
G = I;
G(7:8,7:8) = [c_6 -s_6; s_6 c_6]
H = G*H
% build the 8th rotation and update H
G = I;
G(8:9,8:9) = [c_7 -s_7; s_7 c_7]
H = G*H
The code fails with the following error and can't find how to fix this:
The following error occurred converting from sym to double:
Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
Error in build_rotH_test (line 26)
H(1:2,1:2) = [c_0 -s_0; s_0 c_0]

I solved it like this. Note I realized I need the transpose of each rotation so I can build and apply H'*x i.e. G7'*G6'*...*G0'*I that's why the sin signs are flipped in the solution.
clear all;
% defining 0 and 1 as symbols too, solves the problem
sym_0 = sym('0');
sym_1 = sym('1');
c0 = sym('c0');
c1 = sym('c1');
c2 = sym('c2');
c3 = sym('c3');
c4 = sym('c4');
c5 = sym('c5');
c6 = sym('c6');
c7 = sym('c7');
s0 = sym('s0');
s1 = sym('s1');
s2 = sym('s2');
s3 = sym('s3');
s4 = sym('s4');
s5 = sym('s5');
s6 = sym('s6');
s7 = sym('s7');
% create H orthogonal matrix using the sin and cos symbols
% filling in the first rotation
I = repmat(sym_0,9,9);
for i=1:9
I(i,i)=sym_1;
end
H = I
H(1:2,1:2) = [c0 s0; -s0 c0]
% build the 2nd rotation and update H
G = I;
G(2:3,2:3) = [c1 s1; -s1 c1]
H = G*H;
% build the 3rd rotation and update H
G = I;
G(3:4,3:4) = [c2 s2; -s2 c2]
H = G*H;
% build the 4rth rotation and update H
G = I;
G(4:5,4:5) = [c3 s3; -s3 c3]
H = G*H;
% build the 5th rotation and update H
G = I;
G(5:6,5:6) = [c4 s4; -s4 c4]
H = G*H;
% build the 6th rotation and update H
G = I;
G(6:7,6:7) = [c5 s5; -s5 c5]
H = G*H;
% build the 7th rotation and update H
G = I;
G(7:8,7:8) = [c6 s6; -s6 c6]
H = G*H;
% build the 8th rotation and update H
G = I;
G(8:9,8:9) = [c7 s7; -s7 c7]
H = G*H
and the output is:
H =
[ 1, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1]
H =
[ c0, s0, 0, 0, 0, 0, 0, 0, 0]
[ -s0, c0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1]
G =
[ 1, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, c1, s1, 0, 0, 0, 0, 0, 0]
[ 0, -s1, c1, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1]
G =
[ 1, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, c2, s2, 0, 0, 0, 0, 0]
[ 0, 0, -s2, c2, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1]
G =
[ 1, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, c3, s3, 0, 0, 0, 0]
[ 0, 0, 0, -s3, c3, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1]
G =
[ 1, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, c4, s4, 0, 0, 0]
[ 0, 0, 0, 0, -s4, c4, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1]
G =
[ 1, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, c5, s5, 0, 0]
[ 0, 0, 0, 0, 0, -s5, c5, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1]
G =
[ 1, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, c6, s6, 0]
[ 0, 0, 0, 0, 0, 0, -s6, c6, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1]
G =
[ 1, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, c7, s7]
[ 0, 0, 0, 0, 0, 0, 0, -s7, c7]
H =
[ c0, s0, 0, 0, 0, 0, 0, 0, 0]
[ -c1*s0, c0*c1, s1, 0, 0, 0, 0, 0, 0]
[ c2*s0*s1, -c0*c2*s1, c1*c2, s2, 0, 0, 0, 0, 0]
[ -c3*s0*s1*s2, c0*c3*s1*s2, -c1*c3*s2, c2*c3, s3, 0, 0, 0, 0]
[ c4*s0*s1*s2*s3, -c0*c4*s1*s2*s3, c1*c4*s2*s3, -c2*c4*s3, c3*c4, s4, 0, 0, 0]
[ -c5*s0*s1*s2*s3*s4, c0*c5*s1*s2*s3*s4, -c1*c5*s2*s3*s4, c2*c5*s3*s4, -c3*c5*s4, c4*c5, s5, 0, 0]
[ c6*s0*s1*s2*s3*s4*s5, -c0*c6*s1*s2*s3*s4*s5, c1*c6*s2*s3*s4*s5, -c2*c6*s3*s4*s5, c3*c6*s4*s5, -c4*c6*s5, c5*c6, s6, 0]
[ -c7*s0*s1*s2*s3*s4*s5*s6, c0*c7*s1*s2*s3*s4*s5*s6, -c1*c7*s2*s3*s4*s5*s6, c2*c7*s3*s4*s5*s6, -c3*c7*s4*s5*s6, c4*c7*s5*s6, -c5*c7*s6, c6*c7, s7]
[ s0*s1*s2*s3*s4*s5*s6*s7, -c0*s1*s2*s3*s4*s5*s6*s7, c1*s2*s3*s4*s5*s6*s7, -c2*s3*s4*s5*s6*s7, c3*s4*s5*s6*s7, -c4*s5*s6*s7, c5*s6*s7, -c6*s7, c7]

Related

The given json data was not valid json

Here is my struct
struct Players: Codable {
let players: [Player]
}
// MARK: - Player
struct Player: Codable {
let name: String
let number, gp, gs, min: Double
let fgm, fga, fg3, fg3A: Double
let ft, fta, pts, oreb: Double
let dreb, pf, ast, to: Double
let stl, blk: Double
}
Here is my json
"Players" : {
[
{
"name" : "Player",
"number" : 0,
"gp" : 0,
"gs" : 0,
"min" : 0,
"fgm" : 0,
"fga" : 0,
"fg3" : 0,
"fg3a" : 0,
"ft" : 0,
"fta" : 0,
"pts" : 0,
"oreb" : 0,
"dreb" : 0,
"pf" : 0,
"ast" : 0,
"to" : 0,
"stl" : 0,
"blk" : 0
},
{
"name" : "Player",
"number" : 0,
"gp" : 0,
"gs" : 0,
"min" : 0,
"fgm" : 0,
"fga" : 0,
"fg3" : 0,
"fg3a" : 0,
"ft" : 0,
"fta" : 0,
"pts" : 0,
"oreb" : 0,
"dreb" : 0,
"pf" : 0,
"ast" : 0,
"to" : 0,
"stl" : 0,
"blk" : 0
}
]
}
Here is my code
do {
let decoded = try JSONDecoder().decode(Players.self, from: data)
print(decoded)
} catch {
print(error)
}
And it keeps returning that I have invalid Json. I am not exactly sure what to about this but any help would be much appreciated.
Because your json is invalid json file.
JSON starts with { and ends with }. Your doesnt.
Also your json has { on wrong place after "Player". You defined array so it should go something like this:
{ "Players" : [
{
"name" : "Player",
"number" : 0,
"gp" : 0,
"gs" : 0,
"min" : 0,
"fgm" : 0,
"fga" : 0,
"fg3" : 0,
"fg3a" : 0,
"ft" : 0,
"fta" : 0,
"pts" : 0,
"oreb" : 0,
"dreb" : 0,
"pf" : 0,
"ast" : 0,
"to" : 0,
"stl" : 0,
"blk" : 0
},
{
"name" : "Player",
"number" : 0,
"gp" : 0,
"gs" : 0,
"min" : 0,
"fgm" : 0,
"fga" : 0,
"fg3" : 0,
"fg3a" : 0,
"ft" : 0,
"fta" : 0,
"pts" : 0,
"oreb" : 0,
"dreb" : 0,
"pf" : 0,
"ast" : 0,
"to" : 0,
"stl" : 0,
"blk" : 0
}
]
}
PS. this is recreation of assumption, but i assume you wanted Players to be an array
This is valid json
{"name":"John", "age":30, "car":null}
This is not valid json
"name":"John", "age":30, "car":null
Also for arrays, they are defined with [
So a valid array would be
{
"name":"John",
"age":30,
"cars":["Ford", "BMW", "Fiat"]
}
And this will not be a valid json array
{
"name":"John",
"age":30,
"cars":{["Ford", "BMW", "Fiat"]}
}
The key in json is "Players" and key in the struct Players is "players".
struct Players: Codable {
let players: [Player]
}
You can add a custom value for CodingKeys like this -
struct Players: Codable {
let players: [Player]
enum CodingKeys: String, CodingKey {
case players = "Players"
}
}
If you want "Players" to be an array of objects, then move the first bracket to before "Players" like so:
{
"Players" : [
{
"name" : "Player",
"number" : 0,
"gp" : 0,
"gs" : 0,
"min" : 0,
"fgm" : 0,
"fga" : 0,
"fg3" : 0,
"fg3a" : 0,
"ft" : 0,
"fta" : 0,
"pts" : 0,
"oreb" : 0,
"dreb" : 0,
"pf" : 0,
"ast" : 0,
"to" : 0,
"stl" : 0,
"blk" : 0
},
{
"name" : "Player",
"number" : 0,
"gp" : 0,
"gs" : 0,
"min" : 0,
"fgm" : 0,
"fga" : 0,
"fg3" : 0,
"fg3a" : 0,
"ft" : 0,
"fta" : 0,
"pts" : 0,
"oreb" : 0,
"dreb" : 0,
"pf" : 0,
"ast" : 0,
"to" : 0,
"stl" : 0,
"blk" : 0
}
]
}

Numpy array: Conditional encoding

I have following numpy array:
array([1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 2, 3, 3, 3, 3, 1, 1, 1, 1,
1, 3, 1, 1, 3, 0, 1, 3, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 0, 1, 2, 0, 2,
2, 2, 1, 2, 2, 0, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 0, 2, 1, 1,
1, 1, 3, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 0, 2, 3,
2, 1, 1, 1, 1, 3, 1, 0])
Question: How can I create another array that encodes the data, given condition: If value = 3 or 2, then "1", else "0".
I tried:
from sklearn.preprocessing import label_binarize
label_binarize(doc_topics, classes=[3,2])[:15]
array([[0, 0],
[0, 0],
[0, 0],
[1, 0],
[0, 0],
[0, 0],
[0, 0],
[0, 0],
[0, 0],
[0, 0],
[0, 1],
[0, 0],
[0, 0],
[0, 0],
[0, 1]])
However, this seems to return a 2-D array.
Use np.where and pass your condition to mask the elements of interest to set where the condition is met to 1, 0 otherwise:
In[18]:
a = np.where((a==3) | (a == 2),1,0)
a
Out[18]:
array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0,
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1,
0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0,
0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0])
Here we compare the array with the desired values, and use the unary | to or the conditions, due to operator precedence we have to use parentheses () around the conditions.
To do this using sklearn:
In[68]:
binarizer = preprocessing.Binarizer(threshold=1)
binarizer.transform(a.reshape(1,-1))
Out[68]:
array([[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0,
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1,
0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0,
0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0]])
This treats values above 1 as 1 and 0 otherwise, this only works for this specific data set as you want 2 and 3 to be 1, it won't work if you have other values, so the numpy method is more general

Account structure with multiple nested and recursive parent / child hierarchy

This is my very first question asked (ever). So, please be patient while I try to explain my problem.
I have a table as follows which is giving me the hierarchy structure for some account:
declare #AccountDefinitions table
(
AccountID int identity(1, 1)
primary key
not null,
AccountNumber nvarchar(11) not null,
AccountType nvarchar(1) not null,
SumSign1 smallint,
SumAccount1 nvarchar(11),
SumSign2 smallint,
SumAccount2 nvarchar(11),
SumSign3 smallint,
SumAccount3 nvarchar(11)
)
If an account is summed up (added to another acount) then the parent account is in SumAccount1. So, SumAccount1 can be found in AccountNumber again. That's the ordinary parent / child hierarchy which could be easily solved with a CTE as described in multiple solutions.
Yet, there are two more parent columns with the names SumAccount2 and SumAccount3. This means that an account may have up to three parents. But sometimes there are only two parents or no parents. In such cases SumAccount3 (and / or the others) would be NULL.
Basically, now I would need a nested CTE to deal with these multiple possible parents which may lead to multiple different paths. If an account has three parents and each of these have another three parents then there are already nine different paths this account could be potentially added up to.
Here is some test data to play around with:
insert into #AccountDefinitions
(AccountNumber, AccountType, SumSign1, SumAccount1, SumSign2,
SumAccount2, SumSign3, SumAccount3)
values (N'K07_005', N'U', 0, null, 0, null, 0, null),
(N'K07_010', N'U', 0, null, 0, null, 0, null),
(N'K07_010A', N'U', 0, null, 0, null, 0, null),
(N'K07_020', N'R', 0, null, 0, null, 0, null),
(N'K07_020A', N'R', 0, null, 0, null, 0, null),
(N'K07_020AA', N'R', 0, null, 0, null, 0, null),
(N'K07_021', N'U', 0, null, 0, null, 0, null),
(N'K07_022', N'U', 0, null, 0, null, 0, null),
(N'K07_025', N'U', 0, null, 0, null, 0, null),
(N'K07_025A', N'U', 0, null, 0, null, 0, null),
(N'K07_035', N'U', 1, N'K07_060', 0, null, 0, null),
(N'K07_060', N'U', 1, N'K07_930', 0, null, 0, null),
(N'K07_090', N'U', 0, null, 0, null, 0, null),
(N'K07_091', N'U', 0, null, 0, null, 0, null),
(N'K07_091P', N'U', 0, null, 1, N'K07_O091', 0, null),
(N'K07_092', N'U', 0, null, 0, null, 0, null),
(N'K07_095', N'U', 0, null, 0, null, 0, null),
(N'K07_096', N'U', 0, null, 0, null, 0, null),
(N'K07_100', N'U', 0, null, 1, N'K07_1000', 0, null),
(N'K07_1000', N'I', 1, N'K07_O100', 0, null, 0, null),
(N'K07_1010', N'I', 1, N'K07_100', 1, N'K07_101P', 1, N'K07_C130'),
(N'K07_101P', N'U', 1, N'K07_O101', 0, null, 0, null),
(N'K07_110', N'I', 1, N'K07_130', 0, null, 0, null),
(N'K07_120', N'I', 1, N'K07_130', 0, null, 0, null),
(N'K07_120P', N'U', 1, N'K07_O120', 0, null, 0, null),
(N'K07_160', N'I', 1, N'K07_170', 0, null, 0, null),
(N'K07_170', N'I', 1, N'K07_251', 0, null, 0, null),
(N'K07_180', N'U', 1, N'K07_190', 0, null, 0, null),
(N'K07_185', N'S', 1, N'K07_190', 0, null, 0, null),
(N'K07_190', N'S', 0, null, 0, null, 0, null),
(N'K07_200', N'I', 1, N'K07_2000', 1, N'K07_250', 0, null),
(N'K07_2000', N'U', 0, null, 0, null, 0, null),
(N'K07_201', N'I', 1, N'K07_C810', 1, N'K07_900', 1, N'K07_200'),
(N'K07_202', N'I', 1, N'K07_202P', 1, N'K07_251', 0, null),
(N'K07_202P', N'U', 0, null, 0, null, 0, null),
(N'K07_205', N'C', 1, N'K07_091P', -1, N'K07_251', 0, null),
(N'K07_250', N'U', 1, N'K07_300', 1, N'K07_2500', 0, null),
(N'K07_2500', N'U', 0, null, 0, null, 0, null),
(N'K07_251', N'I', 1, N'K07_301', 1, N'K07_251P', 0, null),
(N'K07_251P', N'U', 0, null, 0, null, 0, null),
(N'K07_270', N'T', -1, N'K07_300', 1, N'K07_2700', 0, null),
(N'K07_2700', N'T', 1, N'K07_O270', 0, null, 0, null),
(N'K07_271', N'C', -1, N'K07_301', 1, N'K07_271P', 0, null),
(N'K07_271P', N'T', 0, null, 1, N'K07_O271', 0, null),
(N'K07_280', N'T', -1, N'K07_300', 1, N'K07_2800', 0, null),
(N'K07_2800', N'T', 1, N'K07_O280', 0, null, 0, null),
(N'K07_281', N'C', -1, N'K07_301', 1, N'K07_281P', 0, null),
(N'K07_281P', N'T', 0, null, 1, N'K07_O281', 0, null),
(N'K07_300', N'U', 1, N'K07_400', 1, N'K07_3000', 0, null),
(N'K07_3000', N'U', 0, null, 0, null, 0, null),
(N'K07_301', N'I', 1, N'K07_401', 1, N'K07_301P', 0, null),
(N'K07_301P', N'U', 0, null, 0, null, 0, null),
(N'K07_320', N'T', 1, N'K07_400', 0, null, 0, null),
(N'K07_321', N'I', 1, N'K07_401', 1, N'K07_342', 0, null),
(N'K07_322', N'I', 1, N'K07_401', 1, N'K07_342', 0, null),
(N'K07_330', N'T', 1, N'K07_400', 0, null, 0, null),
(N'K07_331', N'I', 1, N'K07_401', 0, null, 0, null),
(N'K07_340', N'T', 1, N'K07_400', 0, null, 0, null),
(N'K07_341', N'I', 1, N'K07_401', 1, N'K07_342', 0, null),
(N'K07_342', N'C', 0, null, 0, null, 0, null),
(N'K07_350', N'T', 1, N'K07_400', 0, null, 0, null),
(N'K07_351', N'C', 1, N'K07_401', 0, null, 0, null),
(N'K07_400', N'U', 1, N'K07_600', 0, null, 0, null),
(N'K07_401', N'C', 1, N'K07_601', 1, N'K07_510', 0, null),
(N'K07_420', N'T', 1, N'K07_500', 0, null, 0, null),
(N'K07_421', N'C', 1, N'K07_501', 1, N'K07_502', 0, null),
(N'K07_430', N'T', 1, N'K07_500', 0, null, 0, null),
(N'K07_431', N'C', 1, N'K07_501', 1, N'K07_502', 0, null),
(N'K07_440', N'T', 0, null, 0, null, 0, null),
(N'K07_441', N'T', 1, N'K07_465', 0, null, 0, null),
(N'K07_450', N'T', 0, null, 0, null, 0, null),
(N'K07_451', N'T', 1, N'K07_465', 0, null, 0, null),
(N'K07_455', N'C', 1, N'K07_463', 1, N'K07_466', 0, null),
(N'K07_456', N'U', 1, N'K07_465', 0, null, 0, null),
(N'K07_457', N'C', 1, N'K07_463', 1, N'K07_466', 0, null),
(N'K07_458', N'C', 1, N'K07_463', 1, N'K07_466', 0, null),
(N'K07_459', N'C', 1, N'K07_463', 1, N'K07_466', 0, null),
(N'K07_460', N'T', 0, null, 0, null, 0, null),
(N'K07_461', N'T', 1, N'K07_465', 0, null, 0, null),
(N'K07_462', N'T', 1, N'K07_465', 0, null, 0, null),
(N'K07_463', N'T', 1, N'K07_501', 0, null, 0, null),
(N'K07_464', N'T', 1, N'K07_465', 0, null, 0, null),
(N'K07_465', N'T', 1, N'K07_500', 0, null, 0, null),
(N'K07_466', N'C', 0, null, 1, N'K07_502', 0, null),
(N'K07_470', N'T', 0, null, 0, null, 0, null),
(N'K07_471', N'T', 1, N'K07_485', 0, null, 0, null),
(N'K07_472', N'C', 1, N'K07_475', 0, null, 0, null),
(N'K07_473', N'C', 1, N'K07_475', 0, null, 0, null),
(N'K07_474', N'C', 1, N'K07_475', 0, null, 0, null),
(N'K07_475', N'C', 1, N'K07_501', 1, N'K07_502', 0, null),
(N'K07_476', N'C', 1, N'K07_475', 0, null, 0, null),
(N'K07_480', N'T', 0, null, 0, null, 0, null),
(N'K07_481', N'T', 1, N'K07_485', 0, null, 0, null),
(N'K07_482', N'T', 1, N'K07_485', 0, null, 0, null),
(N'K07_483', N'T', 1, N'K07_485', 0, null, 0, null),
(N'K07_484', N'T', 1, N'K07_485', 0, null, 0, null),
(N'K07_485', N'T', 1, N'K07_500', 0, null, 0, null),
(N'K07_488', N'T', 1, N'K07_500', 0, null, 0, null),
(N'K07_489', N'C', 1, N'K07_501', 1, N'K07_502', 0, null),
(N'K07_490', N'T', 1, N'K07_500', 0, null, 0, null),
(N'K07_491', N'C', 1, N'K07_501', 1, N'K07_502', 0, null),
(N'K07_492', N'C', 1, N'K07_501', 1, N'K07_502', 0, null),
(N'K07_500', N'T', -1, N'K07_600', 0, null, 0, null),
(N'K07_501', N'T', -1, N'K07_601', 0, null, 0, null),
(N'K07_502', N'C', -1, N'K07_510', 0, null, 0, null),
(N'K07_510', N'C', 0, null, 0, null, 0, null),
(N'K07_520', N'T', -1, N'K07_600', 0, null, 0, null),
(N'K07_521', N'C', -1, N'K07_601', 1, N'K07_466', 0, null),
(N'K07_522', N'C', -1, N'K07_601', 1, N'K07_466', 0, null),
(N'K07_530', N'U', 1, N'K07_600', 0, null, 0, null),
(N'K07_531', N'I', 1, N'K07_601', 1, N'K07_591', 0, null),
(N'K07_532', N'C', -1, N'K07_601', 1, N'K07_703', 1, N'K07_502'),
(N'K07_533', N'I', 1, N'K07_601', 1, N'K07_591', 0, null),
(N'K07_540', N'U', 1, N'K07_600', 0, null, 0, null),
(N'K07_541', N'I', 1, N'K07_601', 1, N'K07_591', 0, null),
(N'K07_551', N'I', 1, N'K07_601', 1, N'K07_591', 0, null),
(N'K07_561', N'C', -1, N'K07_601', -1, N'K07_591', 0, null),
(N'K07_571', N'I', 1, N'K07_601', 1, N'K07_591', 0, null),
(N'K07_581', N'C', -1, N'K07_601', -1, N'K07_591', 0, null),
(N'K07_591', N'C', 0, null, 0, null, 0, null),
(N'K07_600', N'U', 1, N'K07_700', 0, null, 0, null),
(N'K07_601', N'C', 1, N'K07_701', 0, null, 0, null),
(N'K07_620', N'T', 1, N'K07_700', 0, null, 0, null),
(N'K07_621', N'C', 1, N'K07_701', 0, null, 0, null),
(N'K07_700', N'U', 0, null, 0, null, 0, null),
(N'K07_703', N'T', 1, N'K07_706', 1, N'K07_704', 0, null),
(N'K07_704', N'T', 1, N'K07_707', 0, null, 0, null),
(N'K07_705', N'T', 1, N'K07_706', 0, null, 0, null),
(N'K07_705CO', N'T', 1, N'K07_705SU', 0, null, 0, null),
(N'K07_705GA', N'T', 1, N'K07_705SU', 0, null, 0, null),
(N'K07_705MS', N'T', 1, N'K07_705SU', 0, null, 0, null),
(N'K07_705OT', N'T', 1, N'K07_705SU', 0, null, 0, null),
(N'K07_705RD', N'T', 1, N'K07_705SU', 0, null, 0, null),
(N'K07_705SU', N'T', 1, N'K07_707', 0, null, 0, null),
(N'K07_706', N'T', 0, null, 0, null, 0, null),
(N'K07_707', N'T', 0, null, 0, null, 0, null),
(N'K07_710', N'U', 1, N'K07_760', 1, N'K07_7100', 1, N'K07_C050'),
(N'K07_7100', N'U', 1, N'K07_O710', 0, null, 0, null),
(N'K07_720', N'U', 1, N'K07_760', 1, N'K07_7200', 1, N'K07_C055'),
(N'K07_7200', N'U', 1, N'K07_O720', 0, null, 0, null),
(N'K07_7300', N'U', 1, N'K07_O730', 0, null, 0, null),
(N'K07_7400', N'U', 1, N'K07_O740', 0, null, 0, null),
(N'K07_7500', N'U', 1, N'K07_O750', 0, null, 0, null),
(N'K07_760', N'U', 1, N'K07_910', 1, N'K07_7600', 1, N'K07_C075'),
(N'K07_7600', N'U', 0, null, 0, null, 0, null),
(N'K07_800', N'U', 1, N'K07_810', 0, null, 0, null),
(N'K07_800N', N'U', 1, N'K07_810N', 0, null, 0, null),
(N'K07_805', N'U', 1, N'K07_810', 0, null, 0, null),
(N'K07_805N', N'U', 1, N'K07_810N', 0, null, 0, null),
(N'K07_810', N'U', 0, null, 0, null, 0, null),
(N'K07_810N', N'U', 0, null, 0, null, 0, null),
(N'K07_815', N'U', 1, N'K07_825', 0, null, 0, null),
(N'K07_815N', N'U', 1, N'K07_825N', 0, null, 0, null),
(N'K07_820', N'U', 1, N'K07_825', 0, null, 0, null),
(N'K07_820N', N'U', 1, N'K07_825N', 0, null, 0, null),
(N'K07_825', N'U', 0, null, 0, null, 0, null),
(N'K07_825N', N'U', 0, null, 0, null, 0, null),
(N'K07_830', N'U', 1, N'K07_840', 0, null, 0, null),
(N'K07_830N', N'U', 1, N'K07_840N', 0, null, 0, null),
(N'K07_835', N'U', 1, N'K07_840', 0, null, 0, null),
(N'K07_835N', N'U', 1, N'K07_840N', 0, null, 0, null),
(N'K07_840', N'U', 0, null, 0, null, 0, null),
(N'K07_840N', N'U', 0, null, 0, null, 0, null),
(N'K07_845', N'U', 1, N'K07_855', 0, null, 0, null),
(N'K07_845N', N'U', 1, N'K07_855N', 0, null, 0, null),
(N'K07_850', N'U', 1, N'K07_855', 0, null, 0, null),
(N'K07_850N', N'U', 1, N'K07_855N', 0, null, 0, null),
(N'K07_855', N'U', 0, null, 0, null, 0, null),
(N'K07_855N', N'U', 0, null, 0, null, 0, null),
(N'K07_860', N'U', 1, N'K07_870', 0, null, 0, null),
(N'K07_860N', N'U', 1, N'K07_870N', 0, null, 0, null),
(N'K07_865', N'U', 1, N'K07_870', 0, null, 0, null),
(N'K07_865N', N'U', 1, N'K07_870N', 0, null, 0, null),
(N'K07_870', N'U', 0, null, 0, null, 0, null),
(N'K07_870N', N'U', 0, null, 0, null, 0, null),
(N'K07_875', N'U', 1, N'K07_885', 0, null, 0, null),
(N'K07_875N', N'U', 1, N'K07_885N', 0, null, 0, null),
(N'K07_880', N'U', 1, N'K07_885', 0, null, 0, null),
(N'K07_880N', N'U', 1, N'K07_885N', 0, null, 0, null),
(N'K07_885', N'U', 0, null, 0, null, 0, null),
(N'K07_885N', N'U', 0, null, 0, null, 0, null),
(N'K07_900', N'U', -1, N'K07_920', 0, null, 0, null),
(N'K07_905', N'U', 1, N'K07_920', 0, null, 0, null),
(N'K07_910', N'U', -1, N'K07_940', 0, null, 0, null),
(N'K07_912', N'U', 1, N'K07_920', 0, null, 0, null),
(N'K07_915', N'U', 1, N'K07_920', 0, null, 0, null),
(N'K07_918', N'U', 1, N'K07_920', 0, null, 0, null),
(N'K07_920', N'U', 1, N'K07_940', 0, null, 0, null),
(N'K07_930', N'U', 1, N'K07_920', 0, null, 0, null),
(N'K07_940', N'U', 0, null, 0, null, 0, null),
(N'K07_C010', N'U', 1, N'K07_C045', 1, N'K07_C130', -1, N'K07_C050'),
(N'K07_C015', N'U', 1, N'K07_C045', 1, N'K07_C135', -1, N'K07_C055'),
(N'K07_C045', N'U', 0, null, 0, null, -1, N'K07_C075'),
(N'K07_C050', N'U', 0, null, 0, null, 0, null),
(N'K07_C055', N'U', 0, null, 0, null, 0, null),
(N'K07_C060', N'U', 0, null, 0, null, 0, null),
(N'K07_C065', N'U', 0, null, 0, null, 0, null),
(N'K07_C070', N'U', 0, null, 0, null, 0, null),
(N'K07_C075', N'U', 0, null, 0, null, 0, null),
(N'K07_C100', N'U', 1, N'K07_C125', 1, N'K07_C130', 0, null),
(N'K07_C105', N'U', 1, N'K07_C125', 1, N'K07_C135', 0, null),
(N'K07_C125', N'U', 0, null, 0, null, 0, null),
(N'K07_C130', N'U', 1, N'K07_C155', 1, N'K07_C630', 0, null),
(N'K07_C135', N'U', 1, N'K07_C155', 1, N'K07_C635', 0, null),
(N'K07_C155', N'U', 0, null, 0, null, 0, null),
(N'K07_C400', N'U', 1, N'K07_C425', 0, null, 0, null),
(N'K07_C405', N'U', 1, N'K07_C425', 0, null, 0, null),
(N'K07_C425', N'U', 0, null, 0, null, 0, null),
(N'K07_C430', N'U', 1, N'K07_C455', 1, N'K07_C580', 1, N'K07_C4300'),
(N'K07_C4300', N'U', 1, N'K07_O430', 0, null, 0, null),
(N'K07_C435', N'U', 1, N'K07_C455', 1, N'K07_C585', 1, N'K07_C4350'),
(N'K07_C4350', N'U', 1, N'K07_O435', 0, null, 0, null),
(N'K07_C4400', N'U', 1, N'K07_O440', 0, null, 0, null),
(N'K07_C4450', N'U', 1, N'K07_O445', 0, null, 0, null),
(N'K07_C4500', N'U', 1, N'K07_O450', 0, null, 0, null),
(N'K07_C455', N'U', 1, N'K07_C4550', 1, N'K07_C890', -1, N'K07_C810'),
(N'K07_C4550', N'U', 0, null, 0, null, 0, null),
(N'K07_C460', N'U', 1, N'K07_C485', -1, N'K07_C490', 1, N'K07_C580'),
(N'K07_C465', N'U', 1, N'K07_C485', -1, N'K07_C495', 1, N'K07_C585'),
(N'K07_C485', N'U', -1, N'K07_C515', 0, null, 0, null),
(N'K07_C490', N'U', 0, null, 0, null, 0, null),
(N'K07_C495', N'U', 0, null, 0, null, 0, null),
(N'K07_C500', N'U', 0, null, 0, null, 0, null),
(N'K07_C505', N'U', 0, null, 0, null, 0, null),
(N'K07_C510', N'U', 0, null, 0, null, 0, null),
(N'K07_C515', N'U', 0, null, 0, null, 0, null),
(N'K07_C520', N'U', 1, N'K07_C545', 1, N'K07_C490', 1, N'K07_C5200'),
(N'K07_C5200', N'U', 1, N'K07_O520', 0, null, 0, null),
(N'K07_C525', N'U', 1, N'K07_C545', 1, N'K07_C495', 1, N'K07_C5250'),
(N'K07_C5250', N'U', 1, N'K07_O525', 0, null, 0, null),
(N'K07_C5300', N'U', 1, N'K07_O530', 0, null, 0, null),
(N'K07_C5350', N'U', 1, N'K07_O535', 0, null, 0, null),
(N'K07_C5400', N'U', 1, N'K07_O540', 0, null, 0, null),
(N'K07_C545', N'U', 0, null, 1, N'K07_C515', 1, N'K07_C5450'),
(N'K07_C5450', N'U', 0, null, 0, null, 0, null),
(N'K07_C550', N'U', 1, N'K07_C575', 1, N'K07_C580', 0, null),
(N'K07_C555', N'U', 1, N'K07_C575', 1, N'K07_C585', 0, null),
(N'K07_C575', N'U', 0, null, 0, null, 0, null),
(N'K07_C580', N'U', 1, N'K07_C599', 1, N'K07_C730', 0, null),
(N'K07_C585', N'U', 1, N'K07_C599', 1, N'K07_C735', 0, null),
(N'K07_C599', N'U', 0, null, 0, null, 0, null),
(N'K07_C600', N'U', 1, N'K07_C625', 1, N'K07_C630', 0, null),
(N'K07_C605', N'U', 1, N'K07_C625', 1, N'K07_C635', 0, null),
(N'K07_C625', N'U', 0, null, 0, null, 0, null),
(N'K07_C630', N'U', 1, N'K07_C655', 0, null, 0, null),
(N'K07_C635', N'U', 1, N'K07_C655', 0, null, 0, null),
(N'K07_C655', N'U', 0, null, 0, null, 0, null),
(N'K07_C700', N'U', 1, N'K07_C725', 1, N'K07_C730', 0, null),
(N'K07_C705', N'U', 1, N'K07_C725', 1, N'K07_C735', 0, null),
(N'K07_C725', N'U', 0, null, 0, null, 0, null),
(N'K07_C730', N'U', 1, N'K07_C755', 0, null, 0, null),
(N'K07_C735', N'U', 1, N'K07_C755', 0, null, 0, null),
(N'K07_C755', N'U', 0, null, 0, null, 0, null),
(N'K07_C800', N'U', -1, N'K07_C890', 0, null, 0, null),
(N'K07_C810', N'U', 0, null, 0, null, 0, null),
(N'K07_C830', N'U', -1, N'K07_C890', 0, null, 0, null),
(N'K07_C870', N'U', -1, N'K07_C890', 0, null, 0, null),
(N'K07_C890', N'U', 0, null, 0, null, 0, null),
(N'K07_I110', N'T', 1, N'K07_I300', 0, null, 0, null),
(N'K07_I120', N'T', 1, N'K07_I300', 0, null, 0, null),
(N'K07_I130', N'T', 1, N'K07_I300', 0, null, 0, null),
(N'K07_I140', N'T', 1, N'K07_I300', 0, null, 0, null),
(N'K07_I150', N'T', 1, N'K07_I300', 0, null, 0, null),
(N'K07_I160', N'T', 1, N'K07_I300', 0, null, 0, null),
(N'K07_I170', N'T', 1, N'K07_I300', 0, null, 0, null),
(N'K07_I180', N'T', 1, N'K07_I300', 0, null, 0, null),
(N'K07_I190', N'T', 1, N'K07_I300', 0, null, 0, null),
(N'K07_I200', N'T', 1, N'K07_I300', 0, null, 0, null),
(N'K07_I290', N'T', 1, N'K07_I300', 0, null, 0, null),
(N'K07_I295', N'T', 1, N'K07_I300', 0, null, 0, null),
(N'K07_I300', N'T', 0, null, 0, null, 0, null),
(N'K07_I310', N'C', 1, N'K07_I400', 0, null, 0, null),
(N'K07_I320', N'C', 1, N'K07_I400', 0, null, 0, null),
(N'K07_I400', N'C', 0, null, 0, null, 0, null),
(N'K07_O091', N'U', -1, N'K07_O251', 0, null, 0, null),
(N'K07_O100', N'U', 1, N'K07_O200', 0, null, 0, null),
(N'K07_O101', N'U', 1, N'K07_O202', 0, null, 0, null),
(N'K07_O115', N'U', 1, N'K07_O200', 0, null, 0, null),
(N'K07_O116', N'U', 1, N'K07_O200', 0, null, 0, null),
(N'K07_O117', N'U', 1, N'K07_O200', 0, null, 0, null),
(N'K07_O118', N'U', 1, N'K07_O200', 0, null, 0, null),
(N'K07_O120', N'U', 1, N'K07_O202', 0, null, 0, null),
(N'K07_O200', N'U', 1, N'K07_O250', 0, null, 0, null),
(N'K07_O202', N'U', 1, N'K07_O251', 0, null, 0, null),
(N'K07_O250', N'U', 1, N'K07_O300', 0, null, 0, null),
(N'K07_O251', N'U', 1, N'K07_O301', 0, null, 0, null),
(N'K07_O270', N'T', -1, N'K07_O300', 0, null, 0, null),
(N'K07_O271', N'T', -1, N'K07_O301', 0, null, 0, null),
(N'K07_O280', N'T', -1, N'K07_O300', 0, null, 0, null),
(N'K07_O281', N'T', -1, N'K07_O301', 0, null, 0, null),
(N'K07_O300', N'U', 0, null, 0, null, 0, null),
(N'K07_O301', N'U', 0, null, 0, null, 0, null),
(N'K07_O430', N'U', 1, N'K07_O455', 0, null, 0, null),
(N'K07_O435', N'U', 1, N'K07_O455', 0, null, 0, null),
(N'K07_O440', N'U', 1, N'K07_O455', 0, null, 0, null),
(N'K07_O445', N'U', 1, N'K07_O455', 0, null, 0, null),
(N'K07_O450', N'U', 1, N'K07_O455', 0, null, 0, null),
(N'K07_O455', N'U', 0, null, 0, null, 0, null),
(N'K07_O520', N'U', 1, N'K07_O545', 0, null, 0, null),
(N'K07_O525', N'U', 1, N'K07_O545', 0, null, 0, null),
(N'K07_O530', N'U', 1, N'K07_O545', 0, null, 0, null),
(N'K07_O535', N'U', 1, N'K07_O545', 0, null, 0, null),
(N'K07_O540', N'U', 1, N'K07_O545', 0, null, 0, null),
(N'K07_O545', N'U', 0, null, 0, null, 0, null),
(N'K07_O710', N'U', 1, N'K07_O760', 0, null, 0, null),
(N'K07_O720', N'U', 1, N'K07_O760', 0, null, 0, null),
(N'K07_O730', N'U', 1, N'K07_O760', 0, null, 0, null),
(N'K07_O740', N'U', 1, N'K07_O760', 0, null, 0, null),
(N'K07_O750', N'U', 1, N'K07_O760', 0, null, 0, null),
(N'K07_O760', N'U', 0, null, 0, null, 0, null),
(N'K07_P091', N'U', -1, N'K07_P251', 1, N'K07_O091', 0, null),
(N'K07_P091US', N'U', -1, N'K07_P251US', 0, null, 0, null),
(N'K07_P101', N'U', 1, N'K07_P1010', 1, N'K07_PP101', 0, null),
(N'K07_P115', N'U', 1, N'K07_O115', 1, N'K07_P200', 0, null),
(N'K07_P116', N'U', 1, N'K07_O116', 1, N'K07_P200', 0, null),
(N'K07_P117', N'U', 1, N'K07_O117', 1, N'K07_P200', 0, null),
(N'K07_P118', N'U', 1, N'K07_O118', 1, N'K07_P200', 0, null),
(N'K07_P120', N'U', 1, N'K07_O120', 1, N'K07_P202', 0, null),
(N'K07_P120US', N'U', 0, null, 1, N'K07_P202US', 0, null),
(N'K07_P200', N'U', 1, N'K07_P250', 0, null, 0, null),
(N'K07_P202', N'U', 1, N'K07_P251', 0, null, 0, null),
(N'K07_P202US', N'U', 1, N'K07_P251US', 0, null, 0, null),
(N'K07_P250', N'U', 1, N'K07_P300', 0, null, 0, null),
(N'K07_P251', N'U', 1, N'K07_P301', 0, null, 0, null),
(N'K07_P251US', N'U', 1, N'K07_P301US', 0, null, 0, null),
(N'K07_P270', N'T', -1, N'K07_P300', 1, N'K07_O270', 0, null),
(N'K07_P271', N'T', -1, N'K07_P301', 1, N'K07_O271', 0, null),
(N'K07_P271US', N'T', -1, N'K07_P301US', 0, null, 0, null),
(N'K07_P280', N'T', -1, N'K07_P300', 1, N'K07_O280', 0, null),
(N'K07_P281', N'T', -1, N'K07_P301', 1, N'K07_O281', 0, null),
(N'K07_P281US', N'T', -1, N'K07_P301US', 0, null, 0, null),
(N'K07_P300', N'U', 0, null, 0, null, 0, null),
(N'K07_P301', N'U', 0, null, 0, null, 0, null),
(N'K07_P301US', N'U', 0, null, 0, null, 0, null),
(N'K07_P430', N'U', 1, N'K07_O430', 1, N'K07_P455', 0, null),
(N'K07_P435', N'U', 1, N'K07_O435', 1, N'K07_P455', 0, null),
(N'K07_P440', N'U', 1, N'K07_O440', 1, N'K07_P455', 0, null),
(N'K07_P445', N'U', 1, N'K07_O445', 1, N'K07_P455', 0, null),
(N'K07_P450', N'U', 1, N'K07_O450', 1, N'K07_P455', 0, null),
(N'K07_P455', N'U', 0, null, 0, null, 0, null),
(N'K07_P489US', N'T', 0, null, 0, null, 0, null),
(N'K07_P520', N'U', 1, N'K07_O520', 1, N'K07_P545', 0, null),
(N'K07_P521US', N'T', 0, null, 0, null, 0, null),
(N'K07_P525', N'U', 1, N'K07_O525', 1, N'K07_P545', 0, null),
(N'K07_P530', N'U', 1, N'K07_O530', 1, N'K07_P545', 0, null),
(N'K07_P535', N'U', 1, N'K07_O535', 1, N'K07_P545', 0, null),
(N'K07_P540', N'U', 1, N'K07_O540', 1, N'K07_P545', 0, null),
(N'K07_P545', N'U', 0, null, 0, null, 0, null),
(N'K07_P710', N'U', 1, N'K07_O710', 1, N'K07_P760', 0, null),
(N'K07_P710US', N'U', 1, N'K07_P760US', 0, null, 0, null),
(N'K07_P720', N'U', 1, N'K07_O720', 1, N'K07_P760', 0, null),
(N'K07_P720US', N'U', 1, N'K07_P760US', 0, null, 0, null),
(N'K07_P730', N'U', 1, N'K07_O730', 1, N'K07_P760', 0, null),
(N'K07_P740', N'U', 1, N'K07_O740', 1, N'K07_P760', 0, null),
(N'K07_P750', N'U', 1, N'K07_O750', 1, N'K07_P760', 0, null),
(N'K07_P760', N'U', 0, null, 0, null, 0, null),
(N'K07_P760US', N'U', 0, null, 0, null, 0, null),
(N'K07_PA101', N'U', -1, N'K07_PP101', 0, null, 0, null),
(N'K07_PP101', N'U', 0, null, 0, null, 0, null);
My attempt now was to get the nested hierarchy with multiple joins. But this doesn't seem to do the trick.
with Hierarchy(AccountNumber, ParentsPaths)
as (
select ad1.AccountNumber,
cast(N'' as nvarchar(max))
from #AccountDefinitions as ad1
where ad1.SumAccount1 is null
union all
select ad2.AccountNumber,
cast(case when h.ParentsPaths = N''
then (cast(ad2.AccountNumber as nvarchar(max)))
else (h.ParentsPaths + '.'
+ cast(ad2.AccountNumber as nvarchar(max)))
end as nvarchar(max))
from #AccountDefinitions as ad2
inner join Hierarchy as h
on h.AccountNumber = ad2.SumAccount1
or h.AccountNumber = ad2.SumAccount2
or h.AccountNumber = ad2.SumAccount3
where ad2.SumAccount1 is not null
)
select *
from Hierarchy
order by len(ParentsPaths) desc
option (maxrecursion 0)
In the end I would need to get a list of all accounts and all intermediary steps where they were added to, so that I can join the resulting table with all financial bookings and get all values summed up together.
Example: for K07_1000 there is only one possible path being K07_1000 adds to K07_O100, which adds up to K07_O200 and finally ends in K07_O250. In order to be able to join this, I would need the result:
Original | Mapped
-------------------
K07_1000 | K07_1000 <-- preserve the original posting
K07_1000 | K07_O100 <-- the one and only path
K07_1000 | K07_O200
K07_1000 | K07_O250
K07_1000 | K07_O300
If I join this table on the booking table then I would get for one booking to account K07_1000 four resulting bookings: the original and three more (which would add to the summed up parent accounts).
For account K07_1010 it would be more difficult as it can take four different paths.
Original | Mapped
-------------------
K07_1010 | K07_1010 <-- the original posting
K07_1010 | K07_100 <-- first possible path
K07_1010 | K07_1000
K07_1010 | K07_O100
K07_1010 | K07_O200
K07_1010 | K07_O250
K07_1010 | K07_O300
K07_1010 | K07_101P <-- second possible path
K07_1010 | K07_O101
K07_1010 | K07_O202
K07_1010 | K07_O251
K07_1010 | K07_O301
K07_1010 | K07_C130 <-- third possible path
K07_1010 | K07_C155 <- third path with sub path 1
K07_1010 | K07_C630 <- third path with sub path 2
K07_1010 | K07_C655 <- third path with sub path 2
I hope this makes sense and someone can help.
Ralph, try this. I think it is working:
with Hierarchy
as (
select ad1.AccountNumber,
SumAccount1,
SumAccount2,
SumAccount3
from #AccountDefinitions as ad1
union all
select h.AccountNumber,
ad2.SumAccount1,
ad2.SumAccount2,
ad2.SumAccount3
from #AccountDefinitions as ad2
inner join Hierarchy as h
on h.SumAccount1 = ad2.AccountNumber
or h.SumAccount2 = ad2.AccountNumber
or h.SumAccount3 = ad2.AccountNumber
),
cter
as(
SELECT AccountNumber, AccountNumber AS SumAccount FROM #AccountDefinitions
UNION
select AccountNumber,
SumAccount1 as SumAccount
from Hierarchy
where SumAccount1 is not null
union
select AccountNumber,
SumAccount2 as SumAccount
from Hierarchy
where SumAccount2 is not null
union
select AccountNumber,
SumAccount3 as SumAccount
from Hierarchy
where SumAccount3 is not null)
select * from cter
WHERE AccountNumber = 'K07_1010'
option (maxrecursion 0)

node mongodb not keeping zero-filled data

I'm following this guide as a basis for keeping analytic data:
pre-aggregated-reports
My code is generating an update object {} that looks as follows (actual example):
{ '$inc': {},
'$set':
{ 'hourly.9': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'minute.9.51': { total: 0, global: 0 },
'minute.9.52': { total: 0, global: 0 },
'minute.9.53': { total: 0, global: 0 },
'minute.9.54': { total: 0, global: 0 },
'minute.9.55': { total: 0, global: 0 },
'minute.9.56': { total: 0, global: 0 },
'minute.9.57': { total: 0, global: 0 },
'minute.9.58': { total: 0, global: 0 },
'minute.9.59': { total: 0, global: 0 },
'hourly.10': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.11': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.12': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.13': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.14': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.15': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.16': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.17': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.18': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.19': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.20': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.21': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.22': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] },
'hourly.23': { total: 0, global: 0, trends: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] } },
'$addToSet': {}
}
And the update code looks like this:
daily.update(query, update, {upsert:true, safe:true}, function(err, result) {
if(err) {
console.log("error writing update. " + err);
throw err;
}
});
query is a simple object {'_id': someid}, the update is the object listed above. The document is created but none of the zero filled fields are stored.
{
"_id" : "20140804/example.com/13567219",
"metadata" : {
"date" : ISODate("2014-08-04T04:00:00Z"),
"host" : "example.com",
"id" : "13567219"
}
}
However if I run the same upsert in the mongo console, the record is created/updated with all the zero filled fields in place:
"13" : {
"total" : 0,
"global" : 0,
"trends" : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
"14" : {
"total" : 0,
"global" : 0,
"trends" : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
...
...
"22" : {
"total" : 0,
"global" : 0,
"trends" : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
"23" : {
"total" : 0,
"global" : 0,
"trends" : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
"9" : {
"total" : 0,
"global" : 0,
"trends" : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
}
},
"metadata" : {
"date" : ISODate("2014-08-04T04:00:00Z"),
"host" : "example.com",
"id" : "13560169"
},
"minute" : {
"9" : {
"51" : {
"total" : 0,
"global" : 0
},
"52" : {
"total" : 0,
"global" : 0
},
"53" : {
"total" : 0,
"global" : 0
},
"54" : {
"total" : 0,
"global" : 0
},
"55" : {
"total" : 0,
"global" : 0
},
"56" : {
"total" : 0,
"global" : 0
},
"57" : {
"total" : 0,
"global" : 0
},
"58" : {
"total" : 0,
"global" : 0
},
"59" : {
"total" : 0,
"global" : 0
}
}
}
Is there a setting that I'm missing on the native driver to make it force populating the data?
There were/are no issues on versions of Mongo or the native driver. The issue was PLBKAC - Problem Lies Between Keyboard And Chair.
Within my code (running on node) I had the update outside of the lookup of a document. So the updates were taking place before the document returned from the DB...all that lovely async goodness.
Moving the update method inside of the document lookup fixed the issue of the update not pre-allocating the document.
I had this:
...
... code that updates the update object with $inc's, and $addToSets...
...
daily.find({'_id' : id}, {}, {'limit': 1}).toArray(function(err, doc) {
...
...
});
daily.update(query, update, {upsert:true, safe:true}, function(err, result) {
if(err) {
console.log("error writing update. " + err);
throw err;
}
});
and moved the daily.update inside of the daily.find...
daily.find({'_id' : id}, {}, {'limit': 1}).toArray(function(err, doc) {
...
...
daily.update(query, update, {upsert:true, safe:true}, function(err, result) {
if(err) {
console.log("error writing update. " + err);
throw err;
}
});
});
So future people, make sure all of your edits to the update object are async safe :)

Probit model in winbugs

I conducted an analysis using a logit model and now want to do the same using a probit model. Can anyone please turn this winbugs logit model into a winbugs probit model?
model
{
for (i in 1:n) {
# Linear regression on logit
logit(p[i]) <- alpha + b.sex*sex[i] + b.age*age[i]
# Likelihood function for each data point
frac[i] ~ dbern(p[i])
}
alpha ~ dnorm(0.0,1.0E-4) # Prior for intercept
b.sex ~ dnorm(0.0,1.0E-4) # Prior for slope of sex
b.age ~ dnorm(0.0,1.0E-4) # Prior for slope of age
}
Data
list(sex=c(1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1,
1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0,
0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1,
0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1),
age= c(69, 57, 61, 60, 69, 74, 63, 68, 64, 53, 60, 58, 79, 56, 53, 74, 56, 76, 72,
56, 66, 52, 77, 70, 69, 76, 72, 53, 69, 59, 73, 77, 55, 77, 68, 62, 56, 68, 70, 60,
65, 55, 64, 75, 60, 67, 61, 69, 75, 68, 72, 71, 54, 52, 54, 50, 75, 59, 65, 60, 60,
57, 51, 51, 63, 57, 80, 52, 65, 72, 80, 73, 76, 79, 66, 51, 76, 75, 66, 75, 78, 70,
67, 51, 70, 71, 71, 74, 74, 60, 58, 55, 61, 65, 52, 68, 75, 52, 53, 70),
frac=c(1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0,
1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1,
1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1,
1, 0, 1, 1, 0, 0, 1, 0, 0, 1),
n=100)
Initial Values
list(alpha=0, b.sex=1, b.age=1)
WinBUGS accepts multiple types of link functions (see page 15 in the WinBUGS manual). For a probit model, change your linear regression equation to:
probit(p[i]) <- alpha + b.sex*sex[i] + b.age*age[i]
I would recommend you center the age variable, otherwise you may well run into some convergence problems, so something like:
probit(p[i]) <- alpha + b.sex*sex[i] + b.age*(age[i] - mean(age[]))
Alternatively, for a probit model (if the probit functions gives you some trap errors) you could use the phi standard normal cdf function:
p[i] <- phi(alpha + b.sex*sex[i] + b.age*(age[i] - mean(age[])))