private void attemtp_Find_Solution (ArrayList<Juggler> input_juggle_list, Current_Solution_Info cur_sul)
{
int tmp_sort_list[];
//first get the number of available juggerls
int avail_j_num = input_juggle_list.size();

//System.out.println ("Now " + avail_j_num + "jugglers remain");

int tmp_sort_value[];
ArrayList<Juggler> remove_juggle_list = new ArrayList<Juggler>();
//sort the available jugger’s based on the current circuit and pref

tmp_sort_list = new int[avail_j_num];
//tmp_sort_value = new int[avail_j_num];

int tmp_count = 0;
for (int j = 0; j < avail_j_num; j++)
{

int j_num = input_juggle_list.get(j).get_Juggler_Index();
tmp_sort_list[tmp_count] = j_num;
tmp_count++;

}
//then do a sort
//quickSort(tmp_sort_value, 0, avail_j_num – 1, tmp_sort_list);

//starting from top of sort list
for (int j = 0; j < avail_j_num; j++)
{

int attempt_j_num = tmp_sort_list[j];
//try the circuits for this juggler in the following order
//first select from the preference list,the first, then second, then third then based on the product dot value for each circuit

int attempt_num = juggle_list.get(attempt_j_num).get_Prev_Circuit_Attempt_Num();
int attempt_c_num = juggle_list.get(attempt_j_num).get_CurrentTopPickCircuit(attempt_num);
attempt_num++;
boolean insert_j_flag = false;
while (attempt_c_num != -1)
{
//check to see if the attempt circuit is full
if (cur_sul.get_Circuit_Remain_Spots(attempt_c_num) > 0)
{
//just add the juggler straight into the circuit if it is not full
cur_sul.add_New_Sol(attempt_c_num, attempt_j_num);
//always set the number of attempts on circuit, so if this juggler got kicked
//next time he know where to start
juggle_list.get(attempt_j_num).set_Prev_Circuit_Attempt_Num(attempt_num);
insert_j_flag = true;
break;
} else
{
//this circuit is full
//remember all the juggers are already sorted in the circuit, so we start from the last one
//then check all the jugger already asigned to this circuit, if there is any juggler perform worse than me, kick worst one and pick me!
if (cur_sul.check_juggler_Better_Fit(attempt_c_num, attempt_j_num))
{
//we need to remove the last one and add the new juggler into the solution
int removed_j = cur_sul.remove_Circuit_Last_Jugger(attempt_c_num);

remove_juggle_list.add(juggle_list.get(removed_j));
//add the new juggler, what a sad day for the one who got kicked
cur_sul.add_New_Sol(attempt_c_num, attempt_j_num);
//same thing, set the number of attempts
juggle_list.get(attempt_j_num).set_Prev_Circuit_Attempt_Num(attempt_num);
insert_j_flag = true;
break;
}
}
//fail at this preference, try next one
attempt_c_num = juggle_list.get(attempt_j_num).get_CurrentTopPickCircuit( attempt_num);
attempt_num++;
}//end of while loop

if (!insert_j_flag)
{
//if none of this juggler’s preference was selected. just pick any circuit base on the product dot
attempt_num--;
attempt_c_num = juggle_list.get(attempt_j_num).get_Rest_Non_Pref_PickCircuit(attempt_num);
attempt_num++;
while (attempt_c_num != -1)
{
if (cur_sul.get_Circuit_Remain_Spots(attempt_c_num) > 0)
{
cur_sul.add_New_Sol(attempt_c_num, attempt_j_num);
juggle_list.get(attempt_j_num).set_Prev_Circuit_Attempt_Num(attempt_num);

insert_j_flag = true;
break;
}
attempt_c_num = juggle_list.get(attempt_j_num).get_Rest_Non_Pref_PickCircuit(attempt_num);
attempt_num++;
}
}
}//end of for loop

if ( remove_juggle_list.isEmpty())
return;
else
{
recursive_call_num++;
attemtp_Find_Solution (remove_juggle_list, cur_sul);
}
}