Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Weiszfeld’s Algorithms Help PLS

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Weiszfeld’s Algorithms Help PLS

    Please help me. Where is wrong ?

    package Sezgisel;
     
    public class SezgiselAlgoritma1 {
     
    	public static void main(String[] args) {
     
    	double a[]={40.78,40.75,40.71,40.72,40.69,40.93,40.51,40.80,40.64, 41.07,41.03,41.05,40.51,40.69,40.88,40.40};
    	double b[]={30.40,30.40,30.36,30.38,30.62,30.48,30.29,30.75,30.54, 30.78,30.31,30.85,30.17,30.27,30.45,30.49};
    		//Rastgele değerler x=50 ve y=50 olarak verildi.
    		int x=50;
    		int y=50;
    		int literasyon=0;
    		double m,l;
    		double J=0;//Amaç fonksiyonu J fonksiyonudur.
    	do {
    			 double Toplam=0;
    			 for ( int i=0; i<16; i++){
    			 m(i)=1/sqrt(((x-a[i]))^2+((y-b[i]))^2);
    			 Toplam=Toplam+ m(i);
    			  }// 1. for end
    			 for (int i=0; i<16; i++){
    				 l(i)=m(i)/Toplam ;
    			 }//2. for end
    			 x=0; y=0;//Formüldeki ilk x ve y değerleri sıfırdır.
    			 for (int i=0; i<16; i++){
    				 x= x+ (l(i)*a[i]);
    				 y= y+ (l(i)*b[i]);
    			 }//3. for end
     
    			 for (int i=0; i<16; i++){
    			 J=J+ sqrt(((x-a[i]))^2+((y-b[i]))^2);
     
    			literasyon=literasyon+1;
    	}while (literasyon!=50);
    		System.out.println("Tesisin enlem değeri X=" + x + "ve boylam değeri Y=" + y + "'dir." );
     
    	 }
    		System.out.println("Amaç fonksiyonumuzun değeri Z=" + J);
     
    	}
     
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Weiszfeld’s Algorithms Help PLS

    If you are getting error messages. copy the full text and paste it here.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Weiszfeld’s Algorithms Help PLS

    thanx. i edited it...

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Weiszfeld’s Algorithms Help PLS

    Where is wrong ?
    Can you explain what the problem is?
    Post the program's output, explain what is wrong with it and show what it should be.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Weiszfeld’s Algorithms Help PLS

    Here is a output errors...

    gu2rx.jpg

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Weiszfeld’s Algorithms Help PLS

    Please copy and post the error messages NOT an image.

    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Weiszfeld’s Algorithms Help PLS

    Quote Originally Posted by Norm View Post
    Please copy and post the error messages NOT an image.

    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    like this ? sorry for misunderstood, i'm at very beginning for java programming

    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    The left-hand side of an assignment must be a variable
    The method m(int) is undefined for the type SezgiselAlgoritma1
    The left-hand side of an assignment must be a variable
    The method l(int) is undefined for the type SezgiselAlgoritma1
    The method l(int) is undefined for the type SezgiselAlgoritma1
    The operator ^ is undefined for the argument type(s) double, double
    Syntax error, insert "while ( Expression ) ;" to complete DoStatement

    at SezgiselAlgoritma1.main(depo.java:19)

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Weiszfeld’s Algorithms Help PLS

    at SezgiselAlgoritma1.main(depo.java:19)
    The error messages do NOT show what lines they happened on. I don't think all those error messages are for the code at line 19. What code is on line 19?
    Can you use the javac compiler to compile the program to get compiler error messages?
    Your IDE's error messages don't say where the errors are.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Algorithms required
    By beginner in forum Member Introductions
    Replies: 1
    Last Post: February 20th, 2012, 07:42 AM
  2. SORTING ALGORITHMS...
    By Medo Almasry in forum Algorithms & Recursion
    Replies: 3
    Last Post: October 14th, 2011, 08:18 PM
  3. Re: Sorting Algorithms
    By shashiwagh in forum Java Theory & Questions
    Replies: 1
    Last Post: March 23rd, 2011, 02:19 PM
  4. Sorting Algorithms
    By Dalisra in forum Java Code Snippets and Tutorials
    Replies: 1
    Last Post: November 10th, 2009, 09:24 PM
  5. Java algorithm for bank program to connect database
    By araujo3rd in forum Algorithms & Recursion
    Replies: 1
    Last Post: December 10th, 2008, 01:34 PM