Step 4: ⎩⎨⎧x1e+vx1e+v≤v+f≤v+f≤x2≤x2if x1≥e+v and x2≥f+vif x1≤e+v and x2≥f+vif x1≥e+v and x2≤f+vif x1≤e+v and x2≤f+v ⇓ ⎩⎨⎧vex1v≥x1−f≤f≤x2≤x2−eif x1≥e+v and x2≥f+vif x1≤e+v and x2≥f+vif x1≥e+v and x2≤f+vif x1≤e+v and x2≤f+v ⇓
Range 1: ⎩⎨⎧vvvvv≥x1−f≤x1−e≤x2−f≥c≤d⇒v∈[max(x1−f,c),min(x1−e,x2−f,d)]
Range 2: ⎩⎨⎧vvvv≥x1−e≤x2−f≥c≤d⇒v∈[max(x1−e,c),min(x2−f,d)]
Range 3: ⎩⎨⎧vvvv≥x2−f≤x1−e≥c≤d⇒v∈[max(x2−f,c),min(x1−e,d)]
Range 4: ⎩⎨⎧vvvvv≤x2−e≥x1−e≥x2−f≥c≤d⇒v∈[max(x1−e,x2−f,c),min(x2−e,d)]
Step 5:
select a value v in available ranges for candidate,
update date target to [x1-v, x2-v]
select one element from others as candidate and remove it from others
if others is not empty, 4. update others as the sum of others elements (except new candidateelement) 5. Go to Step 1.
else go to Step 6.
Step 6: select a random value from the intersection of target and candidate.