From 4bc44838a4f795e35b47677238d9fdc811b47b86 Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Wed, 8 Dec 2021 10:30:05 +1100 Subject: [PATCH] Change naming to use "round" instead of "occasion" --- dlmo.mzn | 32 +++++++-------- output.txt | 112 ++++++++++++++++++----------------------------------- 2 files changed, 54 insertions(+), 90 deletions(-) diff --git a/dlmo.mzn b/dlmo.mzn index 7db58d2..d3b996d 100644 --- a/dlmo.mzn +++ b/dlmo.mzn @@ -8,23 +8,23 @@ array[Patient, Horizon] of float: sample; % --- Derived data --- -% For each patient: after which sample could we stop and have found dlmo? (occasion must then include `critical_test[PT]` and its successor to catch it). +% For each patient: after which sample could we stop and have found dlmo? (round must then include `critical_test[PT]` and its successor to catch it). array[Patient] of var Horizon: critical_sample = [ min([i | i in -5..1 where sample[pt, i] <= DLMO_threshold /\ sample[pt, i+1] >= DLMO_threshold]) | pt in Patient]; % --- Decisions --- -% First occasion: -var Horizon: first_sample; % When to start sampling on the first occasion -var 2..length(Horizon): first_num_samples; % How many samples to take on the first occasion +% 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 -% Second occasion: -var 2..length(Horizon): second_num_samples; % How many samples to take on the second occasion +% 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 occasion, then we sample `second_num_samples` ending with the `first_sample`. -% If the levels were to low in all samples during the first occasion, 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 `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 --- -% For each patient: will their DLMO be detected on the first occasion? +% 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) | pt in Patient @@ -32,29 +32,29 @@ array[Patient] of var bool: first_detected = [ % --- Constraint --- -% The DLMO should be detected on the second occasion (if not detected on the first occasion) +% The DLMO should be detected on the second round (if not detected on the first round) constraint forall (pt in Patient) ( first_detected[pt] - % Before first occasion + % Before first round \/ (critical_sample[pt] >= first_sample - (second_num_samples - 1) /\ critical_sample[pt] + 1 <= first_sample) - % After first occasion + % 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)) ); % --- Objective --- solve minimize - % Number of tests on first occasion + % Number of tests on first round (length(Patient) * first_num_samples) - % Number of test on second occasion + % Number of test on second round + (count(pt in Patient) (not first_detected[pt]) * second_num_samples); % --- Output --- -output ["First Occasion:\n"] +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] ++ ["\n\nFirst try (%): \(count(first_detected) / length(Patient) * 100)\n"] -++ ["\n\nSecond Occasion:\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] ++ ["\n\nTotal number of tests = \(_objective);"] diff --git a/output.txt b/output.txt index ad85e28..d54f235 100644 --- a/output.txt +++ b/output.txt @@ -1,83 +1,47 @@ -First Occasion: --5 -4 -3 -2 -1 0 1 2 - |----|----|----|====|====|====|----| - -First try (%): 41.75824175824176 - - -Second Occasion: --5 -4 -3 -2 -1 0 1 2 - |====|====|====|----|----|----|====| - -Total number of tests = 1470; - - -first_sample = -2; -first_num_samples = 4; -second_num_samples = 7; ----------- -First Occasion: --5 -4 -3 -2 -1 0 1 2 - |----|----|----|====|----|----|----| - -First try (%): 29.12087912087912 - - -Second Occasion: --5 -4 -3 -2 -1 0 1 2 - |====|====|====|----|====|====|====| - -Total number of tests = 1009; - - -first_sample = -2; -first_num_samples = 2; -second_num_samples = 5; ----------- -First Occasion: --5 -4 -3 -2 -1 0 1 2 - |----|----|----|====|----|----|----| - -First try (%): 29.12087912087912 - - -Second Occasion: --5 -4 -3 -2 -1 0 1 2 - |====|====|====|----|====|====|====| - -Total number of tests = 880; - - -first_sample = -2; -first_num_samples = 2; -second_num_samples = 4; ----------- -First Occasion: --5 -4 -3 -2 -1 0 1 2 - |----|====|====|====|----|----|----| - -First try (%): 78.57142857142857 - - -Second Occasion: --5 -4 -3 -2 -1 0 1 2 - |====|----|----|----|====|====|----| - -Total number of tests = 845; - - -first_sample = -4; -first_num_samples = 4; -second_num_samples = 3; ----------- -First Occasion: +First Round: -5 -4 -3 -2 -1 0 1 2 |----|----|====|====|----|----|----| First try (%): 54.94505494505495 -Second Occasion: +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 |====|====|----|----|====|====|----|