This is a basic constraint optimization problem:
$min$ $c_1 \left\| {X - Y} \right\| + c_2 \left\| {X - A} \right\| + c_2 \left\| {Y - B} \right\|$ (minimize the weighted distances)
Subject to:
$(P - X)\times (X - Q) = 0$
(X must lie on the line between $Q$ and $P$)
and
$(R - Y)\times (Y - Q) = 0$
(Y must lie on the line between $Q$ and $R$)
where $c_1$=20,000 and $c_2$=10,000 $P$, $Q$, $R$ ,$A$, and $B$ are known.