- Timestamp:
- 09/01/14 22:05:22 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java
r1707 r1710 79 79 public static int nThreads; 80 80 public static boolean harmonizeSequences; 81 public static boolean loadSubstutionMatrix; 81 82 82 83 … … 127 128 this.preparationTaskHandlingStrategy = new TaskHandlingStrategy( 128 129 minimalTaskEquality); 129 130 130 } 131 131 … … 140 140 } 141 141 142 public void saveAppData(String name) { 143 String objectName = name; 144 String filename = name + ".dat"; 145 Object dataObject = GlobalDataContainer.getInstance().getData( 146 objectName); 147 if (dataObject == null) { 148 CommandHelpers.objectNotFoundMessage(objectName); 149 } 150 FileOutputStream fos = null; 151 ObjectOutputStream out = null; 152 try { 153 fos = new FileOutputStream(filename); 154 out = new ObjectOutputStream(fos); 155 out.writeObject(dataObject); 156 out.close(); 157 } catch (IOException ex) { 158 Console.logException(ex); 159 } 160 } 161 162 public RuleApplicationData loadAppData(String name) { 163 String objectName = name; 164 String filename = name + ".dat"; 165 166 Object data = null; 167 FileInputStream fis = null; 168 ObjectInputStream in = null; 169 try { 170 fis = new FileInputStream(filename); 171 in = new ObjectInputStream(fis); 172 data = in.readObject(); 173 in.close(); 174 } catch (IOException ex) { 175 Console.logException(ex); 176 } catch (ClassNotFoundException ex) { 177 Console.logException(ex); 178 } 179 if (GlobalDataContainer.getInstance().addData(objectName, data)) { 180 CommandHelpers.dataOverwritten(objectName); 181 } 182 return (RuleApplicationData) GlobalDataContainer.getInstance().getData(name); 183 } 184 142 185 /* 143 186 * (non-Javadoc) … … 151 194 RuleApplicationData appData = new RuleApplicationData(sessions); 152 195 if(SequenceForTaskDetectionRuleAlignment.harmonizeSequences) { 196 //appData.getStopWatch().start("harmonization"); 153 197 harmonizeEventTaskInstancesModel(appData); 198 //appData.getStopWatch().stop("harmonization"); 199 GlobalDataContainer.getInstance().addData("harmonized", appData); 200 //Saving intermediate results to file 201 Console.traceln(Level.INFO,"saving substitution matrix to file"); 202 saveAppData("harmonized"); 203 } 204 else { 205 Console.traceln(Level.INFO,"loading substitution matrix from file"); 206 appData = loadAppData("harmonized"); 207 } 208 209 if(!SequenceForTaskDetectionRuleAlignment.loadSubstutionMatrix) { 154 210 Console.traceln(Level.INFO, "generating substitution matrix from " + appData.getUniqueTasks().size() + " unique tasks"); 211 appData.getStopWatch().start("substitution matrix"); 155 212 appData.getSubmat().generate(appData.getUniqueTasks()); 156 213 appData.getStopWatch().stop("substitution matrix"); 157 GlobalDataContainer.getInstance().addData("appData", appData); 158 //Saving intermediate results to file 159 Console.traceln(Level.INFO,"saving substitution matrix to file"); 160 String objectName = "appData"; 161 String filename = "appData.dat"; 162 Object dataObject = GlobalDataContainer.getInstance().getData( 163 objectName); 164 if (dataObject == null) { 165 CommandHelpers.objectNotFoundMessage(objectName); 166 } 167 FileOutputStream fos = null; 168 ObjectOutputStream out = null; 169 try { 170 fos = new FileOutputStream(filename); 171 out = new ObjectOutputStream(fos); 172 out.writeObject(dataObject); 173 out.close(); 174 } catch (IOException ex) { 175 Console.logException(ex); 176 } 214 GlobalDataContainer.getInstance().addData("substitution", appData); 215 saveAppData("substitution"); 177 216 } 178 217 else { 179 Console.traceln(Level.INFO,"loading substitution matrix from file"); 180 String objectName = "appData"; 181 String filename = "appData.dat"; 182 Object data = null; 183 FileInputStream fis = null; 184 ObjectInputStream in = null; 185 try { 186 fis = new FileInputStream(filename); 187 in = new ObjectInputStream(fis); 188 data = in.readObject(); 189 in.close(); 190 } catch (IOException ex) { 191 Console.logException(ex); 192 } catch (ClassNotFoundException ex) { 193 Console.logException(ex); 194 } 195 if (GlobalDataContainer.getInstance().addData(objectName, data)) { 196 CommandHelpers.dataOverwritten(objectName); 197 } 198 appData = (RuleApplicationData) GlobalDataContainer.getInstance().getData("appData"); 218 appData = loadAppData("substitution"); 199 219 } 200 220 … … 204 224 Console.traceln(Level.INFO, "Iteration Number: " + iteration); 205 225 iteration++; 206 226 207 227 appData.detectedAndReplacedTasks = false; 208 228 appData.getStopWatch().start("whole loop");
Note: See TracChangeset
for help on using the changeset viewer.