// Define the cluster partition of a person (CentralStaff, SoutheastAsia,
// MaghrebArab, CoreArab, or Other)
int hasClusterPartitionState = 0;
ProbabilisticNode child = (ProbabilisticNode) pn
.getNode("hasClusterPartition_person");
PotentialTable table = ((PotentialTable) child.getProbabilityFunction());
int[] coord = new int[child.getParents().size() + 1];
ProbabilisticNode parent = (ProbabilisticNode) pn
.getNode("isTerrorist_person");
coord[table.getVariableIndex(parent)] = isTerroristState;
coord[0] = 0;
float centralStaffUpperBound = table.getValue(coord);
coord[0] = 1;
float southeastAsiaUpperBound = centralStaffUpperBound + table.getValue(coord);
coord[0] = 2;
float maghrebArabUpperBound = southeastAsiaUpperBound + table.getValue(coord);
coord[0] = 3;
float coreArabUpperBound = maghrebArabUpperBound + table.getValue(coord);
float randomProbability = (float) Math.random();
if (randomProbability <= centralStaffUpperBound) {
hasClusterPartitionState = 0;
person.setHasClusterPartition(ClusterPartition.CentralStaff);
} else if (randomProbability <= southeastAsiaUpperBound) {
hasClusterPartitionState = 1;
person.setHasClusterPartition(ClusterPartition.SoutheastAsia);
} else if (randomProbability <= maghrebArabUpperBound) {
hasClusterPartitionState = 2;
person.setHasClusterPartition(ClusterPartition.MaghrebArab);
} else if (randomProbability <= coreArabUpperBound) {
hasClusterPartitionState = 3;
person.setHasClusterPartition(ClusterPartition.CoreArab);
} else {
hasClusterPartitionState = 4;
person.setHasClusterPartition(ClusterPartition.Other);
}
// Define the person nationality (Egypt, SaudiArabia, etc)
child = (ProbabilisticNode) pn.getNode("hasNationality_person");
table = ((PotentialTable) child.getProbabilityFunction());
coord = new int[child.getParents().size() + 1];
parent = (ProbabilisticNode) pn.getNode("hasClusterPartition_person");
coord[table.getVariableIndex(parent)] = hasClusterPartitionState;
coord[0] = 0;
float egyptUpperBound = table.getValue(coord);
coord[0] = 1;
float saudiArabiaUpperBound = egyptUpperBound + table.getValue(coord);
coord[0] = 2;
float kuwaitUpperBound = saudiArabiaUpperBound + table.getValue(coord);
coord[0] = 3;
float jordanUpperBound = kuwaitUpperBound + table.getValue(coord);
coord[0] = 4;
float iraqUpperBound = jordanUpperBound + table.getValue(coord);
coord[0] = 5;
float sudanUpperBound = iraqUpperBound + table.getValue(coord);
coord[0] = 6;
float libyaUpperBound = sudanUpperBound + table.getValue(coord);
coord[0] = 7;
float lebannonUpperBound = libyaUpperBound + table.getValue(coord);
coord[0] = 8;
float indonesiaUpperBound = lebannonUpperBound + table.getValue(coord);
coord[0] = 9;
float malaysiaUpperBound = indonesiaUpperBound + table.getValue(coord);
coord[0] = 10;
float singaporeUpperBound = malaysiaUpperBound + table.getValue(coord);
coord[0] = 11;
float pakistanUpperBound = singaporeUpperBound + table.getValue(coord);
coord[0] = 12;
float philippinesUpperBound = pakistanUpperBound + table.getValue(coord);
coord[0] = 13;
float franceUpperBound = philippinesUpperBound + table.getValue(coord);
coord[0] = 14;
float algeriaUpperBound = franceUpperBound + table.getValue(coord);
coord[0] = 15;
float moroccoUpperBound = algeriaUpperBound + table.getValue(coord);
coord[0] = 16;
float syriaUpperBound = moroccoUpperBound + table.getValue(coord);
coord[0] = 17;
float tunisiaUpperBound = syriaUpperBound + table.getValue(coord);
coord[0] = 18;
float uaeUpperBound = tunisiaUpperBound + table.getValue(coord);
coord[0] = 19;
float yemenUpperBound = uaeUpperBound + table.getValue(coord);
randomProbability = (float) Math.random();
if (randomProbability <= egyptUpperBound) {
person.setHasNationality(Nationality.Egypt);
} else if (randomProbability <= saudiArabiaUpperBound) {
person.setHasNationality(Nationality.SaudiArabia);
} else if (randomProbability <= kuwaitUpperBound) {
person.setHasNationality(Nationality.Kuwait);
} else if (randomProbability <= jordanUpperBound) {
person.setHasNationality(Nationality.Jordan);
} else if (randomProbability <= iraqUpperBound) {
person.setHasNationality(Nationality.Iraq);
} else if (randomProbability <= sudanUpperBound) {
person.setHasNationality(Nationality.Sudan);
} else if (randomProbability <= libyaUpperBound) {
person.setHasNationality(Nationality.Libya);
} else if (randomProbability <= lebannonUpperBound) {
person.setHasNationality(Nationality.Lebannon);
} else if (randomProbability <= indonesiaUpperBound) {
person.setHasNationality(Nationality.Indonesia);
} else if (randomProbability <= malaysiaUpperBound) {
person.setHasNationality(Nationality.Malaysia);
} else if (randomProbability <= singaporeUpperBound) {
person.setHasNationality(Nationality.Singapore);
} else if (randomProbability <= pakistanUpperBound) {
person.setHasNationality(Nationality.Pakistan);
} else if (randomProbability <= philippinesUpperBound) {
person.setHasNationality(Nationality.Philippines);
} else if (randomProbability <= franceUpperBound) {
person.setHasNationality(Nationality.France);
} else if (randomProbability <= algeriaUpperBound) {
person.setHasNationality(Nationality.Algeria);
} else if (randomProbability <= moroccoUpperBound) {
person.setHasNationality(Nationality.Morocco);
} else if (randomProbability <= syriaUpperBound) {
person.setHasNationality(Nationality.Syria);
} else if (randomProbability <= tunisiaUpperBound) {
person.setHasNationality(Nationality.Tunisia);
} else if (randomProbability <= uaeUpperBound) {
person.setHasNationality(Nationality.UAE);
} else if (randomProbability <= yemenUpperBound) {
person.setHasNationality(Nationality.Yemen);
} else {
person.setHasNationality(Nationality.Other);
}
// Define the person economic standing (UpperClass, MiddleClass, or
// LowerClass)
child = (ProbabilisticNode) pn.getNode("hasEconomicStanding_person");
table = ((PotentialTable) child.getProbabilityFunction());
coord = new int[child.getParents().size() + 1];
parent = (ProbabilisticNode) pn.getNode("hasClusterPartition_person");
coord[table.getVariableIndex(parent)] = hasClusterPartitionState;
coord[0] = 0;
float upperClassUpperBound = table.getValue(coord);
coord[0] = 1;
float middleClassUpperBound = upperClassUpperBound + table.getValue(coord);
randomProbability = (float) Math.random();
if (randomProbability <= upperClassUpperBound) {
person.setHasEconomicStanding(EconomicStanding.UpperClass);
} else if (randomProbability <= middleClassUpperBound) {
person.setHasEconomicStanding(EconomicStanding.MiddleClass);
} else {
person.setHasEconomicStanding(EconomicStanding.LowerClass);
}
// Define the person education level (MiddleSchool, HighSchool, College,
// BA_BS, MA_MS, or PhD)
child = (ProbabilisticNode) pn.getNode("hasEducationLevel_person");
table = ((PotentialTable) child.getProbabilityFunction());
coord = new int[child.getParents().size() + 1];
parent = (ProbabilisticNode) pn.getNode("hasClusterPartition_person");
coord[table.getVariableIndex(parent)] = hasClusterPartitionState;
coord[0] = 0;
float middleSchoolUpperBound = table.getValue(coord);
coord[0] = 1;
float highSchoolUpperBound = middleSchoolUpperBound + table.getValue(coord);
coord[0] = 2;
float collegeUpperBound = highSchoolUpperBound + table.getValue(coord);
coord[0] = 3;
float baBsUpperBound = collegeUpperBound + table.getValue(coord);
coord[0] = 4;
float maMsUpperBound = baBsUpperBound + table.getValue(coord);
randomProbability = (float) Math.random();
if (randomProbability <= middleSchoolUpperBound) {
person.setHasEducationLevel(EducationLevel.MiddleSchool);
} else if (randomProbability <= highSchoolUpperBound) {
person.setHasEducationLevel(EducationLevel.HighSchool);
} else if (randomProbability <= collegeUpperBound) {
person.setHasEducationLevel(EducationLevel.College);
} else if (randomProbability <= baBsUpperBound) {
person.setHasEducationLevel(EducationLevel.BA_BS);
} else if (randomProbability <= maMsUpperBound) {
person.setHasEducationLevel(EducationLevel.MA_MS);
} else {
person.setHasEducationLevel(EducationLevel.PhD);
}
// Define the person occupation (Professional, SemiSkilled, or UnSkilled)
child = (ProbabilisticNode) pn.getNode("hasOccupation_person");
table = ((PotentialTable) child.getProbabilityFunction());
coord = new int[child.getParents().size() + 1];
parent = (ProbabilisticNode) pn.getNode("hasClusterPartition_person");
coord[table.getVariableIndex(parent)] = hasClusterPartitionState;
coord[0] = 0;
float professionalUpperBound = table.getValue(coord);
coord[0] = 1;
float semiSkilledUpperBound = professionalUpperBound + table.getValue(coord);
randomProbability = (float) Math.random();
if (randomProbability <= professionalUpperBound) {
person.setHasOccupation(Occupation.Professional);
} else if (randomProbability <= semiSkilledUpperBound) {
person.setHasOccupation(Occupation.SemiSkilled);