Artificial intelligent assistant

Minimum path cost > A railway has to be built between cities A and B, but a wedge of difficult ground PQR lies between them. Find the best route for the railway. !railway This problem (from "Mathematician's Delight") can be solved by simply using a ruler and calculating the different costs but which geometrical rule is used in reality?

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.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 7fdf19c24d160067b4f5bb01661426a8