Archived
1
0

Consider a consistent number of tests for each round

This commit is contained in:
Jip J. Dekker 2021-12-22 13:09:17 +11:00
parent ad9e85aa2d
commit 5e8d024cff
No known key found for this signature in database
GPG Key ID: 517DF4A00618C9C3
4 changed files with 33 additions and 111 deletions

View File

@ -14,19 +14,16 @@ array[Patient] of var Horizon: critical_sample = [ min([i | i in -5..1 where sam
% --- Decisions --- % --- Decisions ---
% First round: % First round:
var Horizon: first_sample; % When to start sampling on the first round var Horizon: first_sample; % When to start sampling on the first round
var 2..length(Horizon): first_num_samples; % How many samples to take on the first round var 2..length(Horizon): num_samples; % How many samples to take on the first round
% Second round: % (Assumption: If the levels were to high in all samples during the first round, then we sample `num_samples` ending with the `first_sample`.
var 2..length(Horizon): second_num_samples; % How many samples to take on the second round % If the levels were to low in all samples during the first round, then we sample `num_samples` from `first_sample + num_samples`.)
% (Assumption: If the levels were to high in all samples during the first round, then we sample `second_num_samples` ending with the `first_sample`.
% If the levels were to low in all samples during the first round, then we sample `second_num_samples` from `first_sample + first_num_samples`.)
% --- Decision Consequences --- % --- Decision Consequences ---
% For each patient: will their DLMO be detected on the first round? % For each patient: will their DLMO be detected on the first round?
array[Patient] of var bool: first_detected = [ array[Patient] of var bool: first_detected = [
critical_sample[pt] >= first_sample /\ critical_sample[pt] + 1 <= first_sample + (first_num_samples - 1) critical_sample[pt] >= first_sample /\ critical_sample[pt] + 1 <= first_sample + (num_samples - 1)
| pt in Patient | pt in Patient
]; ];
@ -37,19 +34,19 @@ array[Patient] of var bool: first_detected = [
constraint forall (pt in Patient) ( constraint forall (pt in Patient) (
first_detected[pt] first_detected[pt]
% Before first round % Before first round
\/ (critical_sample[pt] >= first_sample - (second_num_samples - 1) /\ critical_sample[pt] + 1 <= first_sample) \/ (critical_sample[pt] >= first_sample - (num_samples - 1) /\ critical_sample[pt] + 1 <= first_sample)
% After first round % After first round
\/ (critical_sample[pt] >= first_sample + (first_num_samples - 1) /\ critical_sample[pt] + 1 <= first_sample + (first_num_samples - 1) + (second_num_samples - 1)) \/ (critical_sample[pt] >= first_sample + (num_samples - 1) /\ critical_sample[pt] + 1 <= first_sample + (num_samples - 1) + (num_samples - 1))
); );
% --- Objective --- % --- Objective ---
% solve minimize % solve minimize total_tests;
% Pareto Front objectives % Pareto Front objectives
var int: total_tests ::output = var int: total_tests ::output =
% Number of tests on first round % Number of tests on first round
(length(Patient) * first_num_samples) (length(Patient) * num_samples)
% Number of test on second round % Number of test on second round
+ (count(pt in Patient) (not first_detected[pt]) * second_num_samples); + (count(pt in Patient) (not first_detected[pt]) * num_samples);
var int: total_not_detected ::output = length(Patient) - count(first_detected); var int: total_not_detected ::output = length(Patient) - count(first_detected);
@ -57,14 +54,13 @@ var int: total_not_detected ::output = length(Patient) - count(first_detected);
output ["First Round:\n"] output ["First Round:\n"]
++ [format(2, i) ++ " " | i in Horizon] ++ ["\n |"] ++ [format(2, i) ++ " " | i in Horizon] ++ ["\n |"]
++ [if i in fix(first_sample)..fix(first_sample + (first_num_samples-1) - 1) then "====|" else "----|" endif | i in -5..1] ++ [if i in fix(first_sample)..fix(first_sample + (num_samples-1) - 1) then "====|" else "----|" endif | i in -5..1]
++ ["\n\nFirst try (%): \(count(first_detected) / length(Patient) * 100)\n"] ++ ["\n\nFirst try (%): \(count(first_detected) / length(Patient) * 100)\n"]
++ ["\n\nSecond Round:\n"] ++ ["\n\nSecond Round:\n"]
++ [format(2, i) ++ " " | i in Horizon] ++ ["\n |"] ++ [format(2, i) ++ " " | i in Horizon] ++ ["\n |"]
++ [if i in fix(first_sample-(second_num_samples-1))..fix(first_sample-1) \/ i in fix(first_sample + (first_num_samples - 1))..fix(first_sample + (first_num_samples - 1) + (second_num_samples - 1) - 1) then "====|" else "----|" endif | i in -5..1] ++ [if i in fix(first_sample-(num_samples-1))..fix(first_sample-1) \/ i in fix(first_sample + (num_samples - 1))..fix(first_sample + (num_samples - 1) + (num_samples - 1) - 1) then "====|" else "----|" endif | i in -5..1]
++ ["\n\nTotal number of tests = \(total_tests);"] ++ ["\n\nTotal number of tests = \(total_tests);"]
++ ["\n\n\nfirst_sample = \(first_sample);\n"] ++ ["\n\n\nfirst_sample = \(first_sample);\n"]
++ ["first_num_samples = \(first_num_samples);\n"] ++ ["num_samples = \(num_samples);\n"]
++ ["second_num_samples = \(second_num_samples);"];

View File

@ -1,55 +0,0 @@
First Round:
-5 -4 -3 -2 -1 0 1 2
|----|----|====|====|----|----|----|
First try (%): 54.94505494505495
Second Round:
-5 -4 -3 -2 -1 0 1 2
|====|====|----|----|====|====|====|
Total number of tests = 1038;
first_sample = -3;
first_num_samples = 3;
second_num_samples = 6;
----------
First Round:
-5 -4 -3 -2 -1 0 1 2
|----|----|====|====|----|----|----|
First try (%): 54.94505494505495
Second Round:
-5 -4 -3 -2 -1 0 1 2
|====|====|----|----|====|====|====|
Total number of tests = 874;
first_sample = -3;
first_num_samples = 3;
second_num_samples = 4;
----------
First Round:
-5 -4 -3 -2 -1 0 1 2
|----|----|====|====|----|----|----|
First try (%): 54.94505494505495
Second Round:
-5 -4 -3 -2 -1 0 1 2
|====|====|----|----|====|====|----|
Total number of tests = 792;
first_sample = -3;
first_num_samples = 3;
second_num_samples = 3;
----------
==========

View File

@ -44,8 +44,7 @@ if __name__ == "__main__":
str(sol["total_tests"]), str(sol["total_tests"]),
str(sol["total_not_detected"]), str(sol["total_not_detected"]),
str(sol["first_sample"]), str(sol["first_sample"]),
str(sol["first_num_samples"]), str(sol["num_samples"]),
str(sol["second_num_samples"]),
] ]
) )
) )

