4 Replies - 9954 Views - Last Post: 04 March 2008 - 12:41 AM Rate Topic: -----

#1 akusbharat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 03-March 08

N-queens problem by using genetics algorithm in java

Posted 03 March 2008 - 11:55 AM

Hi,
I need the code for n-queens problem by using genetic's algorithm search technique with the source code written in using java language. please help me as early as possible
as it is very urgent for me
Is This A Good Question/Topic? 0
  • +

Replies To: N-queens problem by using genetics algorithm in java

#2 Nykc  Icon User is offline

  • Gentleman of Leisure
  • member icon

Reputation: 731
  • View blog
  • Posts: 8,644
  • Joined: 14-September 07

Re: N-queens problem by using genetics algorithm in java

Posted 03 March 2008 - 12:04 PM

Hey good luck with that.

I know you are in a hurry, so make sure you read the Posting Rules about how we at Dream In Code will not do your homework for you.
I'll tell you what go ahead and try to do this yourself and if you have a problem while coding be sure to :code: and the good people over at </DIC> will be happy to help you work out your issues.

Happy Coding! :D

This post has been edited by Nykc: 03 March 2008 - 12:06 PM

Was This Post Helpful? 0
  • +
  • -

#3 akusbharat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 03-March 08

Re: N-queens problem by using genetics algorithm in java

Posted 03 March 2008 - 12:10 PM

package myproject;

import java.util.Random;

/**
 *
 * @author Bharat
 */
public class Queen
{
	private static Random randomGenerator = new Random();
	private static  int N;
	private static  int k=randomGenerator.nextInt(32);
	private static  int[][] strandArray=new int[k][N];
	private static  int[][] strandScore=new int[k][2];
	private static  int[][] newStrandArray=new int[k][N];
	private static  int[] fit=new int[k];
	private static  int strandNum,col,m,n,p,count,totalofScores;

	
   public static void main(String[] args)throws Exception 
   {
	for(m=0;m<k-1;m++)
	{
		for(n=0;n<N-1;n++)
		{
			strandArray[m][n]=randomGenerator.nextInt(N);
		}
	}
   }
 
	
	
 /*   
	int[][] Array;
	int k=32;//some random variable
	int N; // the number of queens to be placed on the board
	double p;  // p is the probability
	int count=100;
}*/
/*
 *int [][] strandArray= new strandArray[k][N];
 * int[][] strandScore=new strandScore[k][2];
 * int strandNum,col,m,n;
 * strandNum=m;
 * col=n; 
 * for(m=o;m<k-1;m++)
 * {
 * for(n=0;n<N-1;n++)
 * {
 * strandArray[m][n]=randomvalues;// for example [2413]
 *								//			 [3142]
 * }
 * }
 * 
 * count=score;
 * for(m=0;m<k-1;m++)
 * {
 * if(O[i][j]==O[i+k][j+k])
 * {
 * return false;
 * score+=-10;
 * }
 * ifO[i][j]==O[i-k][j+k]
 * {
 * return false;
 * score+=-10;
 * }
 * ifO[i][j]=O[i][j+k]
 * {
 * return false;
 * score+=-10;
 * }
 * if(O[i][j]==O[i+k][j])
 * {
 * return false;
 * score+=-10;
 * }
 * }
 * if(score==100)
 * {
 * System.out.println("Solution found! stop programme");
 * }
 * totalofScores+=score;
 * p=score/totalofScores*100;
 * }
 * 
 * 
 * int[][] newstrandArray= new newstrandArray[k][N];
 */





i dint write the whole problem. i have been stuck at fitness function. and please give me the code for crossoverpoint and mutation.
Was This Post Helpful? 0
  • +
  • -

#4 akusbharat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 03-March 08

Re: N-queens problem by using genetics algorithm in java

Posted 03 March 2008 - 04:02 PM

hey reply me early please
Was This Post Helpful? 0
  • +
  • -

#5 bhandari  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 9
  • View blog
  • Posts: 754
  • Joined: 31-January 08

Re: N-queens problem by using genetics algorithm in java

Posted 04 March 2008 - 12:41 AM

WTF, you are in hurry that you forgot to tell what help do you want.
can u tell what problem are you facing with that code?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1