#include #include #include #include "sphere_adapt_functions.h" int main(int argc, char *argv[]) { if (argc != 2) { printf("Usage: %s \n", argv[0]); return 1; } DataPoint *mag_anomaly; int row_count = 0; // Call the function to read the data file if (read_data_file(argv[1], &mag_anomaly, &row_count) != 0) { free(mag_anomaly); return 1; } printf("row count read from input file %d\n", row_count); //set parameters for model sphere, with intial depth guess of 500 m Sphere sphere1 = {0.0, 0.0, 900.0, 100.0, 45.0, 0.0, 1.0, 45.0, 0.0}; double alpha_init = 100.0; // Starting learning rate for adaptive learning double tol = 1e-6; // Convergence tolerance for adaptive learning int max_iter = 1000; // Maximum iterations for adaptive learning double z_min = 0.1; // minimum depth for coarse search double z_max = 1000.0; //maximum depth for coarse search int grid_points = 10; // number of solution in coarse search sphere1.z = coarse_to_fine_search(mag_anomaly, &sphere1, row_count, z_min, z_max, grid_points); printf("sphere1.z at end of coarse search = %lf\n", sphere1.z ); double optimal_depth = adaptive_gradient_search(mag_anomaly, &sphere1, row_count, alpha_init, tol, max_iter); printf("Optimized depth: %f\n", optimal_depth); for (int i=0; i