Genetic Algorithm - 5 Generations  

Posted by Sue

import java.util.*;

public class Chromosome
{
private String [] chromosome;
private int [] value;
private int [] fitness;
private int no;
private int size;
private int parent1;
private int parent2;
private int xoverPoint = 0;
private String offspring1;
private String offspring2;
private int fitnessOS1;
private int fitnessOS2;
private int valueOS1;
private int valueOS2;
private int probC;
private int probM;
private boolean crossover;
private boolean mutation;
private int choose1;
private int choose2;
private Random r = new Random();

public Chromosome(int noNew, int sizeNew)
{
no = noNew;
chromosome = new String[no];
value = new int[no];
fitness = new int[no];
crossover = false;
mutation = false;
size = sizeNew;
}

//method for executing generations - somewhat like a semi-main method :p
public String doGeneration()
{
int generation = 1;
String output = "[ - G E N E R A T I O N "+generation+" - ]\n\n";
String xoverStatus = "";
String mutateStatus = "";
int size;
int sum;
double average;

randomPopulation();

size = chromosome[0].length();

calculateFitness();

sum = calculateSum();
average = sum/no;

for (int i=0; i<no; i++)
{
output += "NO - "+(i+1)+"\nCHROMOSOME - "+chromosome[i]+"\nVALUE - "+value[i]+"\nFITNESS - "+fitness[i]+"\n";
}

while (generation&#605)
{
selectParents();
performCrossover();
calcOffspringFitness();

if (!crossover)
xoverStatus = "NO CROSSOVER OCCURED.\n\n";
else
xoverStatus = "CROSSOVER OCCURED AT POINT = "+xoverPoint+"\n\n";

output +="\n\n\n- s e l e c t e d p a r e n t s -\n\nPARENT 1 - "+chromosome[parent1]+"\nFITNESS - "+fitness[parent1]+"\nPARENT 2 - "+chromosome[parent2]+"\nFITNESS - "+fitness[parent2]+"\n\n\n";
output +="- c r o s s o v e r -\n\nPROBABILITY OF CROSSOVER = "+probC+"/100\n\n"+xoverStatus+"OFFSPRING 1 - "+offspring1+"\nFITNESS - "+fitnessOS1+"\n\nOFFSPRING 2 - "+offspring2+"\nFITNESS - "+fitnessOS2+"\n\n\n";

performMutation();

if (!mutation)
mutateStatus = "NO MUTATION OCCURED.\n\n";
else
mutateStatus = "MUTATION OCCURED\n\n";

output +="- m u t a t i o n -\n\nPROBABILITY OF MUTATION = "+probM+"/100\n\n"+mutateStatus+"OFFSPRING 1 - "+offspring1+"\nFITNESS - "+fitnessOS1+"\n\nOFFSPRING 2 - "+offspring2+"\nFITNESS - "+fitnessOS2+"\n\n\n";

generation++;

output +="[ - G E N E R A T I O N "+generation+" - ]\n\n";

replace();
sum = calculateSum();
average = sum/no;

output += "REPLACED "+(choose1+1)+" WITH OFFSPRING 1: "+offspring1+"\n";
output += "REPLACED "+(choose2+1)+" WITH OFFSPRING 2: "+offspring2+"\n\n";

calculateFitness();

sum = calculateSum();
average = sum/no;

for (int i=0; i<no; i++)
{
output += "NO - "+(i+1)+"\nCHROMOSOME - "+chromosome[i]+"\nVALUE - "+value[i]+"\nFITNESS - "+fitness[i]+"\n";
}

output+="\nSUM = "+sum;
output+="\nAVERAGE = "+average;

}

return output;
}

//method for generating a random population. will be run once in goGeneration method
private void randomPopulation()
{
int part;
for (int i=0; i<no; i++)
{
chromosome[i] = "";
for (int j=0; j<size; j++)
{
part = r.nextInt(2);
chromosome[i] += "" + part;
}
}
}

//method for calculating each of the chromosome's fitness
private void calculateFitness()
{
int part;
for (int i=0; i<no; i++)
{
size = chromosome[i].length();
value[i] = 0;
for (int j=0; j<size; j++)
{
part = Integer.parseInt(chromosome[i].charAt(j)+"");
if (part==1)
{
value[i] += Math.pow(2,((size-1)-j));
}
}
fitness[i] = (value[i]*value[i]) - value[i];
}
}

//method for calculating total fitness of all chromosomes
private int calculateSum()
{
int sum = 0;
for (int i=0; i<no; i++)
{
sum += fitness[i];
}
return sum;
}

//method for selecting parents with the highest fitness
private void selectParents()
{
int maxfitness1 = 0;

for (int i=0; i<no; i++)
{
if (fitness[i] > maxfitness1)
{
parent1 = i;
maxfitness1 = fitness[i];
}
}

int maxfitness2 = 0;

for (int i=0; i<no; i++)
{
if (fitness[i] > maxfitness2 && fitness[i] != maxfitness1)
{
parent2 = i;
maxfitness2 = fitness[i];
}
}
}

//method for performing crossover
private void performCrossover() {
probC = r.nextInt(100);
if (probC>70)
{
xoverPoint = r.nextInt(size);
offspring1 = (chromosome[parent1]).substring(0,xoverPoint);
offspring1 = offspring1 + (chromosome[parent2]).substring(xoverPoint,size);
offspring2 = (chromosome[parent2]).substring(0,xoverPoint);
offspring2 = offspring2 + (chromosome[parent1]).substring(xoverPoint,size);
crossover = true;
}
else
{
offspring1 = chromosome[parent1];
offspring2 = chromosome[parent2];
crossover = false;
}
}

//method for calculating offsprings' fitness
private void calcOffspringFitness()
{
int part1, part2;

valueOS1 =0;
valueOS2 = 0;

for (int j=0; j<size; j++)
{
part1 = Integer.parseInt(offspring1.charAt(j)+"");
part2 = Integer.parseInt(offspring2.charAt(j)+"");
if (part1==1)
valueOS1 += Math.pow(2,((size-1)-j));
if (part2==1)
valueOS2 += Math.pow(2,((size-1)-j));
}
fitnessOS1 = (valueOS1*valueOS1) - valueOS1;
fitnessOS2 = (valueOS2*valueOS2) - valueOS2;
}

//method for performing mutation
private void performMutation()
{
int size = offspring1.length();
Random r = new Random();
String temp;
int part1,part2;
int hold1, hold2;

probM = r.nextInt(100);

if (probM<20)
{
part1 = r.nextInt(size);
part2 = r.nextInt(size);
hold1 = Integer.parseInt(offspring1.charAt(part1)+"");
hold2 = Integer.parseInt(offspring2.charAt(part2)+"");
if (hold1 == 1)
{
temp = offspring1.substring(0,part1) + "0" + offspring1.substring(part1+1,size);
offspring1 = temp;
}
else
{
temp = offspring1.substring(0,part1) + "1" + offspring1.substring(part1+1,size);
offspring1 = temp;
}

if (hold2 == 1)
{
temp = offspring2.substring(0,part2) + "0" + offspring2.substring(part2+1,size);
offspring2 = temp;
}
else
{
temp = offspring2.substring(0,part2) + "1" + offspring2.substring(part2+1,size);
offspring2 = temp;
}
mutation = true;
}
else
mutation = false;


valueOS1 =0;
valueOS2 = 0;

for (int j=0; j<size; j++)
{
part1 = Integer.parseInt(offspring1.charAt(j)+"");
part2 = Integer.parseInt(offspring2.charAt(j)+"");
if (part1==1)
valueOS1 += Math.pow(2,((size-1)-j));
if (part2==1)
valueOS2 += Math.pow(2,((size-1)-j));
}
fitnessOS1 = (valueOS1*valueOS1) - valueOS1;
fitnessOS2 = (valueOS2*valueOS2) - valueOS2;
}

//method for replacing 2 of the original chromosomes with the two offsprings
private void replace()
{
choose2 = r.nextInt(no);
choose1 = r.nextInt(no);
int size = chromosome[0].length();
int part;

while(choose1==choose2)
{
choose2 = r.nextInt(no);
}

chromosome[choose1] = offspring1;
chromosome[choose2] = offspring2;

for (int i=0; i<no; i++)
{
size = chromosome[i].length();
value[i] = 0;
for (int j=0; j<size; j++)
{
part = Integer.parseInt(chromosome[i].charAt(j)+"");
if (part==1)
{
value[i] += Math.pow(2,((size-1)-j));
}
}
fitness[i] = (value[i]*value[i]) - value[i];
}

}

}

A Tribute  

Posted by Sue

I believe the passing of great artists whom we had all adored and cherish this past month had shocked us all - Michael Jackson controversial death on 26th June 2009 and Yasmin Ahmad's passing just a month later on the 25th July 2009. I grew up with MJ's songs and Yasmin Ahmad is my favourite director. Despite being criticised for their work/behaviour, they're an absolute inspiration to all of us.

I stumbled on this piece of article online. I don't know whether it's true. But I just want to share it with all of you.
Bismillahirrahmanirrahim..

Michael Jackson (MJ) was known as the most loving person in the world. He gave up most of his assets for charity and all his life, he fought for equality of the African Americans, AIDS victims, Against Drug Abuse, Against Abortion, Against Child Labor and secretly channelled his properties for the hungry children of the world. However, he wasn't peace at heart. He always think of himself as a child trapped inside a man's body. Being Peter Pan is all his dream, never to grow up, forever a child. That inspires him to build Neverland - a heaven for children. Children of all ages and races are welcomed to Neverland. MJ had so much love to give.

However, he made a mistake which he didn't know of the consequences. He saw the peaceful life his brother, Jermaine (Muhammad Abdul Aziz) had as a Muslim - true, Jermaine faced so much pressure that he moved to Bahrain.

In 1989, MJ made a press conference which shocked the world, "I have seen the Islam in the life of my brother, I have read the books about Islam. And I'd love to someday feel the calmness and peace of Islam...."

Since that, MJ's life was never the same again.
He was accused of so many accusations against child molestation. MJ was not someone who can deal with much pressure as he is a 'delicate child'. All the extortion and black mail followed after that. Everything he did was being seen as wrong in the eyes of the Media. All these are to influence his fans to hate MJ. If he is hated, then he would not be influencial anymore.

For several years, he stayed in England. Getting motivation from a long time friend, Cat Stevens, who had converted into Islam - named Yusuf Islam. From him, MJ learnt how Yusuf had survived being Muslim. He made friends with a song writer, Zain Bhikha too, who wrote a song titled, "GIVE THANKS TO ALLAH", which he wanted MJ to sing whenever he is ready.

Following his trial, MJ withdrew to Bahrain, where he was the special guest of sheik Abdullah bin Hamad Al Khalifa, the son of Bahrain’s king. It was then that Michael began to give conversion more “serious thought.”
MJ stayed in Bahrain for approximately 3 years. He studied Islam, the prayers and learn to read the Koran (al-Quran).



Finally, he came back to Los Angeles and in November 2008 MJ had formally converted to Islam in a ceremony at a close friend’s house in Los Angeles.
He perform Haj with the King of Bahrain and son on December 2008.



He had a hidden agenda when he wanted to make a final comeback. He announced in a press conference on March 2009, "This will be my final concert. I'll see you all in July...."

He planned that during his concert, he would announce that this is the FINAL concert as he wouldn't be performing anymore. He will declare that he is a Muslim and will only sing with Yusuf Islam and Friends.
At the end of the concert, he will be singing the song, "GIVE THANKS TO ALLAH" with Yusuf Islam. That is the reason why he chose London as his final concert venue instead of the USA. It was because he thought he could escape the USA's extortion, and that he could perform with yusuf Islam who is in England.

At 12.30am, 25th June 2009, he hugged his production manager and said, "After reherasing for 2 months, I am finally ready for the concert..."
Before leaving to sleep, he waved his dancers, "It was a good night everyone. I'll see you all tomorrow..."
The next thing... He was pronouced dead at 2.26am....

When 911 was called, there are so much questions asked. It is as if they didn't know who MJ is and where he lived. The questions asked are more towards to delay time.
The hospital said the autopsy result can only be obtained after 2 months - very illogical as even the worst African technology could obtain the result in less than 2 weeks.

MJ's family members opt for second private autopsy as they started to feel something fishy is going on. The result came out in about 4 days - MJ was drugged with high dosage of anaesthetic - drug that brings about a reversible loss of consciousness, if used to much could stop the heart from beating.

Another result which was not aired in the media was, MJ's stomach is empty of this drug, but his blood were filled with it - same case as the death of Marilyn Monroe.
The private doctors also found many needle marks, afraid to be forced injections given to MJ on his bed.

In CNN Live after a week, Barack Obama was interviewed. And he said, "I love MJ, I grew up listening to his songs. It is a great loss, but rest assured that there is no conspiracy in his death..."
Now, why must a President made such statement before the official autopsy result came out? How would he know that there is no conspiracy without the post-mortem result? Seems like someone is afraid of his shadows.

MJ was known to the world as a person who is against drug abuse. Why must he be addicted to drug, then? If he wanted to commit suicide, why rehearse for his concert? And why will he want to see his dancers the next day?

Enough about his death. I am sure people around the world is not stupid anymore. These supreme power can fool us during the Marilyn Monroe conspiracy, Martin Luther King and Princess Diana. But in this MJ's case, they left too many loopholes for those who think...!!

MJ left us with this unfinished studio-recorded song, GIVE THANKS TO ALLAH. You can download this song here:
http://www.filefactory.com/file/ahb80ff/n/Micheal_Jackson_-_Give_Thanks_To_Allah_mp3

MJ's family was about to give him a Muslim burial with the help of The Brotherhood of Islam. But, the CIA showed up at Neverland's door - blackmailed them that if they do so publicly, Katherine (MJ's mother) would be pull off from MJ's 3 children's custody as well as MJ's estates. Instead, they'll hire Debbie Rowe for the purpose, and the court will be in their favour. So much for democracy and fairness...

Finally, they agreed to let MJ have a Muslim Burial in Neverland. But in condition, must show to the public a Christian Memorial Service, as to prove to the world that MJ was never a Muslim.

So, Staples Centre was just a normal show. That's why the coffin was closed and sealed.

MJ was buried days earlier. The Gold Coffin was empty. They were about to bury the Coffin according to Christianity ways in Hollywood - as in their deal with the USA Government.

These happened, because the USA is afraid of the rising numbers of Muslims in the world.

(Sheikh Ha**d)
The Brotherhood of Islam
Buletin of Bahrain

I don't know about you and the rest of the world. But my family thought that it is indeed suspicious about his death - the ongoing autopsy, his burial place, Neverland, the coffin during his memorial at Staples Centre, etc... But I do hope Michael was Muslim when he died. Al-Fatihah to both him and Yasmin. I guess we could no longer read any of Yasmin's interesting posts anymore. ;(

Beadworks Feature  

Posted by Sue

I posted our beaded bracelets designs on Al-Fareeda Bazaar. Come and take a look at them. And try to order, will ya? :p


(Disregard the "COMING SOON" text. They're already ready to be ordered. I'm too lazy to edit. :P)

Price ranges from RM18 to RM20.

They're colour customisable - it means you can choose whatever colour of bracelet that you'd like to have and we'll make the bracelet for you. We can also shorten or add some length to your bracelet! I'd insist guys to buy these remarkable bracelets for their girlfriends. ;) Luckily my friends had the urge of doing so... I provided free delivery and even purchased a RM2.50 gift box for them with no extra charge! haha~ for friends' sake.

Simple Fettucini Carbonara ... My Supper + Breakfast + Lunch + Dinner  

Posted by Sue


I don't know what's wrong with me.. Recently I don't have the urge to eat. Hmm.. Anyway, since I realised I haven't had any meal today, I decided to pamper myself with some Italian food, malas style. ;D (malas means lazy in Malay)

Ingredients:
1/2 onion chopped (bawang besar yang warna kuning tu, biasa orang putih pakai ni untuk memasak)
1 sausage sliced (I use Ramlee's Beef Hotdogs)
250-300gm fettucini pasta
1 can of Prego's Cheese and Herbs
some oil, salt and parsley

Directions:

  1. Bring some water to boil in your cooking pot.
  2. Put the fettucini into the simmering water. And a pinch of salt.
  3. While the fettucini cooks, heat some oil in your saucepan. Stir in your chopped onions.
  4. When the onions are fragrant, pour a cup of water.
  5. Open up the Cheese and Herbs can and stir in the entire content into the saucepan.
  6. Put in the sliced sausages.
  7. Stir and wait until the sauce mixed well and thickens. Make sure the sausage is cooked.
  8. By the time you finished the sauce, your fettucini should be soft and ready to be drained.
  9. Mix both the drained fettucini and sauce together into a bowl.
  10. Sprinkle some parsley and you're done!

By the way, lately I've been receiving visitors from various countries. Hmm.. :)

Grab a Burqini for only RM100!  

Posted by Sue

Al-Fareeda Bazaar is NOW OPEN!

Jom beli burqini...! :D

Meet Minty the Hamster