Skip to content

About

Location optimization project (Weiszfeld's algorithm, gradient descent) for TMA4180

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

README

Facility Location Optimization: The Fermat-Weber Problem

This repository studies the (weighted) Fermat-Weber problem: finding the point that minimizes the sum of weighted Euclidean distances to a set of given points. It is solved both with the Weiszfeld algorithm and with steepest gradient descent using a backtracking line search, and applied to finding the demographic midpoint of Norway's cities.

Group project for TMA4180 (Optimization I) at NTNU, spring 2026. Collaborators: selma-bl Haakan03.

Optimal city placement Convergence of both methods
Optimal city placement Error convergence

Project Structure

main.ipynb: The single notebook containing the full project, organized by problem number:

  • Problem 2: Plots the unit balls of the Manhattan, Euclidean and max-norm distances.
  • Problem 5: Checks, via a convex hull argument, whether a point among a set of points on a circle can be a minimizer.
  • Problem 13: Implements the Weiszfeld algorithm (FermatsProblem class), tested on a symmetric four-point example and on the largest cities of Norway.
  • Problem 14: Implements steepest gradient descent with backtracking line search and compares it against Weiszfeld on the same problem.
  • Demographic midpoint of Norway: Uses the 50 largest cities (weighted by population) to compute and plot the demographic midpoint on a map.
  • Comparison: Compares Weiszfeld and gradient descent over many random problems, reporting average iteration counts and standard deviation.

Requirements

The project requires:

pip install numpy scipy matplotlib geopandas

Note: geopandas pulls in GDAL/Fiona and is easiest to install via conda if pip fails.

How to Run

Open main.ipynb and run the cells top to bottom; each problem is self-contained in its own labeled section.

Outputs

Plots are exported as PNG files in the repository root (points_circle1.png, points_circle2.png, errors_weiszfeld.png, errors_gradient_descent.png). Leverbar zip.zip is the original course submission archive.

About

Location optimization project (Weiszfeld's algorithm, gradient descent) for TMA4180

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages