I have a large system of equations in the software R, with more unknowns than equations. This obviously have a (unlimited) range of solutions. An example of such a system would be
$x_1 + x_2 + x_3 = 5000$
$y_1 + y_2 + y_3 = 2500$
$z_1 + z_2 + z_3 = 7500$
$x_1 + y_1 + z_1 = 10000$
$x_2 + y_2 + z_2 = 3000$
$x_3 + y_3 + x_3 = 2000$
I want to numerically solve the system subject, while minimizing
$\Big|x_1-5000\cdot\frac{10000}{15000}\Big| + \Big|y_1 - 2500\cdot\frac{10000}{15000}\Big|$
This system would be easy to provide a solution intuitively to. However, the real system will have a larger function to minimize as well as more equations.
Do anyone know how to solve such a system in the software R
Let your constraint set be $X$.
Your objective function is of the form of
$$\min |x_1-a_1| + |y_1 - b_1|$$
subject to $x \in X$.
We can convert the optimization problem to $$\min w_1 + w_2$$
subject to $$w_1 \ge x_1-a_1$$ $$w_1 \ge a_1-x_1$$
$$w_2 \ge y_1-b_1$$
$$w_2 \ge b_1 - y_1$$ $$x \in X$$
which is just a linear programming problem.
Remark: For your special problem, set $x_1=a_1$ and $y_1=b_1$ and then you just have to find a feasible solution to minimize the objective function.