/** 
 * @author YourAndrewIDHere
 * You should fill in the stub for this code file.  The
 * arguments will be given to you 
 */

import java.io.*;
import java.util.*;

public class DetermModelDriver {

	/**
	 * The first argument is the model filename
	 * 
	 * All other arguments are integers which are the NodeIDs of states 
	 * initially active in the simulation.
	 * 
	 * The last argument is potentially a flag indicating that a test run
	 * will be performed.
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		if(args.length < 2)
		{
			System.out.println("Usage: DetermModelDriver netDefFilename Active1 (Active2) ... (ActiveN) (-test)");
			return;
		}
		
		String networkFilename = args[0];
		ArrayList<Integer> initialActiveNodes = new ArrayList<Integer>();
		
		DetermNetwork network = new DetermNetwork(networkFilename);

		for(int i = 1; i < args.length; i++)
		{
			if(args[i].toLowerCase().equals("-test"))
			{
				ArrayList<Integer> activated = network.runTest(initialActiveNodes);
				
				System.out.println("Initial set " + initialActiveNodes + " activated " + activated.size() + " nodes");
				System.out.println(activated);
				return;
			}
			
			initialActiveNodes.add(Integer.parseInt(args[i]));
		}
		
		int[] one = {0};
		int oneCount = -1;
		int[] two = {0,0};
		int twoCount = -1;
		int[] three = {0,0,0};
		int threeCount = -1;
		
		ArrayList<Integer> active;
				
		for (int i = 0; i < network.numNodes; i++ ) {
			initialActiveNodes = new ArrayList<Integer>();
			initialActiveNodes.add(i);
			
			active = network.runTest(initialActiveNodes);
			if (active.size() > oneCount) {
				one[0] = i;
				oneCount = active.size(); }
			
			for (int j = i+1; j < network.numNodes; j++ ) {
				initialActiveNodes.add(j);
				
				active = network.runTest(initialActiveNodes);
				if (active.size() > twoCount) {
					two[0] = i; two[1] = j;
					twoCount = active.size(); }

				for (int k = j+1; k < network.numNodes; k++ ) {
					initialActiveNodes.add(k);
					
					active = network.runTest(initialActiveNodes);
					if (active.size() > threeCount) {
						three[0] = i; three[1] = j; three[2] = k;
						threeCount = active.size();	}
					
				}
			}
		}
		
		System.out.println("One: " + one[0]);
		System.out.println("Count: " + oneCount);
		System.out.println("Two: " + two[0] + "," + two[1]);
		System.out.println("Count: " + twoCount);
		System.out.println("Three: " + three[0] + "," + three[1] + "," + three[2]);
		System.out.println("Count: " + threeCount);
		

	}

}

