Consider a consistent number of tests for each round
This commit is contained in:
parent
ad9e85aa2d
commit
5e8d024cff
28
dlmo.mzn
28
dlmo.mzn
@ -14,19 +14,16 @@ array[Patient] of var Horizon: critical_sample = [ min([i | i in -5..1 where sam
|
||||
% --- Decisions ---
|
||||
% 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:
|
||||
var 2..length(Horizon): second_num_samples; % How many samples to take on the second round
|
||||
|
||||
% (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`.)
|
||||
% (Assumption: If the levels were to high in all samples during the first round, then we sample `num_samples` ending with the `first_sample`.
|
||||
% If the levels were to low in all samples during the first round, then we sample `num_samples` from `first_sample + num_samples`.)
|
||||
|
||||
% --- Decision Consequences ---
|
||||
|
||||
% For each patient: will their DLMO be detected on the first round?
|
||||
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
|
||||
];
|
||||
|
||||
@ -37,19 +34,19 @@ array[Patient] of var bool: first_detected = [
|
||||
constraint forall (pt in Patient) (
|
||||
first_detected[pt]
|
||||
% 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
|
||||
\/ (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 ---
|
||||
% solve minimize
|
||||
% solve minimize total_tests;
|
||||
% Pareto Front objectives
|
||||
var int: total_tests ::output =
|
||||
% Number of tests on first round
|
||||
(length(Patient) * first_num_samples)
|
||||
(length(Patient) * num_samples)
|
||||
% 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);
|
||||
|
||||
@ -57,14 +54,13 @@ var int: total_not_detected ::output = length(Patient) - count(first_detected);
|
||||
|
||||
output ["First Round:\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\nSecond Round:\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\n\nfirst_sample = \(first_sample);\n"]
|
||||
++ ["first_num_samples = \(first_num_samples);\n"]
|
||||
++ ["second_num_samples = \(second_num_samples);"];
|
||||
++ ["num_samples = \(num_samples);\n"]
|
||||
|
55
output.txt
55
output.txt
@ -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;
|
||||
----------
|
||||
==========
|
@ -44,8 +44,7 @@ if __name__ == "__main__":
|
||||
str(sol["total_tests"]),
|
||||
str(sol["total_not_detected"]),
|
||||
str(sol["first_sample"]),
|
||||
str(sol["first_num_samples"]),
|
||||
str(sol["second_num_samples"]),
|
||||
str(sol["num_samples"]),
|
||||
]
|
||||
)
|
||||
)
|
||||
|
@ -1,9 +1,8 @@
|
||||
792,82,-3,3,3
|
||||
845,39,-4,4,3
|
||||
958,24,-4,5,2
|
||||
979,23,-5,5,3
|
||||
1108,8,-5,6,2
|
||||
1274,0,-5,7,8
|
||||
792,82,-3,3
|
||||
884,39,-4,4
|
||||
1025,23,-5,5
|
||||
1140,8,-5,6
|
||||
1274,0,-5,7
|
||||
----------------------------------------------------
|
||||
First Round:
|
||||
-5 -4 -3 -2 -1 0 1 2
|
||||
@ -20,8 +19,8 @@ Total number of tests = 792;
|
||||
|
||||
|
||||
first_sample = -3;
|
||||
first_num_samples = 3;
|
||||
second_num_samples = 3;
|
||||
num_samples = 3;
|
||||
|
||||
First Round:
|
||||
-5 -4 -3 -2 -1 0 1 2
|
||||
|----|====|====|====|----|----|----|
|
||||
@ -31,31 +30,14 @@ First try (%): 78.57142857142857
|
||||
|
||||
Second Round:
|
||||
-5 -4 -3 -2 -1 0 1 2
|
||||
|====|----|----|----|====|====|----|
|
||||
|====|----|----|----|====|====|====|
|
||||
|
||||
Total number of tests = 845;
|
||||
Total number of tests = 884;
|
||||
|
||||
|
||||
first_sample = -4;
|
||||
first_num_samples = 4;
|
||||
second_num_samples = 3;
|
||||
First Round:
|
||||
-5 -4 -3 -2 -1 0 1 2
|
||||
|----|====|====|====|====|----|----|
|
||||
num_samples = 4;
|
||||
|
||||
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:
|
||||
-5 -4 -3 -2 -1 0 1 2
|
||||
|====|====|====|====|----|----|----|
|
||||
@ -65,14 +47,14 @@ First try (%): 87.36263736263736
|
||||
|
||||
Second Round:
|
||||
-5 -4 -3 -2 -1 0 1 2
|
||||
|----|----|----|----|====|====|----|
|
||||
|----|----|----|----|====|====|====|
|
||||
|
||||
Total number of tests = 979;
|
||||
Total number of tests = 1025;
|
||||
|
||||
|
||||
first_sample = -5;
|
||||
first_num_samples = 5;
|
||||
second_num_samples = 3;
|
||||
num_samples = 5;
|
||||
|
||||
First Round:
|
||||
-5 -4 -3 -2 -1 0 1 2
|
||||
|====|====|====|====|====|----|----|
|
||||
@ -82,14 +64,14 @@ First try (%): 95.60439560439561
|
||||
|
||||
Second Round:
|
||||
-5 -4 -3 -2 -1 0 1 2
|
||||
|----|----|----|----|----|====|----|
|
||||
|----|----|----|----|----|====|====|
|
||||
|
||||
Total number of tests = 1108;
|
||||
Total number of tests = 1140;
|
||||
|
||||
|
||||
first_sample = -5;
|
||||
first_num_samples = 6;
|
||||
second_num_samples = 2;
|
||||
num_samples = 6;
|
||||
|
||||
First Round:
|
||||
-5 -4 -3 -2 -1 0 1 2
|
||||
|====|====|====|====|====|====|----|
|
||||
@ -105,5 +87,5 @@ Total number of tests = 1274;
|
||||
|
||||
|
||||
first_sample = -5;
|
||||
first_num_samples = 7;
|
||||
second_num_samples = 8;
|
||||
num_samples = 7;
|
||||
|
||||
|
Reference in New Issue
Block a user