Skip to content

A multi-stage optimization solution using Differential Evolution and L-BFGS-B to find unknown parameters in a complex parametric curve.

Notifications You must be signed in to change notification settings

GX-47/parametric-curve-optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Assignment for Research and Development / AI

Overview

This project solves a parametric curve fitting problem to find unknown parameters in a complex parametric equation. The goal is to fit observed data points to a parametric curve and determine the optimal values for three unknown parameters: θ (theta), M, and X.

Problem Statement

Given the parametric equations:

  • $x = t \cdot \cos(\theta) - e^{M|t|} \cdot \sin(0.3t) \cdot \sin(\theta) + X$
  • $y = 42 + t \cdot \sin(\theta) + e^{M|t|} \cdot \sin(0.3t) \cdot \cos(\theta)$

Where:

  • Unknown parameters: $\theta$ (0° < θ < 50°), $M$ (-0.05 < M < 0.05), $X$ (0 < X < 100)
  • Parameter range: $t \in (6, 60)$
  • Input data: 27.4 KB of observed (x, y) points lying on the curve

Objective

Find the optimal values of θ, M, and X that best fit the observed data points, minimizing the distance between the predicted curve and the observed points.


Final Solution

\left(t\cdot\cos(\pi/6) - e^{0.03\left|t\right|}\cdot\sin(0.3t)\sin(\pi/6) + 55, 42 + t\cdot\sin(\pi/6) + e^{0.03\left|t\right|}\cdot\sin(0.3t)\cos(\pi/6)\right)

Or in decimal form:

\left(t\cdot\cos(0.523599) - e^{0.03\left|t\right|}\cdot\sin(0.3t)\sin(0.523599) + 55, 42 + t\cdot\sin(0.523599) + e^{0.03\left|t\right|}\cdot\sin(0.3t)\cos(0.523599)\right)

Where:

  • θ = 0.523599 radians = π/6 radians = 30°
  • M = 0.03
  • X = 55
  • L1 Distance: 0.027621

The explanation of the solution will be found in EXPLANATION.md


Quick Start

Install Dependencies

pip install -r requirements.txt

Run the Solution

python src/solution.py

or

Open src/solution.ipynb and run each cell

Run the Post-Optimization

python src/test_parameters.py

️ Project Structure

.
├── README.md              # This file
├── SOLUTION.md            # Detailed solution explanation
├── requirements.txt       # Python dependencies
├── data/
│   └── xy_data.csv        # Given data points
├── src/
│   ├── solution.py        # Python solution script
│   └── test_parameters.py # Post-optimization parameter testing
│   └── solution.ipynb     # Jupyter notebook with interactive analysis
└── results/
    ├── solution.txt       # Solution output
    └── figures/           # Generated visualizations
        ├── fitted_curve_vs_observed.png
        ├── parametric_curve_analysis.png
        ├── parameter_comparison.png
        └── comparison_User_Test_(θπ6,_M0.03,_X55).png

Visualizations

The solution generates the following visualizations:

1. Fitted Curve vs Observed Data (fitted_curve_vs_observed.png)

  • Overlay of predicted curve and observed points
  • Visual validation of curve fit quality

2. Complete Analysis Dashboard (parametric_curve_analysis.png)

  • Distance Distribution: Histogram of point-to-curve distances
  • Parametric Components: x(t) and y(t) over parameter range
  • Residual Plot: Distance vs. parameter t
  • Exponential Modulation: Visualization of e^(M|t|)·sin(0.3t) term

3. Parameter Comparison (parameter_comparison.png)

  • Generated by test_parameters.py
  • Compares user-provided test parameters with optimal solution
  • Shows fit quality across different parameter sets

4. User Test Comparison (comparison_User_Test_(θπ6,_M0.03,_X55).png)

  • Detailed comparison visualization for specific test parameters
  • Shows both curves overlaid with observed data

All figures are saved in results/figures/.


License

This project is for assessment purposes.


About

A multi-stage optimization solution using Differential Evolution and L-BFGS-B to find unknown parameters in a complex parametric curve.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published