∇ProvenDecisions
Ctrl K

Warehouse location (Fermat-Weber point): a convex optimization example, solved and checked

The warehouse location (Fermat-Weber point) is a classic convex optimization problem. Here it is solved by a real solver (CLARABEL) and checked: every constraint, and the optimality certificate. Change the numbers below and solve your own.

Answer. Assumed: the warehouse may be placed anywhere on the plane. The smallest objective value is 6.54099, at x = 1.30224, y = 1.04678. All 2 constraints are satisfied exactly. Optimal, numerically checked.

Solve your own version free, no account needed

The problem

Towns sit at (0, 0), (4, 0) and (1, 3) on a map in km. Where should a warehouse go to minimize the total straight-line distance to the three towns, and what is that total?

How the model was built

The objective as written from the problem, before the numbers are multiplied out:

Assumptions:

The model

Each line has a plain-language note on the right.

make as small as possible: total straight-line distance from the warehouse to the three towns (km)
warehouse east-west coordinate (km) is at least -1000
warehouse north-south coordinate (km) is at least -1000

What is being decided

There are 2 decision variables.

VariableTypeMeaning
xreal numberwarehouse east-west coordinate (km)
yreal numberwarehouse north-south coordinate (km)

Goal and limits

Minimize total straight-line distance from the warehouse to the three towns (km) subject to 2 constraints, of which 2 are simple bounds on a single variable.

Problem type

Conic (convex), complexity level 4: convex nonlinear functions such as log, exp, square roots or powers. Solved with CLARABEL at the Medium solver tier.

Picture

Shaded: every point that satisfies all the constraints. Dot: the optimum. Dashed: the objective's level line through it.

(1.30224, 1.04678)-1200.26-1200.21-849.805-849.843-499.349-499.477-148.893-149.11201.563201.256xy

The answer at a glance

The optimal value of each decision, as the solver returned it.

x1.30224y1.04678

Which constraints hold the answer in place

No constraint is binding. Changing a binding constraint changes the answer; a slack one can move a little without effect.

#ConstraintValueLimitSlackBinding
1x >= -10001.30224-10001001.3
2y >= -10001.04678-10001001.05

Algebraic model (low level)

Decision variables, objective and every constraint written out; this is exactly what the solver receives.

Model code (cvxpy)

The same model in cvxpy, ready to run.

import cvxpy as cp

x = cp.Variable(name='x')  # warehouse east-west coordinate (km)
y = cp.Variable(name='y')  # warehouse north-south coordinate (km)

objective = cp.Minimize(cp.sqrt(x**2 + y**2) + cp.sqrt(y**2 + (x - 4)**2) + cp.sqrt((x - 1)**2 + (y - 3)**2))
constraints = [
    x >= -1000,
    y >= -1000,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='CLARABEL')
print(problem.status, problem.value)
print('x =', x.value)
print('y =', y.value)

Solve your own

This is the model as the app reads it. Change any number and solve it in the free box on the front page (no account needed).

minimize sqrt((x-0)^2 + (y-0)^2) + sqrt((x-4)^2 + (y-0)^2) + sqrt((x-1)^2 + (y-3)^2)
subject to
x >= -1000
y >= -1000
# x = warehouse east-west coordinate (km)
# y = warehouse north-south coordinate (km)
# objective = total straight-line distance from the warehouse to the three towns (km)
# assume: the warehouse may be placed anywhere on the plane

Change the numbers and solve it

Checked: the app's answer matches the reference answer in our test set, which two solvers (CLARABEL, SCS) agree on. Built 2026-11-10.

Related examples

All 50 solved examples

Try ProvenDecisions free: type, photograph or say an optimization problem; every answer is checked by a solver.

What do you want to optimize?

Type the math, describe it in words, snap a photo or say it. ProvenDecisions builds the model, solves it, checks it and walks you through it.

One constraint per line, or separated by commas. Add integer: x, y or binary: z for whole-number decisions. LaTeX works too.

Try: