-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
% Guesses_double, written by Michael Hatcher ([email protected]). Any errors are my own. | ||
% Double spells at the bound. Start date p0, length spell 1 is z0-1, length spell 2 is z1-1. | ||
|
||
%%T_guess = 10; | ||
V_mat = []; | ||
|
||
for p0 = 1:T_guess-3 | ||
|
||
for z0 = 1:T_guess-3 | ||
|
||
for z1 = 1:T_guess-1-(p0+z0) | ||
|
||
A_mat = ones(T_guess); | ||
|
||
for index=1:T_guess-(p0 + z0 + z1) | ||
|
||
A_mat(p0:p0+z0-1,index) = 0; | ||
A_mat(p0+z0+index:p0+z0+z1-1+index,index) = 0; | ||
|
||
end | ||
|
||
V_mat = [V_mat A_mat]; | ||
s0=sum(V_mat,1); V_mat = V_mat(:,s0 < T_guess); %Remove columns of all ones | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
%Guesses_master, written by Michael Hatcher ([email protected]). Any errors are my own. | ||
|
||
V_0 = tril(ones(T_guess)); %Spells starting from date 1. Note: V_0(:,1) --> slack in all periods. | ||
V_mat = []; Message_1 = []; Message_2 = []; | ||
|
||
run Guesses_single, V_1 = V_mat; V_mat = V_1; %Single spells at the bound | ||
run Guesses_double, V_2 = [V_1 V_mat]; V_mat = V_2; %Uncomment as necessary | ||
%%n_loop_l = [1:2]; run Guesses_triple_loop, V_3 = [V_2 V_mat]; V_mat = V_3; %Uncomment as necessary | ||
|
||
V_mat = unique(V_mat.', 'rows').'; | ||
if isempty(V_mat) | ||
ind_stack(:,1:T_guess) = V_0; | ||
elseif size(V_mat,2) >= N_guess-T_guess | ||
ind_stack = [V_0 V_mat(:,1:N_guess-T_guess)]; | ||
Message_1 = 1; d0 = size([V_0 V_mat],2); | ||
else | ||
ind_stack = [V_0 V_mat ind_stack(:,size(V_mat,2)+T_guess+1:end)]; | ||
Message_2 = 1; d0 = size([V_0 V_mat],2); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
%Guesses_master_2, written by Michael Hatcher ([email protected]). Any errors are my own. | ||
|
||
V_0 = tril(ones(T_guess)); %Spells starting from date 1, V_0(:,1) --> slack in all periods | ||
V_mat = []; Message_1 = []; Message_2 = []; | ||
|
||
run Guesses_single, V_1 = V_mat; V_mat = V_1; %Single spells at the bound | ||
run Guesses_double, V_2 = [V_1 V_mat]; V_mat = V_2; %Double spells at the bound | ||
n_loop_l = [1:2]; run Guesses_triple_loop, V_3 = [V_2 V_mat]; V_mat = V_3; %n_loop_l set by user | ||
|
||
V_mat = unique(V_mat.', 'rows').'; | ||
if isempty(V_mat) | ||
ind_stack(:,1:T_guess) = V_0; | ||
elseif size(V_mat,2) >= N_guess-T_guess | ||
ind_stack = [V_0 V_mat(:,1:N_guess-T_guess)]; | ||
Message_1 = 1; d0 = size([V_0 V_mat],2); | ||
else | ||
ind_stack = [V_0 V_mat ind_stack(:,size(V_mat,2)+T_guess+1:end)]; | ||
Message_2 = 1; d0 = size([V_0 V_mat],2); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
% Guesses_single, written by Michael Hatcher ([email protected]). Any errors are my own. | ||
% Single spells at the bound, date 2 onwards. Spell length controlled by index. Start date is p0. | ||
|
||
%%T_guess = 10; | ||
V_mat = []; | ||
|
||
for p0 = 2:T_guess-1 | ||
A_mat = ones(T_guess); | ||
|
||
for index=1:T_guess-p0 | ||
A_mat(p0:p0+index-1,index) = 0; | ||
end | ||
|
||
V_mat = [V_mat A_mat]; | ||
s0=sum(V_mat,1); V_mat = V_mat(:,s0 < T_guess); %Remove columns of all ones | ||
|
||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
% Guesses_triple_l, written by Michael Hatcher ([email protected]). Any errors are my own. | ||
% Triple spells at the bound ending with a 3-spell. Start date p0, length spell 1 is z0-1; length spell 2 is z1-1; spell 3, length l. | ||
% Note that n_loop_l is set in a separate loop file in Guesses_master_FG (needs to be commented in). | ||
|
||
%%T_guess = 10; | ||
V_mat = []; | ||
|
||
for l=n_loop_l | ||
|
||
%Loop over length of final spell | ||
|
||
for p0 = 1:T_guess-5 | ||
|
||
for z0 = 1:T_guess-5 | ||
|
||
for z1 = 1:T_guess-3-(p0+z0) | ||
|
||
for gap = 1:T_guess-2-(p0+z0+z1)-(l-1) | ||
|
||
A_mat = ones(T_guess); | ||
|
||
for index=1:T_guess-(p0+z0+z1+gap)-3 | ||
A_mat(p0:p0+z0-1,index) = 0; | ||
A_mat(p0+z0+index:p0+z0+z1-1+index,index) = 0; | ||
A_mat(p0+z0+z1+gap+index:p0+z0+z1+gap+index+l-1,index) = 0; | ||
end | ||
|
||
V_mat = [V_mat A_mat]; | ||
s0=sum(V_mat,1); V_mat = V_mat(:,s0 < T_guess); %Remove columns of all ones | ||
|
||
end | ||
|
||
|
||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
|
||
|
||
|
||
|