Description:
Using Bee Colony optimization to trace possible paths in any state transition diagram
Introduction:
The basic idea of the research work is to prove the efficient use of swarm intelligence to find efficient solutions to np hard problems in a better optimized way.
There are various algorithms available to traverse all the possible edges of any state transition diagram or directed/undirected graphs ,such as Depth First Traversal or Breadth First Traversal. But these methods don't provide inefficient control on the way tracing happens. By using BCO we can trace across a graph with minimum possible number of steps and enjoying more control on the way traversing is to be done,as will be explained in the paper.
Problem Statement:
Trace all possible transitions in any directed/undirected graph or FSM diagram with superior control than traditional methods as DFS/BFS. Presently, it is a very challenging job to find all possible transitions and techniques are required to solve it. The advantage of solutions is that during testing phase it would be possible to trace the malfunctioning node without going through all graph repeadly.
Proposed Solution:
The problem of tracing all the possible paths in any given graph or all transitions in a state transition diagram can be solved by using Bee Colony optimization technique very efficiently.
Mapping the Bee behavior on tracing possible edges of graph, it can be stated that bee's have two possible states:
1) Dancing on the floor 2)Looking for food.
When the first bee moves out, it comes out with some nectar(result) to the hive and performs waggle dance. The duration and energy of dance depends upon the type of result carried back by bee. If it's acceptable the rest of the bees also follow the respective bee to it's result source.
This method takes the solution to optimum result by taking in consideration only the optimum result.
Mapped on graph, first agent is to decide the connected node it has to move to after traversing any particular node.
The factors on which the respective choice depends are:
1) Number of previsits to the bode(a).
2) Closeness to final state(b).
3) Input/Output degree for each node(c).
Happiness value=(a(power(choice)+b(power(choice))+c(power(choice))
where choice is the personal decision of programmer. By varying the powers the programmer can trace paths with his possible choice.
Initialization phase:
1.Initially the previsit for all nodes will be set to zero and with each subsequent result it will update the data possessed per node.
2.Maintain separate data for input/output degree and closeness to final state in different tables.
These values must be calculated before the algorithm starts running.
Employed bee phase:
1. Add the visited node to tabu list.
2. Update the visited information in data structure.
Onlooker phase:
1.For all possible next phases chose a node with:
a) Maximum happiness value.
b) Never before visited node(not in tabu list).
Proposed Approach:
The starting node is considered to be the first node traversed always. When search bees start from here in different directions they go to all the nodes connected to this node.
All bees come back on the starting node to perform waggle dance. Bee with maximum happiness value performs the best dance
All nodes that are traversed through are added to the Tabu list.
Analysis:
The number of iterations depends upon the number of connected nodes to any node. Since it is a two dimensional representation it's complexity doesn't cross O(n^2). In terms of memory
requirements a 2-d matrix maintains Input/output degree data per node & two different arrays can be used to keep information about pre-visits and closeness to final state per node.
I am posting the code i submitted as my part of submission. This code runs fine and works for most of graphs I believe and it is in raw form, you can always improve it as much as you can. There is only one feature missing that I couldn't code in time is labeling the nodes according to closeness from final state. If you can do it....it will be great.
I hope it helps you. If you have something better please add to it, we all will be grateful to your help. The best way to understand this undocumented code will be debugging it in eclipse or your favorite IDE.
Code Section: As I have informed , it is not refined code, so you will have to spend time at least once to see through it. Good source for those who are willing to learn and confusing to those who are seeking a place to cheat.....:P
----------------------------------------------BeeCore.java------------------------------------------------------------
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Random;
import java.util.Set;
@SuppressWarnings("unchecked")
public class BeeCore {
Random rand=new Random();
//static int mynum=14;
static int mynum=6;
static int matrixs_io[][]=new int[mynum][mynum];
ArrayList elements=new ArrayList();
static int temp_array[]=new int[mynum];
Set set[]=new Set[mynum];
static int k=0;
int num=0;
static HashMap hash=new HashMap();
int el_count=0;
static int data_tr[]=new int[mynum];
int happy=0;
static Set path[]=new LinkedHashSet[mynum*mynum];
Set paths=new LinkedHashSet();
int tr_data=0;
int sum,max=0;
int count=0;
int det_count=0;
int check_var_start=mynum*2;
int check_var_j=mynum*2;
int throw_back=1;
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
static int ret_st[]=new int[mynum];
static int my_array[][]={ //state machine
{ 1, 5, mynum+1, mynum+1, mynum+1, mynum+1},
{ 2, mynum+1, mynum+1, mynum+1, mynum+1, mynum+1},
{ 2, 3, 4, 5, mynum+1, mynum+1},
{ 5, mynum+1, mynum+1, mynum+1, mynum+1, mynum+1},
{ 5, 3, 2, mynum+1, mynum+1, mynum+1},
{ 5, mynum+1, mynum+1, mynum+1, mynum+1, mynum+1},
};
void fill_matrix() throws NumberFormatException, IOException
{
for(int k=0;k
{
System.out.println("Number of elements in row:");
int numel=Integer.parseInt(stdin.readLine());
for(int j=0;j
{
System.out.println("Enter elements:");
int numel_1=Integer.parseInt(stdin.readLine());
my_array[k][j]=numel_1;
}
}
}
void print_fill_matrix()
{
for(int k=0;k
for(int j=0;j
{
System.out.println(my_array[k][j]);
}
}
void initialize_temp_array()
{
for(int k=0;k
{
temp_array[k]=0;
}
initialize_set1();
}
void initialize_set1()
{
for(int k=0;k
{
path[k]=new LinkedHashSet();
}
}
int i,j;
//static int my_array[][]=new int[mynum][mynum];
void RandomMatrix() throws IOException //if you want a new state machine every time
{
for(i=0;i
for(j=0;j
{
my_array[i][j]=rand.nextInt(mynum);
}
}
void matrixprint() //to print the state machine
{
System.out.println("Random: "+mynum);
System.out.println("Random matrix:\t");
for(i=0;i
{ for(j=0;j
{
System.out.println(my_array[i][j]);
}
System.out.println("\t");
}
}
void check_repeat() //once a state has been traversed it must not be visited again
{
int element;
for(i=0;i
{
elements.clear();
for(j=0;j
{
element=my_array[i][j];
if(elements.contains(element))
{
my_array[i][j]=mynum+1;
}
else
elements.add(element);
}
}
}
void iodegree() //was To calculate input/output degree though here only indegree is being referred
{
int element;
for(i=0;i
for(j=0;j
{
element=my_array[i][j];
if(element
{
temp_array[element]++;
}
else
{}
}
}
void print_temp_array()
{
int k;
for(k=0;k
{
System.out.println(" "+temp_array[k]);
}
}
void initialize_set()
{
for(i=0;i
{
data_tr[i]=0;
set[i]=new HashSet();
for(j=0;j
matrixs_io[i][j]=0;
}
}
void travelled(int state) //if a state has been traversed add it to visited list
{
tr_data=data_tr[state];
++tr_data;
// System.out.println("Tr_data=+="+tr_data+"state=="+state);
data_tr[state]=tr_data;
// return data_tr[state];
}
void populate_main()
{
for(i=0;i
for(j=0;j
{
// System.out.println("I: " + i + "J:" + j);
if(my_array[i][j]>=mynum||my_array[i][j]==i)
{
matrixs_io[i][j]=-1;
}
else
{
matrixs_io[i][j]=temp_array[my_array[i][j]];
}
// matrixs[i][j].pre_tarv=travelled(i);
}
}
void print_populate()
{
for(i=0;i
for(j=0;j
{
System.out.println("["+i+"]"+"["+j+"]");
System.out.println("IO_degree= "+matrixs_io[i][j]);//+" Pre Traversed= "+matrixs[i][j].pre_tarv);
}
}
/*void det_path(int start)
{
++count;
System.out.println("Count="+count);
i=start;
System.out.println("next=="+start);
//path[i].add(start);
if(paths.contains(i))
{
System.out.println("State getting repeated:"+i);
}
else
{
paths.add(i);
data_tr[i]=+1;
}
while(count<=input)
{
for(j=0;j
{
sum=matrixs_io[i][j]+data_tr[j];
if(max
{ System.out.println("Max="+max);
max=sum;}
else continue;
}
// System.out.println("States having same max");
// for(i=0;i
for(j=0;j
{
if(matrixs_io[i][j]+data_tr[j]==max )
{
System.out.println("State in row:"+matrix[i][j]);
if(count<=input && !(paths.contains(matrix[i][j]))) {
// path[i].add(matrix[i][j]);
det_path(matrix[i][j]);
}
else
{
det_path(matrix[i][j]);
}
}
System.out.println("path contents:"+paths);
// Iterator itr=path[i].iterator();
while(itr.hasNext())
{
}
// System.out.println("Max value:"+max+"HashSet="+path[i]);
}
} }*/
// int find_next(int num)
void top()
{
int path=rand.nextInt(mynum);
path=0;
for(int i=0;i
{
throw_back=1;
if(check_var_start==mynum*2 && check_var_j==mynum*2)
{
System.out.println("---In top no cancel");
next_state(path,i);
print_path();
System.out.println("---In top no cancel");
}
else
{
System.out.println("-----In top 1st cancel--------");
System.out.println("Row-"+check_var_start+"column="+check_var_j);
next_state(path,i);
print_path();
System.out.println("-----In top 1st cancel-------");
}
my_array[check_var_start][check_var_j]=mynum+1;
}
}
int next_state(int path,int i) // To find the next state for the present state
{ int counter=0;
{
for(int s=0;s
{
count=0;
paths.clear();
det_count=0;
populate_main();
data_tr[s]=0;
determine_path(path,++counter,i);
}
}
//max_in_row(path);
return 0;
}
// int my_path[][]=new int[mynum][mynum];
int ks=0;
void determine_path(int start,int index,int i) //To find the final path
{
{
int max=0;
int last = 0;
// System.out.println("Path["+path[start]+"]"+" --Index="+index/*+"-->Paths="+paths*/);
path[index-1].add(start);
// System.out.println("start:"+start);
//my_path[++ks]=start;
if(check_var_start==mynum*2 && check_var_j==mynum*2)
max=max_in_row(start);
else
{
my_array[check_var_start][check_var_j]=mynum+1;
max=max_in_row(start);
}
for(j=0;j
{
if(my_array[start][j]==mynum+1)
{
continue;
}
else
{
if(max==matrixs_io[start][j]+data_tr[my_array[start][j]]) //&& !paths.contains(matrix[start][j]))
{
matrixs_io[start][j]=-1;
// System.out.println("Next state="+matrix[start][j]);
travelled(my_array[start][j]);
if(throw_back==1)
{
check_var_start=mynum*2;
check_var_j=mynum*2;
while(check_var_start==mynum*2 && check_var_j==mynum*2)
{
check_var_start=start;
check_var_j=j;
// matrix[check_var_start][check_var_j]=input+1;
}
}
throw_back=0;
if(++det_count<=mynum*mynum)
{
last=j;
determine_path(my_array[start][j],index,i);
System.out.println("Last="+last);
// System.out.println("start:"+my_array[start][j]);
}
}
}
}
// matrixs_io[start][last]=-1;
/* for(int w=0;w
for(int t=0;t
System.out.println("--Matrix_io="+w+" "+t+matrixs_io[w][t]);*/
}
}
int max_in_row(int row) //TO calcuate the happiness value for next node
{
int current=0;
for(j=0;j
{
if(my_array[row][j]==mynum+1)
{
// System.out.println("Arrival of a final state");
continue;
}
else
{
// System.out.println("io_data="+matrixs_io[row][j]+" data_tr="+data_tr[matrix[row][j]]);
max=matrixs_io[row][j]+data_tr[my_array[row][j]];
// if(!path[index].contains(matrix[row][j]))
if(max>current )
{
current=max;
// System.out.println("Max=="+current+"state=="+row);
}
else
{
continue;
}
}
}return current;
}
void print_visit()
{
for(int g=0;g
System.out.println("data["+g+"]="+data_tr[g]);
}
void print_path()
{
for(int k=0;k
System.out.println("path["+k+"]"+path[k]);
}
void print_ks()
{
// for(int ks=0;ks
// System.out.println("KS="+my_path[ks]);
}
}
----------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------main.java-------------------------------------------------------------
import java.io.IOException;
public class main {
public static void main(String args[]) throws IOException
{
BeeCore beecore=new BeeCore();
// beecore.RandomMatrix();
// beecore.fill_matrix();
//beecore.matrixprint();
beecore.print_fill_matrix();
beecore.check_repeat();
// beecore.matrixprint();
beecore.initialize_temp_array();
beecore.initialize_set();
beecore.iodegree();
beecore.print_temp_array();
// beecore.prox_states();
// int happiness=beecore.calculate_happiness();
// System.out.println("Happiness="+happiness);
beecore.populate_main();
beecore.print_populate();
// beecore.det_path();
// beecore.next_state();
// beecore.print_populate();
beecore.top();
// beecore.print_visit();
beecore.print_path();
// beecore.print_ks();
}
}
------------------------------------------------------------------------------------------------------------------------------
Using Bee Colony optimization to trace possible paths in any state transition diagram
Introduction:
The basic idea of the research work is to prove the efficient use of swarm intelligence to find efficient solutions to np hard problems in a better optimized way.
There are various algorithms available to traverse all the possible edges of any state transition diagram or directed/undirected graphs ,such as Depth First Traversal or Breadth First Traversal. But these methods don't provide inefficient control on the way tracing happens. By using BCO we can trace across a graph with minimum possible number of steps and enjoying more control on the way traversing is to be done,as will be explained in the paper.
Problem Statement:
Trace all possible transitions in any directed/undirected graph or FSM diagram with superior control than traditional methods as DFS/BFS. Presently, it is a very challenging job to find all possible transitions and techniques are required to solve it. The advantage of solutions is that during testing phase it would be possible to trace the malfunctioning node without going through all graph repeadly.
Proposed Solution:
The problem of tracing all the possible paths in any given graph or all transitions in a state transition diagram can be solved by using Bee Colony optimization technique very efficiently.
Mapping the Bee behavior on tracing possible edges of graph, it can be stated that bee's have two possible states:
1) Dancing on the floor 2)Looking for food.
When the first bee moves out, it comes out with some nectar(result) to the hive and performs waggle dance. The duration and energy of dance depends upon the type of result carried back by bee. If it's acceptable the rest of the bees also follow the respective bee to it's result source.
This method takes the solution to optimum result by taking in consideration only the optimum result.
Mapped on graph, first agent is to decide the connected node it has to move to after traversing any particular node.
The factors on which the respective choice depends are:
1) Number of previsits to the bode(a).
2) Closeness to final state(b).
3) Input/Output degree for each node(c).
Happiness value=(a(power(choice)+b(power(choice))+c(power(choice))
where choice is the personal decision of programmer. By varying the powers the programmer can trace paths with his possible choice.
Initialization phase:
1.Initially the previsit for all nodes will be set to zero and with each subsequent result it will update the data possessed per node.
2.Maintain separate data for input/output degree and closeness to final state in different tables.
These values must be calculated before the algorithm starts running.
Employed bee phase:
1. Add the visited node to tabu list.
2. Update the visited information in data structure.
Onlooker phase:
1.For all possible next phases chose a node with:
a) Maximum happiness value.
b) Never before visited node(not in tabu list).
Proposed Approach:
The starting node is considered to be the first node traversed always. When search bees start from here in different directions they go to all the nodes connected to this node.
All bees come back on the starting node to perform waggle dance. Bee with maximum happiness value performs the best dance
All nodes that are traversed through are added to the Tabu list.
Analysis:
The number of iterations depends upon the number of connected nodes to any node. Since it is a two dimensional representation it's complexity doesn't cross O(n^2). In terms of memory
requirements a 2-d matrix maintains Input/output degree data per node & two different arrays can be used to keep information about pre-visits and closeness to final state per node.
I am posting the code i submitted as my part of submission. This code runs fine and works for most of graphs I believe and it is in raw form, you can always improve it as much as you can. There is only one feature missing that I couldn't code in time is labeling the nodes according to closeness from final state. If you can do it....it will be great.
I hope it helps you. If you have something better please add to it, we all will be grateful to your help. The best way to understand this undocumented code will be debugging it in eclipse or your favorite IDE.
Code Section: As I have informed , it is not refined code, so you will have to spend time at least once to see through it. Good source for those who are willing to learn and confusing to those who are seeking a place to cheat.....:P
----------------------------------------------BeeCore.java------------------------------------------------------------
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Random;
import java.util.Set;
@SuppressWarnings("unchecked")
public class BeeCore {
Random rand=new Random();
//static int mynum=14;
static int mynum=6;
static int matrixs_io[][]=new int[mynum][mynum];
ArrayList
static int temp_array[]=new int[mynum];
Set set[]=new Set[mynum];
static int k=0;
int num=0;
static HashMap hash=new HashMap();
int el_count=0;
static int data_tr[]=new int[mynum];
int happy=0;
static Set
Set
int tr_data=0;
int sum,max=0;
int count=0;
int det_count=0;
int check_var_start=mynum*2;
int check_var_j=mynum*2;
int throw_back=1;
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
static int ret_st[]=new int[mynum];
static int my_array[][]={ //state machine
{ 1, 5, mynum+1, mynum+1, mynum+1, mynum+1},
{ 2, mynum+1, mynum+1, mynum+1, mynum+1, mynum+1},
{ 2, 3, 4, 5, mynum+1, mynum+1},
{ 5, mynum+1, mynum+1, mynum+1, mynum+1, mynum+1},
{ 5, 3, 2, mynum+1, mynum+1, mynum+1},
{ 5, mynum+1, mynum+1, mynum+1, mynum+1, mynum+1},
};
void fill_matrix() throws NumberFormatException, IOException
{
for(int k=0;k
{
System.out.println("Number of elements in row:");
int numel=Integer.parseInt(stdin.readLine());
for(int j=0;j
{
System.out.println("Enter elements:");
int numel_1=Integer.parseInt(stdin.readLine());
my_array[k][j]=numel_1;
}
}
}
void print_fill_matrix()
{
for(int k=0;k
for(int j=0;j
{
System.out.println(my_array[k][j]);
}
}
void initialize_temp_array()
{
for(int k=0;k
{
temp_array[k]=0;
}
initialize_set1();
}
void initialize_set1()
{
for(int k=0;k
{
path[k]=new LinkedHashSet();
}
}
int i,j;
//static int my_array[][]=new int[mynum][mynum];
void RandomMatrix() throws IOException //if you want a new state machine every time
{
for(i=0;i
for(j=0;j
{
my_array[i][j]=rand.nextInt(mynum);
}
}
void matrixprint() //to print the state machine
{
System.out.println("Random: "+mynum);
System.out.println("Random matrix:\t");
for(i=0;i
{ for(j=0;j
{
System.out.println(my_array[i][j]);
}
System.out.println("\t");
}
}
void check_repeat() //once a state has been traversed it must not be visited again
{
int element;
for(i=0;i
{
elements.clear();
for(j=0;j
{
element=my_array[i][j];
if(elements.contains(element))
{
my_array[i][j]=mynum+1;
}
else
elements.add(element);
}
}
}
void iodegree() //was To calculate input/output degree though here only indegree is being referred
{
int element;
for(i=0;i
for(j=0;j
{
element=my_array[i][j];
if(element
{
temp_array[element]++;
}
else
{}
}
}
void print_temp_array()
{
int k;
for(k=0;k
{
System.out.println(" "+temp_array[k]);
}
}
void initialize_set()
{
for(i=0;i
{
data_tr[i]=0;
set[i]=new HashSet();
for(j=0;j
matrixs_io[i][j]=0;
}
}
void travelled(int state) //if a state has been traversed add it to visited list
{
tr_data=data_tr[state];
++tr_data;
// System.out.println("Tr_data=+="+tr_data+"state=="+state);
data_tr[state]=tr_data;
// return data_tr[state];
}
void populate_main()
{
for(i=0;i
for(j=0;j
{
// System.out.println("I: " + i + "J:" + j);
if(my_array[i][j]>=mynum||my_array[i][j]==i)
{
matrixs_io[i][j]=-1;
}
else
{
matrixs_io[i][j]=temp_array[my_array[i][j]];
}
// matrixs[i][j].pre_tarv=travelled(i);
}
}
void print_populate()
{
for(i=0;i
for(j=0;j
{
System.out.println("["+i+"]"+"["+j+"]");
System.out.println("IO_degree= "+matrixs_io[i][j]);//+" Pre Traversed= "+matrixs[i][j].pre_tarv);
}
}
/*void det_path(int start)
{
++count;
System.out.println("Count="+count);
i=start;
System.out.println("next=="+start);
//path[i].add(start);
if(paths.contains(i))
{
System.out.println("State getting repeated:"+i);
}
else
{
paths.add(i);
data_tr[i]=+1;
}
while(count<=input)
{
for(j=0;j
{
sum=matrixs_io[i][j]+data_tr[j];
if(max
{ System.out.println("Max="+max);
max=sum;}
else continue;
}
// System.out.println("States having same max");
// for(i=0;i
for(j=0;j
{
if(matrixs_io[i][j]+data_tr[j]==max )
{
System.out.println("State in row:"+matrix[i][j]);
if(count<=input && !(paths.contains(matrix[i][j]))) {
// path[i].add(matrix[i][j]);
det_path(matrix[i][j]);
}
else
{
det_path(matrix[i][j]);
}
}
System.out.println("path contents:"+paths);
// Iterator itr=path[i].iterator();
while(itr.hasNext())
{
}
// System.out.println("Max value:"+max+"HashSet="+path[i]);
}
} }*/
// int find_next(int num)
void top()
{
int path=rand.nextInt(mynum);
path=0;
for(int i=0;i
{
throw_back=1;
if(check_var_start==mynum*2 && check_var_j==mynum*2)
{
System.out.println("---In top no cancel");
next_state(path,i);
print_path();
System.out.println("---In top no cancel");
}
else
{
System.out.println("-----In top 1st cancel--------");
System.out.println("Row-"+check_var_start+"column="+check_var_j);
next_state(path,i);
print_path();
System.out.println("-----In top 1st cancel-------");
}
my_array[check_var_start][check_var_j]=mynum+1;
}
}
int next_state(int path,int i) // To find the next state for the present state
{ int counter=0;
{
for(int s=0;s
{
count=0;
paths.clear();
det_count=0;
populate_main();
data_tr[s]=0;
determine_path(path,++counter,i);
}
}
//max_in_row(path);
return 0;
}
// int my_path[][]=new int[mynum][mynum];
int ks=0;
void determine_path(int start,int index,int i) //To find the final path
{
{
int max=0;
int last = 0;
// System.out.println("Path["+path[start]+"]"+" --Index="+index/*+"-->Paths="+paths*/);
path[index-1].add(start);
// System.out.println("start:"+start);
//my_path[++ks]=start;
if(check_var_start==mynum*2 && check_var_j==mynum*2)
max=max_in_row(start);
else
{
my_array[check_var_start][check_var_j]=mynum+1;
max=max_in_row(start);
}
for(j=0;j
{
if(my_array[start][j]==mynum+1)
{
continue;
}
else
{
if(max==matrixs_io[start][j]+data_tr[my_array[start][j]]) //&& !paths.contains(matrix[start][j]))
{
matrixs_io[start][j]=-1;
// System.out.println("Next state="+matrix[start][j]);
travelled(my_array[start][j]);
if(throw_back==1)
{
check_var_start=mynum*2;
check_var_j=mynum*2;
while(check_var_start==mynum*2 && check_var_j==mynum*2)
{
check_var_start=start;
check_var_j=j;
// matrix[check_var_start][check_var_j]=input+1;
}
}
throw_back=0;
if(++det_count<=mynum*mynum)
{
last=j;
determine_path(my_array[start][j],index,i);
System.out.println("Last="+last);
// System.out.println("start:"+my_array[start][j]);
}
}
}
}
// matrixs_io[start][last]=-1;
/* for(int w=0;w
for(int t=0;t
System.out.println("--Matrix_io="+w+" "+t+matrixs_io[w][t]);*/
}
}
int max_in_row(int row) //TO calcuate the happiness value for next node
{
int current=0;
for(j=0;j
{
if(my_array[row][j]==mynum+1)
{
// System.out.println("Arrival of a final state");
continue;
}
else
{
// System.out.println("io_data="+matrixs_io[row][j]+" data_tr="+data_tr[matrix[row][j]]);
max=matrixs_io[row][j]+data_tr[my_array[row][j]];
// if(!path[index].contains(matrix[row][j]))
if(max>current )
{
current=max;
// System.out.println("Max=="+current+"state=="+row);
}
else
{
continue;
}
}
}return current;
}
void print_visit()
{
for(int g=0;g
System.out.println("data["+g+"]="+data_tr[g]);
}
void print_path()
{
for(int k=0;k
System.out.println("path["+k+"]"+path[k]);
}
void print_ks()
{
// for(int ks=0;ks
// System.out.println("KS="+my_path[ks]);
}
}
----------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------main.java-------------------------------------------------------------
import java.io.IOException;
public class main {
public static void main(String args[]) throws IOException
{
BeeCore beecore=new BeeCore();
// beecore.RandomMatrix();
// beecore.fill_matrix();
//beecore.matrixprint();
beecore.print_fill_matrix();
beecore.check_repeat();
// beecore.matrixprint();
beecore.initialize_temp_array();
beecore.initialize_set();
beecore.iodegree();
beecore.print_temp_array();
// beecore.prox_states();
// int happiness=beecore.calculate_happiness();
// System.out.println("Happiness="+happiness);
beecore.populate_main();
beecore.print_populate();
// beecore.det_path();
// beecore.next_state();
// beecore.print_populate();
beecore.top();
// beecore.print_visit();
beecore.print_path();
// beecore.print_ks();
}
}
------------------------------------------------------------------------------------------------------------------------------