src-gu/mir-reasoner/src/reasoner/ApplyMIRReasonerPW.java
//Applies the MIRReasoner to the possible worlds problem using recursion
Applies the MIRReasoner to the possible worlds problem using recursion
Applies the MIRReasoner to the possible worlds problem using recursion
public static void main(String[] args) {
		if (args.length != 5){
			System.out.println("USAGE ERROR: ApplyMIRReasonerPW input_filename input_type output_filename output_type provenance_flag");
			return;
		}
		else if (!isFormatType(args[1])){
			System.out.println("Usage Error: input type must be either \"special\" or \"standard.\"");
			return;
		}
		else if (args.length == 5 && !isFormatType(args[3])){
			System.out.println("Usage Error: output type must be either \"special\" or \"standard.\"");
			return;
		}
		isProvenance = Boolean.valueOf(args[4]);
		try{
			Parser parser = new Parser(args[0], getFormatType(args[1]));
			TaxonomyInfo original = parser.getTaxonomyContents();
			MIRReasoner reasoner = new MIRReasoner(original);
			boolean isConsistent;
			if (!reasoner.runReasoner()){
				isConsistent = false;
				System.out.println("Inconsistent");
			}
			else{
				isConsistent = true;
				System.out.println("Consistent");
			}
			if (args.length == 5 || args.length == 6){
				reasoner.printMIR(new PrintStream(args[2]), getFormatType(args[3]), isProvenance);
				if(isConsistent){
					Parser outputParser = new Parser(args[2], getFormatType(args[3]));
					PossibleWorlds pw = new PossibleWorlds(outputParser.getTaxonomyContents());
					long numWorlds = pw.getNumWorlds();
					maxWorlds = numWorlds;
					if(numWorlds != 1){
						ArrayList<TaxonomyInfo> worlds = pw.createAllWorlds(original);
						FileOutputStream fos = new FileOutputStream(args[2], true);
						PrintStream output = new PrintStream(fos);
						for(TaxonomyInfo ti : worlds){
							MIRReasoner reasonerPW = new MIRReasoner(ti);
							if(!reasonerPW.runReasoner()){}
							else{
								runPW(ti, createTaxonomyInfo(reasonerPW.getArticulations(), reasoner.getT1(), reasoner.getT2()), output, args[3], reasonerPW.getLocalProvenance(), reasonerPW.getGlobalProvenance());
							}
						}
					}
				}
			}
		}
		catch(IOException ex1){
			System.out.println("Error: failed to access one of the given files.");
			System.out.println(ex1.getMessage());
		}
		catch(InvalidTokenException ex2){
			System.out.println("Error: file contains incorrect syntax.");
			System.out.println(ex2.getMessage());
		}
	}
public static void main ( String [ ] args ) { if ( args . length != 5 ) { System . out . println ( "USAGE ERROR: ApplyMIRReasonerPW input_filename input_type output_filename output_type provenance_flag" ) ; return ; } else if ( ! isFormatType ( args [ 1 ] ) ) { System . out . println ( "Usage Error: input type must be either \"special\" or \"standard.\"" ) ; return ; } else if ( args . length == 5 && ! isFormatType ( args [ 3 ] ) ) { System . out . println ( "Usage Error: output type must be either \"special\" or \"standard.\"" ) ; return ; } isProvenance = Boolean . valueOf ( args [ 4 ] ) ; try { Parser parser = new Parser ( args [ 0 ] , getFormatType ( args [ 1 ] ) ) ; TaxonomyInfo original = parser . getTaxonomyContents ( ) ; MIRReasoner reasoner = new MIRReasoner ( original ) ; boolean isConsistent ; if ( ! reasoner . runReasoner ( ) ) { isConsistent = false ; System . out . println ( "Inconsistent" ) ; } else { isConsistent = true ; System . out . println ( "Consistent" ) ; } if ( args . length == 5 || args . length == 6 ) { reasoner . printMIR ( new PrintStream ( args [ 2 ] ) , getFormatType ( args [ 3 ] ) , isProvenance ) ; if ( isConsistent ) { Parser outputParser = new Parser ( args [ 2 ] , getFormatType ( args [ 3 ] ) ) ; PossibleWorlds pw = new PossibleWorlds ( outputParser . getTaxonomyContents ( ) ) ; long numWorlds = pw . getNumWorlds ( ) ; maxWorlds = numWorlds ; if ( numWorlds != 1 ) { ArrayList < TaxonomyInfo > worlds = pw . createAllWorlds ( original ) ; FileOutputStream fos = new FileOutputStream ( args [ 2 ] , true ) ; PrintStream output = new PrintStream ( fos ) ; for ( TaxonomyInfo ti : worlds ) { MIRReasoner reasonerPW = new MIRReasoner ( ti ) ; if ( ! reasonerPW . runReasoner ( ) ) { } else { runPW ( ti , createTaxonomyInfo ( reasonerPW . getArticulations ( ) , reasoner . getT1 ( ) , reasoner . getT2 ( ) ) , output , args [ 3 ] , reasonerPW . getLocalProvenance ( ) , reasonerPW . getGlobalProvenance ( ) ) ; } } } } } } catch ( IOException ex1 ) { System . out . println ( "Error: failed to access one of the given files." ) ; System . out . println ( ex1 . getMessage ( ) ) ; } catch ( InvalidTokenException ex2 ) { System . out . println ( "Error: file contains incorrect syntax." ) ; System . out . println ( ex2 . getMessage ( ) ) ; } }
Applies the MIRReasoner to the possible worlds problem using recursion
Applies the MIRReasoner to the possible worlds problem using recursion
//if(args.length == 6){ //	maxWorlds = Integer.parseInt(args[5]); //}