// Nelder-Mead metodu ile optimizasyon
// 
import java.util.*;
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import javax.swing.*;


class ff1 extends f_xj
{
double a[][];

public ff1(String s)
{a=Text.readDoubleT(s);}
	
public double func(double x[]) 
{
//optimisation function
double ff=0;
int n=a[0].length;
for(int i=0;i<n;i++)
   ff+=a[0][i]*((x[0]-a[1][i])*(x[0]-a[1][i])+(x[1]-a[2][i])*(x[1]-a[2][i]));
return ff; 
}
}

public class NA42
{
	 public static void main (String args[])  
     {  
	 String s="enter optimum point first estimation values with one empty space in between: ";
     double [] x0=NA41.inputdata(s);
     double [] dx0=new double[x0.length];
     for(int i=0;i<x0.length;i++) dx0[i]=0.2*x0[i];
     ff1 f=new ff1("city.txt");
     double [] r1= NA41.nelder(f,x0);
     s=" solution set  : \n"+Matrix.toStringT(r1);     
     String s2="Nelder-Mead simplex optimisation method ";
     JOptionPane.showMessageDialog(null,s,s2,JOptionPane.PLAIN_MESSAGE);
     System.exit(0);
     } 
}
