Answer To: Stochastic systems For this assessment I ask you to implement Markov chains and to answer 6...
Abr Writing answered on Nov 06 2021
import java.lang.Math;
import java.util.*;
import java.io.PrintWriter;
class Markov {
public static void checkIn(String name, String login, double[] sol1, boolean[] sol2) {
System.out.println("****************************************************** ");
System.out.println(" ");
System.out.println(" ");
System.out.println("NAME: " + name + " " + login);
//###########
//Write feedback sheet
//##################
try {
PrintWriter writer = new PrintWriter("/home/cur/dfc/feedback" + ".mark", "UTF-8");
String domi = new String("Dominique Chu");
if (name.equals(domi)) {
name = "replacemexxx";
}
writer.println("************************************");
writer.println("************************************");
writer.println("Feedback for CO528 Assessment 1: Genetic Algorithms for " + name + " (" + login + ")");
writer.println("************************************");
writer.println("************************************");
} catch (Exception e) {
System.out.println(e);
}
}
//##################################
public static double getTransProb(int i, int j, int k) {
double g;
double[][] trans;
if (k == 4) {
trans = new double[][] {
{0.2, 0.4, 0.4, 0},
{0.4, 0.2, 0, 0.4},
{0.4, 0, 0.2, 0.4},
{0, 0.4, 0.4, 0.2}
};
g = trans[i-1][j-1];
} else {
trans = new double[][] {
{0.2, 0.2, 0.2, 0.2, 0, 0, 0.2, 0, 0},
{0.2, 0.2, 0.2, 0, 0.2, 0, 0, 0.2, 0},
{0.2, 0.2, 0.2, 0, 0, 0.2, 0, 0, 0.2},
{0.2, 0, 0, 1/4, 0.2, 0.2, 0.2, 0, 0},
{0, 0.2, 0, 0.2, 0.2, 0.2, 0, 0.2, 0},
{0, 0, 0.2, 0.2, 0.2, 0.2, 0, 0, 0.2},
{0.2, 0, 0, 0.2, 0, 0, 0.2, 0.2, 0.2},
...