def __init__(self, parent, id): #--------------------------------------------------------------------------- ExpertSettingPanel.__init__(self, parent, id) # sizer for widget setting sizer = wx.FlexGridSizer(0, 2, 5, 5) sizer.AddGrowableCol(1) self.SetSizer(sizer) # enable or disable the parallelization text = wx.StaticText(self, -1, "Status:") sizer.Add(text, 0, wx.ALIGN_BOTTOM | wx.LEFT | wx.RIGHT | wx.TOP, 10) self.parallelEnabled = wx.CheckBox(self, -1, "Enable Parallelization", \ name = "parallelization") self.parallelEnabled.SetValue(True) compat_wx.set_tool_tip(self.parallelEnabled, "Only available if compiled with OpenMP") sizer.Add(self.parallelEnabled, 0, wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, 10) # if enabled choose the number of used threads threadText = wx.StaticText(self, -1, "Number of Threads:") sizer.Add(threadText, 0, wx.ALIGN_BOTTOM | wx.LEFT | wx.RIGHT | wx.TOP, 10) try: # check available hardware import multiprocessing cpu_count = multiprocessing.cpu_count() except Exception: # when no multiprocessing module is available (python < 2.6) # assume 2 cores cpu_count = 2 # by default use all instead of one core cores_to_use = cpu_count - 1 if cores_to_use < 1: cores_to_use = 1 self.threadNum = wx.Slider(self, -1, cores_to_use, 1, cpu_count, style=wx.SL_LABELS) sizer.Add(self.threadNum, 0, wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, 10) # save the logical dependencies self.genericWidgets.append(self.parallelEnabled) #self.AddChildToParent(self.parallelEnabled, threadText) self.AddChildToParent(self.parallelEnabled, self.threadNum) # bind the EVT_CHECKBOX to the CheckBox self.BindEvent(wx.EVT_CHECKBOX, self.OnCheckBox, [self.parallelEnabled])
def AddSimpleTool(self, id, bitmap, help_string, callback=None, toggle=0): if not toggle: button = ButtonClass(self, id, bitmap, size=wx.Size(30,30)) else: button = ToggleButtonClass(self, id, bitmap, size=wx.Size(30,30)) button.SetBezelWidth(1) button.SetUseFocusIndicator(False) compat_wx.set_tool_tip(button, help_string) if callback: compat_wx.handle_event_1(self, wx.EVT_BUTTON, callback, id) self.sizer.Add(button, flag=wx.ALIGN_CENTER) self.sizer.SetSizeHints(self) self.controls.append(button) return button
def __init__(self, parent, id): #--------------------------------------------------------------------------- ExpertSettingPanel.__init__(self, parent, id) # sizer for widget setting sizer = wx.FlexGridSizer(0, 2, 5, 5) sizer.AddGrowableCol(1) self.SetSizer(sizer) # enable or disable the parallelization text = wx.StaticText(self, -1, "Status:") sizer.Add(text, 0, wx.ALIGN_BOTTOM | wx.LEFT | wx.RIGHT | wx.TOP, 10) self.parallelEnabled = wx.CheckBox(self, -1, "Enable Parallelization", \ name = "parallelization") self.parallelEnabled.SetValue(True) compat_wx.set_tool_tip(self.parallelEnabled, "Only available if compiled with OpenMP") sizer.Add(self.parallelEnabled, 0, wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, 10) # if enabled choose the number of used threads threadText = wx.StaticText(self, -1, "Number of Threads:") sizer.Add(threadText, 0, wx.ALIGN_BOTTOM | wx.LEFT | wx.RIGHT | wx.TOP, 10) try: # check available hardware import multiprocessing cpu_count = multiprocessing.cpu_count() except Exception: # when no multiprocessing module is available (python < 2.6) # assume 2 cores cpu_count = 2 # by default use all instead of one core cores_to_use = cpu_count - 1 if cores_to_use < 1: cores_to_use = 1 self.threadNum = wx.Slider(self, -1, cores_to_use, 1, cpu_count, style= wx.SL_LABELS) sizer.Add(self.threadNum, 0, wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, 10) # save the logical dependencies self.genericWidgets.append(self.parallelEnabled) #self.AddChildToParent(self.parallelEnabled, threadText) self.AddChildToParent(self.parallelEnabled, self.threadNum) # bind the EVT_CHECKBOX to the CheckBox self.BindEvent(wx.EVT_CHECKBOX, self.OnCheckBox, [self.parallelEnabled])
def AddMenuTool(self, id, text, help_string, callback=None, toggle=0): if not toggle: button = buttons.GenBitmapTextButton( self, id, None, text, size=wx.Size(48, 28)) else: button = buttons.GenBitmapTextToggleButton( self, id, None, text, size=wx.Size(48,28)) button.SetBitmapLabel(gamera_icons.getToolbarMenuBitmap()) button.SetBezelWidth(1) button.SetUseFocusIndicator(False) compat_wx.set_tool_tip(button, help_string) if callback: compat_wx.handle_event_1(self, wx.EVT_BUTTON, callback, id) self.sizer.Add(button, flag=wx.ALIGN_CENTER) self.sizer.SetSizeHints(self) self.controls.append(button) return button
def __init__(self, parent, id): #--------------------------------------------------------------------------- ExpertSettingPanel.__init__(self, parent, id) sizer = wx.GridBagSizer(hgap=5, vgap=5) self.SetSizer(sizer) # generational replacement self.genReplacement = wx.RadioButton(self, -1, "Generational Replacement", \ name = "generationalReplacement") sizer.Add(self.genReplacement, pos=(0,0), \ flag = wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, border=10) self.genericWidgets.append(self.genReplacement) # SSGA - replace worst self.ssgaWorse = wx.RadioButton(self, -1, "SSGA Worse Replacement", \ name = "SSGAworse") sizer.Add(self.ssgaWorse, pos=(1,0), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.genericWidgets.append(self.ssgaWorse) # SSGA deterministic tournament self.ssgaDetTour = wx.RadioButton(self, -1, "SSGA det. tournament", \ name = "SSGAdetTournament") self.ssgaDetTour.SetValue(True) sizer.Add(self.ssgaDetTour, pos=(2,0), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.ssgaDetTourTsize = wx.SpinCtrl(self, -1, size=(100,-1), \ min=2, max=10, value='3') # TODO: max = popSize compat_wx.set_tool_tip(self.ssgaDetTourTsize, "Tournament size") sizer.Add(self.ssgaDetTourTsize, pos=(2,1), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.genericWidgets.append(self.ssgaDetTour) self.AddChildToParent(self.ssgaDetTour, self.ssgaDetTourTsize) # bind the EVT_RADIOBUTTON to the RadioButtons self.BindEvent(wx.EVT_RADIOBUTTON, self.OnRadioButton, \ [self.genReplacement, self.ssgaWorse, self.ssgaDetTour])
def __init__(self, parent, id): #--------------------------------------------------------------------------- ExpertSettingPanel.__init__(self, parent, id) sizer = wx.GridBagSizer(hgap=5, vgap=5) self.SetSizer(sizer) # roulette wheel selection self.roulettWheel = wx.RadioButton(self, -1, "Roulette wheel", \ name="rouletteWheel") sizer.Add(self.roulettWheel, pos=(0,0), \ flag = wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, border=10) self.genericWidgets.append(self.roulettWheel) # linear scaled fitness self.roulettWheelScaled = wx.RadioButton(self, -1, "Roulette wheel (lin. scaled)", \ name="rouletteWheelScaled") self.roulettWheelScaled.SetValue(True) sizer.Add(self.roulettWheelScaled, pos=(1,0), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.roulettWheelPreasure = FS.FloatSpin(self, -1, min_val=0.0, max_val=2.0, \ increment=0.01, value=2.0) self.roulettWheelPreasure.SetFormat("%f") self.roulettWheelPreasure.SetDigits(2) compat_wx.set_tool_tip(self.roulettWheelPreasure, "The selective pressure") sizer.Add(self.roulettWheelPreasure, pos=(1,1), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.genericWidgets.append(self.roulettWheelScaled) self.AddChildToParent(self.roulettWheelScaled, self.roulettWheelPreasure) # stochastic universal sampling self.stochUniSampling = wx.RadioButton(self, -1, "Stochastic universal sampling", \ name="stochUniSampling") sizer.Add(self.stochUniSampling, pos=(2,0), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.genericWidgets.append(self.stochUniSampling) # rank selection self.rankSelection = wx.RadioButton(self, -1, "Rank selection", name="rankSelection") sizer.Add(self.rankSelection, pos=(3,0), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.rankSelectionPreasure = FS.FloatSpin(self, -1, min_val=0.0, max_val=2.0, \ increment=0.01, value=2.0) self.rankSelectionPreasure.SetFormat("%f") self.rankSelectionPreasure.SetDigits(2) self.rankSelectionPreasure.Disable() compat_wx.set_tool_tip(self.rankSelectionPreasure, "The selective pressure") sizer.Add(self.rankSelectionPreasure, pos=(3,1), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.rankSelectionExponent = FS.FloatSpin(self, -1, min_val=0.0, max_val=2.0, \ increment=0.01, value=1.0) self.rankSelectionExponent.SetFormat("%f") self.rankSelectionExponent.SetDigits(2) self.rankSelectionExponent.Disable() compat_wx.set_tool_tip(self.rankSelectionExponent, "Exponent") sizer.Add(self.rankSelectionExponent, pos=(3,2), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.genericWidgets.append(self.rankSelection) self.AddChildToParent(self.rankSelection, self.rankSelectionPreasure) self.AddChildToParent(self.rankSelection, self.rankSelectionExponent) # tournament selection self.TournamentSelection = wx.RadioButton(self, -1, "Tournament selection", \ name="tournamentSelection") sizer.Add(self.TournamentSelection, pos=(4,0), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.TournamentSelectionTsize = wx.SpinCtrl(self, -1, size=(100,-1), \ min=2, max=25, value='3') # TODO: max = popSize self.TournamentSelectionTsize.Disable() compat_wx.set_tool_tip(self.TournamentSelectionTsize, "Tournament size") sizer.Add(self.TournamentSelectionTsize, pos=(4,1), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.genericWidgets.append(self.TournamentSelection) self.AddChildToParent(self.TournamentSelection, self.TournamentSelectionTsize) # random selection self.randomSelect = wx.RadioButton(self, -1, "Random selection", \ name="randomSelection") sizer.Add(self.randomSelect, pos=(5,0), \ flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=10) self.genericWidgets.append(self.randomSelect) # bind the EVT_RADIOBUTTON to the RadioButtons self.BindEvent(wx.EVT_RADIOBUTTON, self.OnRadioButton, \ [self.roulettWheel, self.roulettWheelScaled, self.stochUniSampling, self.rankSelection, self.TournamentSelection, self.randomSelect])
def __init__(self, parent, id): #--------------------------------------------------------------------------- ExpertSettingPanel.__init__(self, parent, id) sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) # ---------------- generic crossovers ---------------- genericBox = wx.StaticBox(self, -1, "Generic operations", size=(500,-1)) genericBoxSizer = wx.StaticBoxSizer(genericBox, wx.VERTICAL) genericFlexGridSizer = wx.FlexGridSizer(0, 2, 5, 5) genericBoxSizer.Add(genericFlexGridSizer, 0) sizer.Add(genericBoxSizer, 0, wx.ALL | wx.EXPAND, 10) # n point crossover (default: one point crossover) nPointSizer = wx.BoxSizer(wx.HORIZONTAL) genericBoxSizer.Add(nPointSizer, 0, wx.EXPAND) self.nPointCrossover = wx.CheckBox(self, -1, "N-Point crossover", \ name = "nPointCrossover") genericFlexGridSizer.Add(self.nPointCrossover, 0, \ wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5) self.nPointCrossoverN = wx.SpinCtrl(self, -1, size=(100,-1), \ min=1, max=10, value='1') # TODO: max = vector dimension self.nPointCrossoverN.Disable() compat_wx.set_tool_tip(self.nPointCrossoverN, "num crossover points") genericFlexGridSizer.Add(self.nPointCrossoverN, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5) self.genericWidgets.append(self.nPointCrossover) self.AddChildToParent(self.nPointCrossover, self.nPointCrossoverN) # uniform crossover self.uniformCrossover = wx.CheckBox(self, -1, "Uniform crossover", \ name = "uniformCrossover") self.uniformCrossover.SetValue(True) genericFlexGridSizer.Add(self.uniformCrossover, 0, \ wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5) self.uniformCrossoverPref = FS.FloatSpin(self, -1, min_val=0.0, max_val=1.0, \ increment=0.01, value=0.5) self.uniformCrossoverPref.SetFormat("%f") self.uniformCrossoverPref.SetDigits(2) compat_wx.set_tool_tip(self.uniformCrossoverPref, "Preference") genericFlexGridSizer.Add(self.uniformCrossoverPref, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5) self.genericWidgets.append(self.uniformCrossover) self.AddChildToParent(self.uniformCrossover, self.uniformCrossoverPref) # ---------------- real crossovers ---------------- realBox = wx.StaticBox(self, -1, "Real operations (affects only feature weighting)", size=(500,-1)) realBoxSizer = wx.StaticBoxSizer(realBox, wx.VERTICAL) realBoxFlexGridSizer = wx.FlexGridSizer(0, 2, 5, 5) realBoxSizer.Add(realBoxFlexGridSizer, 0) sizer.Add(realBoxSizer, 0, wx.ALL | wx.EXPAND, 10) # simulated binary crossover self.sbxCrossover = wx.CheckBox(self, -1, "SBX Crossover", \ name = "SBXcrossover") self.sbxCrossover.SetValue(True) self.sbxCrossover.Disable() realBoxFlexGridSizer.Add(self.sbxCrossover, 0, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5) self.sbxCrossoverEta = FS.FloatSpin(self, -1, min_val=0.01, max_val=10.0, \ increment=0.01, value=1.0) self.sbxCrossoverEta.SetFormat("%f") self.sbxCrossoverEta.SetDigits(2) self.sbxCrossoverEta.Disable() compat_wx.set_tool_tip(self.sbxCrossoverEta, "eta the amount of exploration "\ "OUTSIDE the parents in BLX-alpha notation") realBoxFlexGridSizer.Add(self.sbxCrossoverEta, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5) self.weightingWidgets.append(self.sbxCrossover) self.AddChildToParent(self.sbxCrossover, self.sbxCrossoverEta) # segment crossover self.segmentCrossover = wx.CheckBox(self, -1, "Segment Crossover", \ name = "segmentCrossover") self.segmentCrossover.Disable() realBoxFlexGridSizer.Add(self.segmentCrossover, 0, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5) self.segmentCrossoverAlpha = FS.FloatSpin(self, -1, min_val=0.01, max_val=10.0, \ increment=0.01, value=1.0) self.segmentCrossoverAlpha.SetFormat("%f") self.segmentCrossoverAlpha.SetDigits(2) self.segmentCrossoverAlpha.Disable() compat_wx.set_tool_tip(self.segmentCrossoverAlpha, "alpha the amount of exploration "\ "OUTSIDE the parents in BLX-alpha notation") realBoxFlexGridSizer.Add(self.segmentCrossoverAlpha, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5) self.weightingWidgets.append(self.segmentCrossover) self.AddChildToParent(self.segmentCrossover, self.segmentCrossoverAlpha) # hypercube crossover self.hypercubeCrossover = wx.CheckBox(self, -1, "Hypercube Crossover", \ name = "hypercubeCrossover") self.hypercubeCrossover.Disable() realBoxFlexGridSizer.Add(self.hypercubeCrossover, 0, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5) self.hypercubeCrossoverAlpha = FS.FloatSpin(self, -1, min_val=0.01, max_val=10.0, \ increment=0.01, value=1.0) self.hypercubeCrossoverAlpha.SetFormat("%f") self.hypercubeCrossoverAlpha.SetDigits(2) self.hypercubeCrossoverAlpha.Disable() compat_wx.set_tool_tip(self.hypercubeCrossoverAlpha, "alpha the amount of exploration "\ "OUTSIDE the parents in BLX-alpha notation") realBoxFlexGridSizer.Add(self.hypercubeCrossoverAlpha, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5) self.weightingWidgets.append(self.hypercubeCrossover) self.AddChildToParent(self.hypercubeCrossover, self.hypercubeCrossoverAlpha) # bind the EVT_CHECKBOX to the CheckBoxes self.BindEvent(wx.EVT_CHECKBOX, self.OnCheckBox, \ [self.nPointCrossover, self.uniformCrossover, self.sbxCrossover, self.segmentCrossover, self.hypercubeCrossover])
def __init__(self, parent, id): #--------------------------------------------------------------------------- ExpertSettingPanel.__init__(self, parent, id) sizer = wx.GridBagSizer(hgap=5, vgap=5) self.SetSizer(sizer) # best fitness self.bestFitness = wx.CheckBox(self, -1, "Perfect LOO-recognition reached", \ name = "bestFitnessStop") sizer.Add(self.bestFitness, pos=(0,0), \ flag = wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, border=10) self.genericWidgets.append(self.bestFitness) # generation counter self.maxGeneration = wx.CheckBox(self, -1, "Max. number of generations", \ name = "maxGenerations") sizer.Add(self.maxGeneration, pos=(1,0), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border = 10) self.maxGenerationCount = wx.SpinCtrl(self, -1, size=(100,-1), \ min=10, max=5000, value='100') compat_wx.set_tool_tip(self.maxGenerationCount, "Number of generations") self.maxGenerationCount.Disable() sizer.Add(self.maxGenerationCount, pos=(1,1), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.genericWidgets.append(self.maxGeneration) self.AddChildToParent(self.maxGeneration, self.maxGenerationCount) # fitness counter self.maxFitnessEval = wx.CheckBox(self, -1, "Max. number of fitness evals", \ name = "maxFitnessEvals") sizer.Add(self.maxFitnessEval, pos=(2,0), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.maxFitnessEvalCount = wx.SpinCtrl(self, -1, size=(100,-1), \ min=10, max=50000, value='5000') compat_wx.set_tool_tip(self.maxFitnessEvalCount, "Number of evaluations") self.maxFitnessEvalCount.Disable() sizer.Add(self.maxFitnessEvalCount, pos=(2,1), \ flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.genericWidgets.append(self.maxFitnessEval) self.AddChildToParent(self.maxFitnessEval, self.maxFitnessEvalCount) # steady state continue self.steadyContinue = wx.CheckBox(self, -1, "Steady state continue", \ name = "steadyStateStop") self.steadyContinue.SetValue(True) sizer.Add(self.steadyContinue, pos=(3,0), \ flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=10) self.steadyContinueMin = wx.SpinCtrl(self, -1, size=(100,-1), \ min=10, max=250000, value='40') compat_wx.set_tool_tip(self.steadyContinueMin, "Minimum generations") sizer.Add(self.steadyContinueMin, pos=(3,1), \ flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=10) self.steadyContinueNoChange = wx.SpinCtrl(self, -1, size=(100,-1), \ min=1, max=10000, value='10') compat_wx.set_tool_tip(self.steadyContinueNoChange, "Generations without improvement") sizer.Add(self.steadyContinueNoChange, pos=(3,2), \ flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=10) self.genericWidgets.append(self.steadyContinue) self.AddChildToParent(self.steadyContinue, self.steadyContinueMin) self.AddChildToParent(self.steadyContinue, self.steadyContinueNoChange) # bind the EVT_CHECKBOX to the CheckBoxes self.BindEvent(wx.EVT_CHECKBOX, self.OnCheckBox, \ [self.bestFitness, self.maxGeneration, self.maxFitnessEval, self.steadyContinue])
def __init__(self, parent, id): #--------------------------------------------------------------------------- ExpertSettingPanel.__init__(self, parent, id) sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) # ---------------- generic mutations ---------------- genericBox = wx.StaticBox(self, -1, "Generic operations", size=(500,-1)) genericBoxSizer = wx.StaticBoxSizer(genericBox, wx.HORIZONTAL) sizer.Add(genericBoxSizer, 0, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 10) # shift mutation self.shiftMutation = wx.CheckBox(self, -1, "Shift Mutation", \ name = "shiftMutation") genericBoxSizer.Add(self.shiftMutation, 0, \ wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5) self.genericWidgets.append(self.shiftMutation) # swap mutation self.swapMutation = wx.CheckBox(self, -1, "Swap Mutation", \ name = "swapMuation") self.swapMutation.SetValue(True) genericBoxSizer.Add(self.swapMutation, 0, \ wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5) self.genericWidgets.append(self.swapMutation) # inversion mutation self.inversionOrderMutation = wx.CheckBox(self, -1, "Inversion Order", \ name = "inversionMutation") genericBoxSizer.Add(self.inversionOrderMutation, 0, \ wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5) self.genericWidgets.append(self.inversionOrderMutation) # ---------------- binary mutations ---------------- binaryBox = wx.StaticBox(self, -1, "Binary operations (affects only feature selection)", size=(500,-1)) binaryBoxSizer = wx.StaticBoxSizer(binaryBox, wx.HORIZONTAL) sizer.Add(binaryBoxSizer, 0, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 10) # bit flip mutation self.binaryMutation = wx.CheckBox(self, -1, "Binary Mutation", \ name = "binaryMutation") self.binaryMutation.SetValue(True) binaryBoxSizer.Add(self.binaryMutation, 0, \ wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5) self.binaryMutationRate = FS.FloatSpin(self, -1, min_val=0.0, max_val=1.0, \ increment=0.01, value=0.05) self.binaryMutationRate.SetFormat("%f") self.binaryMutationRate.SetDigits(2) compat_wx.set_tool_tip(self.binaryMutationRate, "Rate of mutation") binaryBoxSizer.Add(self.binaryMutationRate, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5) self.selectionWidgets.append(self.binaryMutation) self.AddChildToParent(self.binaryMutation, self.binaryMutationRate) # ---------------- real mutations ---------------- realBox = wx.StaticBox(self, -1, "Real operations (affects only feature weighting)", size=(500,-1)) realBoxSizer = wx.StaticBoxSizer(realBox, wx.VERTICAL) realBoxFlexGridSizer = wx.FlexGridSizer(0, 3, 5, 5) realBoxSizer.Add(realBoxFlexGridSizer, 0) sizer.Add(realBoxSizer, 0, wx.ALL | wx.EXPAND, 10) # gauss mutation self.gaussMutation = wx.CheckBox(self, -1, "Gauss Mutation", \ name = "gaussMutation") self.gaussMutation.SetValue(True) self.gaussMutation.Disable() realBoxFlexGridSizer.Add(self.gaussMutation, 0, \ wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5) self.gaussMutationSigma = FS.FloatSpin(self, -1, min_val=0.01, max_val=10.0, \ increment=0.01, value=0.5) self.gaussMutationSigma.SetFormat("%f") self.gaussMutationSigma.SetDigits(2) self.gaussMutationSigma.Disable() compat_wx.set_tool_tip(self.gaussMutationSigma, "sigma the range for uniform nutation") realBoxFlexGridSizer.Add(self.gaussMutationSigma, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5) self.gaussMutationPchance = FS.FloatSpin(self, -1, min_val=0.0, max_val=1.0, \ increment=0.01, value=0.5) self.gaussMutationPchance.SetFormat("%f") self.gaussMutationPchance.SetDigits(2) self.gaussMutationPchance.Disable() compat_wx.set_tool_tip(self.gaussMutationPchance, "p_change the probability to "\ "change a given coordinate") realBoxFlexGridSizer.Add(self.gaussMutationPchance, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5) self.weightingWidgets.append(self.gaussMutation) self.AddChildToParent(self.gaussMutation, self.gaussMutationSigma) self.AddChildToParent(self.gaussMutation, self.gaussMutationPchance) # bind the EVT_CHECKBOX to the CheckBoxes self.BindEvent(wx.EVT_CHECKBOX, self.OnCheckBox, \ [self.shiftMutation, self.swapMutation, self.inversionOrderMutation, self.binaryMutation, self.gaussMutation])