/// <summary> /// Dump the current state of SPLConqueror to Files. /// </summary> /// <param name="pathArray">Array with file paths. Needs 5 paths. Data will be stored in these files.</param> /// <param name="mlSettings">Current ML_Settings, to save.</param> /// <param name="toSample">Sampling strategies to save.</param> /// <param name="toSampleValidation">Validation sampling strategies to save.</param> /// <param name="exp">Learning object to save.</param> /// <param name="history">Command history to save.</param> public static void dump(string[] path, ML_Settings mlSettings, List <SamplingStrategies> toSample, List <SamplingStrategies> toSampleValidation, Learning exp, CommandHistory history) { if (path.Length >= 1) { StreamWriter sw = new StreamWriter(path[0] + "GlobalState.xml"); sw.Write(PersistGlobalState.dump()); sw.Flush(); sw.Close(); sw = new StreamWriter(path[0] + "mlSettings.xml"); sw.Write(PersistMLSettings.dump(mlSettings)); sw.Flush(); sw.Close(); sw = new StreamWriter(path[0] + "toSample.xml"); sw.Write(PersistSampling.dump(toSample)); sw.Flush(); sw.Close(); sw = new StreamWriter(path[0] + "toSampleValidation.xml"); sw.Write(PersistSampling.dump(toSampleValidation)); sw.Flush(); sw.Close(); sw = new StreamWriter(path[0] + "learning.xml"); sw.Write(PersistLearning.dump(exp)); sw.Flush(); sw.Close(); sw = new StreamWriter(path[0] + "history.xml"); sw.Write(PersistCommandHistory.dump(history)); sw.Flush(); sw.Close(); } else { GlobalState.logError.logLine("Couldn't dump the data. Not all target paths are given"); } }
/// <summary> /// Recover the SPLConqueror data from files. /// </summary> /// <param name="pathArray">String array with the file paths. Needs 6 file paths.</param> /// <returns>Tuple containing all recovered data.</returns> public static Tuple <ML_Settings, List <SamplingStrategies>, List <SamplingStrategies> > recoverDataFromDump(string[] path) { if (path.Length >= 1) { PersistGlobalState.recoverFromPersistentDump(path[0] + "GlobalState.xml"); ML_Settings mlSettings = PersistMLSettings.recoverFromPersistentDump(path[0] + "mlSettings.xml"); List <SamplingStrategies> toSample = PersistSampling.recoverFromDump(path[0] + "toSample.xml"); List <SamplingStrategies> toSampleValidation = PersistSampling.recoverFromDump(path[0] + "toSampleValidation.xml"); List <List <string> > learningRounds = PersistLearning.recoverFromPersistentDump(path[0] + "learning.xml"); learningHistory = Tuple.Create(true, learningRounds.Last()); history = PersistCommandHistory.recoverFromDump(path[0] + "history.xml"); return(Tuple.Create(mlSettings, toSample, toSampleValidation)); } else { GlobalState.logError.logLine("Couldn't recover from dump. Not all source paths are given"); return(null); } }