View File

@ -1,9 +1,8 @@
792,82,-3,3,3 792,82,-3,3
845,39,-4,4,3 884,39,-4,4
958,24,-4,5,2 1025,23,-5,5
979,23,-5,5,3 1140,8,-5,6
1108,8,-5,6,2 1274,0,-5,7
1274,0,-5,7,8
---------------------------------------------------- ----------------------------------------------------
First Round: First Round:
-5 -4 -3 -2 -1 0 1 2 -5 -4 -3 -2 -1 0 1 2
@ -20,8 +19,8 @@ Total number of tests = 792;
first_sample = -3; first_sample = -3;
first_num_samples = 3; num_samples = 3;
second_num_samples = 3;
First Round: First Round:
-5 -4 -3 -2 -1 0 1 2 -5 -4 -3 -2 -1 0 1 2
|----|====|====|====|----|----|----| |----|====|====|====|----|----|----|
@ -31,31 +30,14 @@ First try (%): 78.57142857142857
Second Round: Second Round:
-5 -4 -3 -2 -1 0 1 2 -5 -4 -3 -2 -1 0 1 2
|====|----|----|----|====|====|----| |====|----|----|----|====|====|====|
Total number of tests = 845; Total number of tests = 884;
first_sample = -4; first_sample = -4;
first_num_samples = 4; num_samples = 4;
second_num_samples = 3;
First Round:
-5 -4 -3 -2 -1 0 1 2
|----|====|====|====|====|----|----|
First try (%): 86.81318681318682
Second Round:
-5 -4 -3 -2 -1 0 1 2
|====|----|----|----|----|====|----|
Total number of tests = 958;
first_sample = -4;
first_num_samples = 5;
second_num_samples = 2;
First Round: First Round:
-5 -4 -3 -2 -1 0 1 2 -5 -4 -3 -2 -1 0 1 2
|====|====|====|====|----|----|----| |====|====|====|====|----|----|----|
@ -65,14 +47,14 @@ First try (%): 87.36263736263736
Second Round: Second Round:
-5 -4 -3 -2 -1 0 1 2 -5 -4 -3 -2 -1 0 1 2
|----|----|----|----|====|====|----| |----|----|----|----|====|====|====|
Total number of tests = 979; Total number of tests = 1025;
first_sample = -5; first_sample = -5;
first_num_samples = 5; num_samples = 5;
second_num_samples = 3;
First Round: First Round:
-5 -4 -3 -2 -1 0 1 2 -5 -4 -3 -2 -1 0 1 2
|====|====|====|====|====|----|----| |====|====|====|====|====|----|----|
@ -82,14 +64,14 @@ First try (%): 95.60439560439561
Second Round: Second Round:
-5 -4 -3 -2 -1 0 1 2 -5 -4 -3 -2 -1 0 1 2
|----|----|----|----|----|====|----| |----|----|----|----|----|====|====|
Total number of tests = 1108; Total number of tests = 1140;
first_sample = -5; first_sample = -5;
first_num_samples = 6; num_samples = 6;
second_num_samples = 2;
First Round: First Round:
-5 -4 -3 -2 -1 0 1 2 -5 -4 -3 -2 -1 0 1 2
|====|====|====|====|====|====|----| |====|====|====|====|====|====|----|
@ -105,5 +87,5 @@ Total number of tests = 1274;
first_sample = -5; first_sample = -5;
first_num_samples = 7; num_samples = 7;
second_num_samples = 8;