private void button2_Click(object sender, EventArgs e) { openFileDialog1 = new OpenFileDialog(); openFileDialog1.Title = @"Select Feature Model File"; var result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { try { //var text = File.ReadAllText(openFileDialog1.FileName); //var loaded = new NewGen(Model, true /* from file */); _model.LoadFM(openFileDialog1.FileName); _frame.LoadedModel(); } catch (IOException exc) { Console.WriteLine(exc.Message); } } }
private void PerformCommand(string[] argument) { //Console.WriteLine("Evaluate Arguments: " + parser.Arguments.Count); try { //string[] argument = parser.Arguments[0]; switch (argument[0]) { //[ARGUMENT] case "load": argument = argument.Skip(1).ToArray(); switch (argument[0]) { case COMMAND_PATH_FEATURE_MODEL: _model.LoadFM(argument[1]); Console.WriteLine("Feature Count: " + _model.Setting.NumberOfFeatures); break; case COMMAND_PATH_FEATURE_DISTRIBUTION: switch (argument[1]) { case COMMAND_NORMAL_RANDOM_FUNCTION: case COMMAND_UNIFORM_RANDOM_FUNCTION: feature_random_function_values = new double[2]; feature_random_function_values[0] = Convert.ToDouble(argument[2]); feature_random_function_values[1] = Convert.ToDouble(argument[3]); Console.WriteLine("Feature Random Function"); break; case COMMAND_EXP_RANDOM_FUNCTION: feature_random_function_values = new double[1]; feature_random_function_values[0] = Convert.ToDouble(argument[2]); Console.WriteLine("Feature Random Function"); break; default: Console.WriteLine("Feature Path: " + featurepath); break; } featurepath = argument[1]; break; case COMMAND_PATH_INTERACTION_DISTRIBUTION: switch (argument[1]) { case COMMAND_NORMAL_RANDOM_FUNCTION: case COMMAND_UNIFORM_RANDOM_FUNCTION: interaction_random_function_values = new double[2]; interaction_random_function_values[0] = Convert.ToDouble(argument[2]); interaction_random_function_values[1] = Convert.ToDouble(argument[3]); Console.WriteLine("Interaction Random Function"); break; case COMMAND_EXP_RANDOM_FUNCTION: interaction_random_function_values = new double[1]; interaction_random_function_values[0] = Convert.ToDouble(argument[2]); Console.WriteLine("Interaction Random Function"); break; default: Console.WriteLine("Interaction Path: " + featurepath); break; } interactionpath = argument[1]; break; case COMMAND_PATH_VARIANT_DISTRIBUTION: variantpath = argument[1]; Console.WriteLine("Variant Path: " + variantpath); break; } break; case "set": // SET [ARGUMENT] argument = argument.Skip(1).ToArray(); switch (argument[0]) { //PATH case COMMAND_OUTPUT_PATH: output_path = argument[1]; break; case COMMAND_RANDOM_SEED: _model.SetRandomSeed(Convert.ToInt32(argument[1])); break; //FEATURE case COMMAND_FEATURES_SCALE_MIN: _model.Setting.FeatureScaleMin = Convert.ToDouble(argument[1]); break; case COMMAND_FEATURES_SCALE_MAX: _model.Setting.FeatureScaleMax = Convert.ToDouble(argument[1]); break; //INTERACTION case COMMAND_FEATUREMODEL_NUMBER_OF_INTERACTIONS: int value; if (int.TryParse(argument[1], out value)) { _model.Setting.NumberOfInteractions = Convert.ToInt32(value); } else { string[] SplitArgument = argument[1].Split('_'); if (SplitArgument.Length > 1 && SplitArgument[0].Equals(COMMAND_INTERACTIONS_RELATIVE)) { string[] relativeInteractionSplit = SplitArgument[1].Split('#'); List <double> relativeInteractionValues = new List <double>(); _model.Setting.AllRelativeInteractions = new List <List <BinaryOption> >(); for (int i = 0; i < relativeInteractionSplit.Length; i++) { double relativeNumber = Convert.ToDouble(relativeInteractionSplit[i]); List <List <BinaryOption> > interactions = SelectRelativeInteractions(i + 2, relativeNumber); relativeInteractionValues.Add(interactions.Count()); _model.Setting.AllRelativeInteractions.AddRange(interactions); } _model.Setting.InteractionOrderPercent = Scaleto100(relativeInteractionValues); _model.Setting.NumberOfInteractions = _model.Setting.AllRelativeInteractions.Count(); _model.Setting.RelativeInteractions = true; } } break; case COMMAND_FEATUREMODEL_INTERACTION: //_SET_ INTERACTION 0.2 0.3 0.4 argument = argument.Skip(1).ToArray(); //_SET_ _INTERACTION 0.2 0.3 0.4 for (int i = 0; i < argument.Count(); ++i) { interactionValues.Add(Convert.ToDouble(argument[i])); } if (!_model.Setting.RelativeInteractions) { _model.Setting.InteractionOrderPercent = Scaleto100(interactionValues); } break; case COMMAND_INTERACTIONS_SCALE_MIN: _model.Setting.InteractionScaleMin = Convert.ToDouble(argument[1]); break; case COMMAND_INTERACTIONS_SCALE_MAX: _model.Setting.InteractionScaleMax = Convert.ToDouble(argument[1]); break; case COMMAND_INTERACTIONS_GENERATE_ALL: _model.Setting.AllInteractions = Convert.ToBoolean(argument[1]); break; ///interactionValues.Add(a); //FEATURE MODEL case COMMAND_FEATUREMODEL_CALCULATE_FEATURE_FITNESS: _model.Setting.FeatureFitness = Convert.ToBoolean(argument[1]); break; case COMMAND_FEATUREMODEL_CALCULATE_INTERACTION_FITNESS: _model.Setting.InteracFitness = Convert.ToBoolean(argument[1]); break; case COMMAND_FEATUREMODEL_CALCULATE_VARIANT_FITNESS: _model.Setting.VariantFitness = Convert.ToBoolean(argument[1]); break; case COMMAND_FEATUREMODEL_CALCULATE_VARIANTS: _model.Setting.NoVariantCalculation = !Convert.ToBoolean(argument[1]); break; //EVOLUTION SETTING case COMMAND_EVOLUTION_LOGGING: _model.Setting.Logging = Convert.ToBoolean(argument[1]); break; case COMMAND_EVOLUTION_LOG_FOLDER: _model.Setting.LogFolder = argument[1]; break; case COMMAND_EVOLUTION_FIT_CRAMER_VON_MISES: _model.Setting.UseCmv = Convert.ToBoolean(argument[1]); break; case COMMAND_EVOLUTION_FIT_KOLMOGOROV_SMIRNOV: _model.Setting.UseKs = Convert.ToBoolean(argument[1]); break; case COMMAND_EVOLUTION_FIT_EUCLIDEAN_DISTANCE: _model.Setting.UseEuclidean = Convert.ToBoolean(argument[1]); break; case COMMAND_EVOLUTION_FIT_CHI_SQUARED_DISTANCE: _model.Setting.UseChiSquared = Convert.ToBoolean(argument[1]); break; case COMMAND_EVOLUTION_FIT_EUCLIDEAN_CMV: _model.Setting.EuclAndCmv = Convert.ToBoolean(argument[1]); break; case COMMAND_EVOLUTION_FIT_CHI_SQUARED_CMV: _model.Setting.ChiAndCmv = Convert.ToBoolean(argument[1]); break; case COMMAND_EVOLUTION_SCALE_MIN_MAX_VARIANT_DISTANCES: _model.Setting.ScaleToGlobalMinMax = Convert.ToBoolean(argument[1]); break; case COMMAND_EVOLUTION_ALGORITHM_MAX_EVALUATION: { int i = Convert.ToInt32(argument[1]); if (i < 0) { throw new WarningException("Must be > 0"); } _model.Setting.MaxEvaluations = i; break; } case COMMAND_EVOLUTION_ALGORITHM_POPULATION_SIZE: { int i = Convert.ToInt32(argument[1]); if (i < 0) { throw new WarningException("Must be > 0"); } _model.Setting.PopulationSize = i; break; } case COMMAND_EVOLUTION_ALGORITHM_EARLY_STOP: _model.Setting.StopEarly = Convert.ToBoolean(argument[1]); break; case COMMAND_EVOLUTION_ALGORITHM_EARLY_STOP_LEVEL: { int i = Convert.ToInt32(argument[1]); if (i < 0) { throw new WarningException("Must be > 0"); } _model.Setting.StopEarlyLevel = i; break; } case COMMAND_EVOLUTION_ALGORITHM_PARALLEL_NSGA_2: _model.Setting.Parallel = Convert.ToBoolean(argument[1]); break; //VARIANT GENERATION CONTROL case COMMAND_VARIANT_USE_RANDOM: _model.Setting.UseRnd = Convert.ToBoolean(argument[1]); break; case COMMAND_VARIANT_USE_FEATURE_WISE: _model.Setting.UseFw = Convert.ToBoolean(argument[1]); break; case COMMAND_VARIANT_USE_NEGATIVE_FEATURE_WISE: _model.Setting.UseNfw = Convert.ToBoolean(argument[1]); break; case COMMAND_VARIANT_USE_PAIR_WISE: _model.Setting.UsePw = Convert.ToBoolean(argument[1]); break; case COMMAND_VARIANT_USE_PSEUDO_RANDOM: _model.Setting.UsePseudoRnd = Convert.ToBoolean(argument[1]); break; case COMMAND_VARIANT_USE_RANDOM_LINEAR_VALUE: _model.Setting.LinearRandom = Convert.ToBoolean(argument[1]); break; case COMMAND_VARIANT_USE_RANDOM_QUADRATIC_VALUE: _model.Setting.QuadraticRandom = Convert.ToBoolean(argument[1]); break; case COMMAND_VARIANT_USE_ALL_VARIANT: _model.Setting.UseAllVariant = Convert.ToBoolean(argument[1]); break; //VARIANT VALUE CONTROL case COMMAND_VARIANT_RANDOM_VARIANT_GENERATION_SECONDS: seconds = Convert.ToInt32(argument[1]); if (seconds < 0) { break; } else { _model.Setting.UseRnd = true; _model.Setting.RndSeconds = seconds; } break; case COMMAND_VARIANT_TRESHOLD: seconds = Convert.ToInt32(argument[1]); if (seconds < 0) { break; } else { _model.Setting.UseRnd = true; _model.Setting.RndTreshold = seconds; } break; case COMMAND_VARIANT_MODULO: seconds = Convert.ToInt32(argument[1]); if (seconds < 0) { break; } else { _model.Setting.UseRnd = true; _model.Setting.RndModulo = seconds; } break; case COMMAND_VARIANT_FW_GENERATION_SECONDS: seconds = Convert.ToInt32(argument[1]); if (seconds < 0) { break; } else { _model.Setting.UseFw = true; _model.Setting.FwSeconds = seconds; } break; case COMMAND_VARIANT_NEGATIV_FW_GENERATION_SECONDS: seconds = Convert.ToInt32(argument[1]); if (seconds < 0) { break; } else { _model.Setting.UseNfw = true; _model.Setting.NfwSeconds = seconds; } break; case COMMAND_VARIANT_PAIR_WISE_GENERATION_SECONDS: seconds = Convert.ToInt32(argument[1]); if (seconds < 0) { break; } else { _model.Setting.UsePw = true; _model.Setting.PwSeconds = seconds; } break; case COMMAND_VARIANT_NUMBER_PER_CONFIGURATION_SIZE: seconds = Convert.ToInt32(argument[1]); if (seconds < 0) { break; } else { _model.Setting.UsePseudoRnd = true; _model.Setting.PseudoRndSize = seconds; } break; case COMMAND_VARIANT_LINEAR_CONFIG_START_SIZE: seconds = Convert.ToInt32(argument[1]); if (seconds < 0) { break; } else { _model.Setting.LinearRandom = true; _model.Setting.LinearRndSize = seconds; } break; case COMMAND_VARIANT_QUAD_CONFIG_START_SIZE: seconds = Convert.ToInt32(argument[1]); if (seconds < 0 || seconds > 50) { break; } else { _model.Setting.QuadraticRandom = true; _model.Setting.QuadraticRandomScale = seconds; } break; case COMMAND_VARIANT_SOLVER_TIMEOUT_SECONDS: seconds = Convert.ToInt32(argument[1]); if (seconds < 0) { break; } else { _model.Setting.SolverTimeout = seconds; } break; //SOLUTION case COMMAND_WEIGHT_FEATURE: weightValues[0] = Convert.ToDouble(argument[1]); break; case COMMAND_WEIGHT_INTERACTION: weightValues[1] = Convert.ToDouble(argument[1]); break; case COMMAND_WEIGHT_VARIANT: weightValues[2] = Convert.ToDouble(argument[1]); break; } break; case "show": argument = argument.Skip(1).ToArray(); switch (argument[0]) { case COMMAND_SHOW_FEATURE: break; case COMMAND_SHOW_INTERACTION: break; case COMMAND_SHOW_LINEAR: break; case COMMAND_SHOW_PSEUDORANDOM: break; case COMMAND_SHOW_QUADRATIC: break; case COMMAND_SHOW_SOLUTION: break; case COMMAND_SHOW_VARIANT: break; } break; } } catch (Exception e) { Console.WriteLine("Error!: " + argument[0]); } }