NICETY_LEVEL = 2;

aaCodes = {{"A",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"K",
"L",
"M",
"N",
"P",
"Q",
"R",
"S",
"T",
"V",
"W",
"Y"}};

function PopulateModelMatrix (ModelMatrixName&, EFV)
{
	ModelMatrixName = {20,20};
		
	for (cI = 1; cI < 20; cI = cI+1)
	{
		commandString = "ModelMatrixName[0]["+cI+"]:=t*(1+(F_" + 
						 aaCodes[cI] +  "<0)*(Exp(F_"+
						 aaCodes[cI] + ")-1));\n" + 
						 "ModelMatrixName["+cI+"][0]:=t*(1+(0>" + "F_" + 
						 aaCodes[cI] + ")*(Exp(-F_"+
						 aaCodes[cI] + ")-1));\n"; 
		ExecuteCommands	 (commandString);
	}

	for (rI = 1; rI < 19; rI = rI+1)
	{
		for (cI = rI+1; cI < 20; cI = cI+1)
		{
			commandString = "ModelMatrixName["+rI+"]["+cI+"]:=t*(1+(F_" + 
							 aaCodes[cI] + "<" + "F_" + 
							 aaCodes[rI] + ")*(Exp(F_"+
							 aaCodes[cI] + "-F_"+
							 aaCodes[rI] + ")-1));\n" + 
							 "ModelMatrixName["+cI+"]["+rI+"]:=t*(1+(F_" + 
							 aaCodes[rI] + "<" + "F_" + 
							 aaCodes[cI] + ")*(Exp(F_"+
							 aaCodes[rI] + "-F_"+
							 aaCodes[cI] + ")-1));\n"; 
			ExecuteCommands	 (commandString);
		}
	}
	
	return 0;
}

commandString = "";

for (rI = 1; rI < 20; rI = rI+1)
{
	commandString = commandString + "global F_" + aaCodes[rI] + 
					"=0; F_" + aaCodes[rI] + ":>-1e10;\n";
}

ExecuteCommands (commandString);

vectorOfFrequencies = {20,1};

commandString = "global EFV_Norm:=1";
for (rI = 1; rI < 20; rI = rI+1)
{
	commandString = commandString+"+Exp(F_"+aaCodes[rI]+")";
}

ExecuteCommands (commandString+";");
vectorOfFrequencies[0]:=1/EFV_Norm;

for (rI = 1; rI < 20; rI = rI+1)
{
	commandString = "vectorOfFrequencies["+rI+"]:=Exp(F_"+aaCodes[rI]+")/EFV_Norm;";
	ExecuteCommands (commandString);
}

FitnessMatrix = 0;
MULTIPLY_BY_FREQS = PopulateModelMatrix ("FitnessMatrix",vectorOfFrequencies);
Model FitnessModel = (FitnessMatrix, vectorOfFrequencies, MULTIPLY_BY_FREQS);
FREQUENCY_SENSITIVE = 0;
