def main(argv): # This is required as plotting with wx does not allow wx.App.MainLoop to be started as a thread # I'm going to use the -o and -v option it can be changed anytime plot = False oBayesactSim = cBayesactSim(argv) # A hack, should probably be fixed later helpstring="Bayesact simulator (2 agents) usage:\n bayesactsim.py\n\t -t <number of trials (default 20)>\n\t -x <number of experiments per trial (default 10)>\n\t -n <number of samples (default 1000)>\n\t -c <client knowledge (0,1,2) (default 2)>\n\t -a <agent knowledge (0,1,2) (Default 0)>\n\t -u (if specified - do uniform draws)\n\t -d <max horizon - default 50>\n\t -r <roughening noise: default n^(-1/3) - to use no roughening ('full' method), specify 0>\n\t -e <environment noise (default 0.0)>\n\t -g <gamma_value (default 1.0)>\n\t -i <agent id label: default randomly chosen>\n\t -j <client id label: default randomly chosen>\n\t -k <agent gender (default: male) - only works if agent_id is specified with -i>\n\t -l (client gender (default: male) only works if client_id is specified with -j>" try: opts, args = getopt.getopt(argv[1:],"huvon:t:x:a:c:d:r:e:g:i:j:k:l:",["help","n=","t=","x=","c=","a=","u=","d=","r=","e=","g=","i=","j=","k=","l="]) except getopt.GetoptError: print helpstring sys.exit(2) for opt, arg in opts: if "-o" == opt: plot = True if (False == plot): oBayesactSim.startBayesactSim() else: from cPlotBayesactThread import cPlotBayesactThread plotter = cPlotBayesactThread() plotPanel = plotter.initFrame() plotter.initPlotBayesactSim(plotPanel) oBayesactSim.plotter = plotter bayesactSimThread = threading.Thread(target=oBayesactSim.startBayesactSim) plotter.setThread(bayesactSimThread) plotter.startApp()
def onStartBayesactSim(self, iEvent): self.m_StartButton.SetLabel("Restart") self.onStopBayesactSim() self.disableStartingOptions() self.updateBayesactFromSettings() self.m_BayesactSim.client_gender = str(self.m_OptionsAgentPanel.m_ClientGenderChoice.GetStringSelection()) self.m_BayesactSim.agent_gender = str(self.m_OptionsAgentPanel.m_AgentGenderChoice.GetStringSelection()) self.m_BayesactSim.client_id_label = str(self.m_OptionsAgentPanel.m_ClientIdentityTextBox.GetValue()) self.m_BayesactSim.agent_id_label = str(self.m_OptionsAgentPanel.m_AgentIdentityTextBox.GetValue()) plotter = cPlotBayesactThread() plotter.initPlotBayesactSim(self.m_PlotEPAPanel2D_A) plotter.addPanel(self.m_PlotEPAPanel2D_B) self.m_BayesactSim.plotter=plotter self.m_BayesactSim.terminate_flag = False self.m_BayesactSimThread = threading.Thread(target=self.m_BayesactSim.startBayesactSim) self.m_BayesactSim.thread_event = threading.Event() plotter.setThread(self.m_BayesactSimThread) plotter.startThread()
def main(argv): plot = False oBayesactInteractive = cBayesactInteractive(argv, plotter=None) # A hack, should probably be fixed later helpstring = "Bayesact simulator (2 agents) usage:\n bayesactsim.py\n\t -t <number of trials (default 20)>\n\t -x <number of experiments per trial (default 10)>\n\t -n <number of samples (default 1000)>\n\t -c <client knowledge (0,1,2) (default 2)>\n\t -a <agent knowledge (0,1,2) (Default 0)>\n\t -u (if specified - do uniform draws)\n\t -d <max horizon - default 50>\n\t -r <roughening noise: default n^(-1/3) - to use no roughening ('full' method), specify 0>\n\t -e <environment noise (default 0.0)>\n\t -g <gamma_value (default 1.0)>\n\t -i <agent id label: default randomly chosen>\n\t -j <client id label: default randomly chosen>\n\t -k <agent gender (default: male) - only works if agent_id is specified with -i>\n\t -l (client gender (default: male) only works if client_id is specified with -j>\n\t -m <gammae_value (default 0.0 or emotions not used)>\n\t" try: opts, args = getopt.getopt( argv[1:], "huvon:t:x:a:c:d:r:e:g:i:j:m:k:l:", [ "help", "n=", "t=", "x=", "c=", "a=", "u=", "d=", "r=", "e=", "g=", "i=", "j=", "k=", "l=" ]) except getopt.GetoptError: print helpstring sys.exit(2) for opt, arg in opts: if "-o" == opt: plot = True if (False == plot): oBayesactInteractive.startBayesactInteractive() else: from cPlotBayesactThread import cPlotBayesactThread plotter = cPlotBayesactThread() plotPanel = plotter.initFrame() plotter.initPlotBayesactSim(plotPanel) oBayesactInteractive.plotter = plotter bayesactSimThread = threading.Thread( target=oBayesactInteractive.startBayesactInteractive) plotter.setThread(bayesactSimThread) plotter.startApp()
def __init__(self, parent, iBayesactSim, iOptionsAgentPanel, iOptionsBayesactPanel, **kwargs): wx.Panel.__init__(self, parent, **kwargs) self.m_OptionsAgentPanel = iOptionsAgentPanel self.m_fidentitiesMale = None self.m_fidentitiesFemale = None self.m_PlotXAlign = 450 self.m_ComboBoxXDiscrepancy = 0 if (cSystemConstants.m_MacOS == cSystemConstants.m_OS): self.m_PlotXAlign = 500 self.m_ComboBoxXDiscrepancy = 50 # This right half of the panel holds the two plot panels for fundamental and tau # It is done like this so that you only draw on 2 panels instead of 4 # These are plot panels self.m_PlotEPAPanel2D_Fundamental = cPlotEPA2D.cPlotPanel(self, iXAxisItem=cOptionSimConstants.m_XAxisDefaultKey, iYAxisItem=cOptionSimConstants.m_YAxisDefaultKey, iPlotType=eEPA.fundamental, pos=(self.m_PlotXAlign, 10), size=(500, 275)) self.m_PlotEPAPanel2D_Fundamental.m_Title = "Fundamentals" self.m_PlotEPAPanel2D_Tau = cPlotEPA2D.cPlotPanel(self, iXAxisItem=cOptionSimConstants.m_XAxisDefaultKey, iYAxisItem=cOptionSimConstants.m_YAxisDefaultKey, iPlotType=eEPA.tau, pos=(self.m_PlotXAlign, 335), size=(500, 275)) self.m_PlotEPAPanel2D_Tau.m_Title = "Tau" self.m_PlotEPAPanel2D_Fundamental.m_TwinPlots.append(self.m_PlotEPAPanel2D_Tau) self.m_PlotEPAPanel2D_Tau.m_TwinPlots.append(self.m_PlotEPAPanel2D_Fundamental) self.m_ChangeXAxisStaticText = wx.StaticText(self, -1, "X Axis", pos=(530 + self.m_ComboBoxXDiscrepancy, 300)) self.m_ChangeXAxisComboBox = wx.ComboBox(self, -1, value=cOptionSimConstants.m_XAxisDefault, pos=(self.m_ChangeXAxisStaticText.GetPosition()[0] + 50, self.m_ChangeXAxisStaticText.GetPosition()[1] - 5), size=wx.DefaultSize, choices=cEPAConstants.m_EPALabels, style=wx.TE_READONLY) self.m_ChangeXAxisComboBox.Bind(wx.EVT_COMBOBOX, self.onChangeXAxis) self.m_ChangeXAxisStaticText = wx.StaticText(self, -1, "Y Axis", pos=(710 + self.m_ComboBoxXDiscrepancy, 300), size=self.m_ChangeXAxisStaticText.GetSize()) self.m_ChangeYAxisComboBox = wx.ComboBox(self, -1, value=cOptionSimConstants.m_YAxisDefault, pos=(self.m_ChangeXAxisStaticText.GetPosition()[0] + 50, self.m_ChangeXAxisStaticText.GetPosition()[1] - 5), size=wx.DefaultSize, choices=cEPAConstants.m_EPALabels, style=wx.TE_READONLY) self.m_ChangeYAxisComboBox.Bind(wx.EVT_COMBOBOX, self.onChangeYAxis) self.m_Plotter = cPlotBayesactThread() self.m_Plotter.addPanel(self.m_PlotEPAPanel2D_Fundamental) self.m_Plotter.addPanel(self.m_PlotEPAPanel2D_Tau) iBayesactSim.plotter = self.m_Plotter # This is the rectangular tab you see on the left half of the sim interactive tabs # The style indicates that the subset of these tabs' are on the left side self.m_SimInteractiveTabs = cSimInteractiveTabs(self, iBayesactSim, self.m_Plotter, iOptionsAgentPanel, iOptionsBayesactPanel, id=wx.ID_ANY, style=wx.BK_LEFT, size=(self.m_PlotXAlign, cBoundaries.m_GlobalWindowHeight)) self.m_Sizer = wx.BoxSizer(wx.VERTICAL) self.m_Sizer.Add(self.m_SimInteractiveTabs, -1) self.SetSizer(self.m_Sizer) self.Layout() self.Show()