📄 dlefgnash.cc
字号:
}//========================================================================// class panelEfgEnumMixed//========================================================================class panelEfgEnumMixed : public panelEfgNashAlgorithm {private: wxRadioBox *m_solveUsing, *m_precision; wxCheckBox *m_findAll; wxSpinCtrl *m_stopAfter; // Private event handlers void OnFindAll(wxCommandEvent &);public: panelEfgEnumMixed(wxWindow *); efgNashAlgorithm *GetAlgorithm(void) const; DECLARE_EVENT_TABLE()};BEGIN_EVENT_TABLE(panelEfgEnumMixed, panelEfgNashAlgorithm) EVT_CHECKBOX(idCHECKBOX_FINDALL, panelEfgEnumMixed::OnFindAll)END_EVENT_TABLE()panelEfgEnumMixed::panelEfgEnumMixed(wxWindow *p_parent) : panelEfgNashAlgorithm(p_parent){ SetAutoLayout(true); wxBoxSizer *topSizer = new wxBoxSizer(wxHORIZONTAL); wxStaticBox *centerBox = new wxStaticBox(this, wxID_STATIC, "EnumMixedSolve"); wxStaticBoxSizer *centerSizer = new wxStaticBoxSizer(centerBox, wxVERTICAL); centerSizer->Add(new wxStaticText(this, wxID_STATIC, "Find Nash equilibria by enumerating " "mixed strategies"), 0, wxALL | wxCENTER, 5); wxString solveChoices[] = { "Extensive form", "Normal form" }; m_solveUsing = new wxRadioBox(this, -1, "Find equilibria using", wxDefaultPosition, wxDefaultSize, 2, solveChoices, 1, wxRA_SPECIFY_ROWS); m_solveUsing->SetSelection(1); m_solveUsing->Enable(false); centerSizer->Add(m_solveUsing, 0, wxALL | wxCENTER, 5); wxString precisionChoices[] = { "Floating point", "Rational" }; m_precision = new wxRadioBox(this, -1, "Precision", wxDefaultPosition, wxDefaultSize, 2, precisionChoices, 1, wxRA_SPECIFY_ROWS); centerSizer->Add(m_precision, 0, wxALL | wxCENTER, 5); wxStaticBox *stopAfterBox = new wxStaticBox(this, wxID_STATIC, "Number to find"); wxStaticBoxSizer *stopAfterSizer = new wxStaticBoxSizer(stopAfterBox, wxHORIZONTAL); m_findAll = new wxCheckBox(this, idCHECKBOX_FINDALL, "Find all"); m_findAll->SetValue(false); stopAfterSizer->Add(m_findAll, 0, wxALL | wxCENTER, 5); stopAfterSizer->Add(new wxStaticText(this, wxID_STATIC, "Stop after"), 0, wxALL | wxCENTER, 5); m_stopAfter = new wxSpinCtrl(this, -1, "1", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 10000); stopAfterSizer->Add(m_stopAfter, 0, wxALL | wxCENTER, 5); centerSizer->Add(stopAfterSizer, 0, wxALL | wxCENTER, 5); topSizer->Add(centerSizer, 1, wxALL | wxCENTER, 0); SetSizer(topSizer); topSizer->Fit(this); topSizer->SetSizeHints(this); Layout(); Show(false);}void panelEfgEnumMixed::OnFindAll(wxCommandEvent &){ m_stopAfter->Enable(!m_findAll->GetValue());}efgNashAlgorithm *panelEfgEnumMixed::GetAlgorithm(void) const{ SubgameSolver *algorithm = new SubgameSolver; if (m_precision->GetSelection() == 0) { nfgEnumMixed<double> *subAlgorithm = new nfgEnumMixed<double>; subAlgorithm->SetStopAfter((m_findAll->GetValue()) ? 0 : m_stopAfter->GetValue()); algorithm->SetAlgorithm(subAlgorithm); } else { nfgEnumMixed<gRational> *subAlgorithm = new nfgEnumMixed<gRational>; subAlgorithm->SetStopAfter((m_findAll->GetValue()) ? 0 : m_stopAfter->GetValue()); algorithm->SetAlgorithm(subAlgorithm); } return algorithm;}//========================================================================// class panelEfgLcp//========================================================================const int idCHECKBOX_LIMITDEPTH = 2002;class panelEfgLcp : public panelEfgNashAlgorithm {private: wxRadioBox *m_solveUsing, *m_precision; wxCheckBox *m_findAll, *m_limitDepth; wxSpinCtrl *m_stopAfter, *m_maxDepth; // Private event handlers void OnFindAll(wxCommandEvent &); void OnStopAfter(wxSpinEvent &); void OnLimitDepth(wxCommandEvent &);public: panelEfgLcp(wxWindow *); efgNashAlgorithm *GetAlgorithm(void) const; DECLARE_EVENT_TABLE()};BEGIN_EVENT_TABLE(panelEfgLcp, panelEfgNashAlgorithm) EVT_CHECKBOX(idCHECKBOX_FINDALL, panelEfgLcp::OnFindAll) EVT_SPINCTRL(idSPINCTRL_STOPAFTER, panelEfgLcp::OnStopAfter) EVT_CHECKBOX(idCHECKBOX_LIMITDEPTH, panelEfgLcp::OnLimitDepth)END_EVENT_TABLE()panelEfgLcp::panelEfgLcp(wxWindow *p_parent) : panelEfgNashAlgorithm(p_parent){ SetAutoLayout(true); wxBoxSizer *topSizer = new wxBoxSizer(wxHORIZONTAL); wxStaticBox *centerBox = new wxStaticBox(this, wxID_STATIC, "LcpSolve"); wxStaticBoxSizer *centerSizer = new wxStaticBoxSizer(centerBox, wxVERTICAL); centerSizer->Add(new wxStaticText(this, wxID_STATIC, "Find Nash equilibria via linear " "complementarity program"), 0, wxALL | wxCENTER, 5); wxString solveChoices[] = { "Extensive form", "Normal form" }; m_solveUsing = new wxRadioBox(this, -1, "Find equilibria using", wxDefaultPosition, wxDefaultSize, 2, solveChoices, 1, wxRA_SPECIFY_ROWS); centerSizer->Add(m_solveUsing, 0, wxALL | wxCENTER, 5); wxString precisionChoices[] = { "Floating point", "Rational" }; m_precision = new wxRadioBox(this, -1, "Precision", wxDefaultPosition, wxDefaultSize, 2, precisionChoices, 1, wxRA_SPECIFY_ROWS); centerSizer->Add(m_precision, 0, wxALL | wxCENTER, 5); wxStaticBox *stopAfterBox = new wxStaticBox(this, wxID_STATIC, "Number to find"); wxStaticBoxSizer *stopAfterSizer = new wxStaticBoxSizer(stopAfterBox, wxHORIZONTAL); m_findAll = new wxCheckBox(this, idCHECKBOX_FINDALL, "Find all"); m_findAll->SetValue(false); stopAfterSizer->Add(m_findAll, 0, wxALL | wxCENTER, 5); stopAfterSizer->Add(new wxStaticText(this, wxID_STATIC, "Stop after"), 0, wxALL | wxCENTER, 5); m_stopAfter = new wxSpinCtrl(this, idSPINCTRL_STOPAFTER, "1", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 10000); stopAfterSizer->Add(m_stopAfter, 0, wxALL | wxCENTER, 5); centerSizer->Add(stopAfterSizer, 0, wxALL | wxCENTER, 5); wxStaticBox *depthBox = new wxStaticBox(this, wxID_STATIC, "Algorithm behavior"); wxStaticBoxSizer *depthSizer = new wxStaticBoxSizer(depthBox, wxHORIZONTAL); m_limitDepth = new wxCheckBox(this, idCHECKBOX_LIMITDEPTH, "Limit depth"); m_limitDepth->SetValue(false); m_limitDepth->Enable(false); depthSizer->Add(m_limitDepth, 0, wxALL | wxCENTER, 5); depthSizer->Add(new wxStaticText(this, wxID_STATIC, "Maximum depth"), 0, wxALL | wxCENTER, 5); m_maxDepth = new wxSpinCtrl(this, -1, "10", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 1000); m_maxDepth->Enable(false); depthSizer->Add(m_maxDepth, 0, wxALL | wxCENTER, 5); centerSizer->Add(depthSizer, 0, wxALL | wxCENTER, 5); topSizer->Add(centerSizer, 1, wxALL | wxCENTER, 0); SetSizer(topSizer); topSizer->Fit(this); topSizer->SetSizeHints(this); Layout(); Show(false);}void panelEfgLcp::OnFindAll(wxCommandEvent &){ m_stopAfter->Enable(!m_findAll->GetValue()); m_limitDepth->Enable(m_findAll->GetValue() || m_stopAfter->GetValue() > 1); m_maxDepth->Enable((m_findAll->GetValue() || m_stopAfter->GetValue() > 1) && m_limitDepth->GetValue());}void panelEfgLcp::OnStopAfter(wxSpinEvent &){ m_limitDepth->Enable(m_stopAfter->GetValue() > 1); m_maxDepth->Enable(m_stopAfter->GetValue() > 1 && m_limitDepth->GetValue());}void panelEfgLcp::OnLimitDepth(wxCommandEvent &){ m_maxDepth->Enable(m_limitDepth->GetValue());}efgNashAlgorithm *panelEfgLcp::GetAlgorithm(void) const{ SubgameSolver *algorithm = new SubgameSolver; if (m_solveUsing->GetSelection() == 0) { if (m_precision->GetSelection() == 0) { efgLcp<double> *subAlgorithm = new efgLcp<double>; subAlgorithm->SetStopAfter((m_findAll->GetValue()) ? 0 : m_stopAfter->GetValue()); subAlgorithm->SetMaxDepth((m_limitDepth->GetValue()) ? m_maxDepth->GetValue() : 0); algorithm->SetAlgorithm(subAlgorithm); } else { efgLcp<gRational> *subAlgorithm = new efgLcp<gRational>; subAlgorithm->SetStopAfter((m_findAll->GetValue()) ? 0 : m_stopAfter->GetValue()); subAlgorithm->SetMaxDepth((m_limitDepth->GetValue()) ? m_maxDepth->GetValue() : 0); algorithm->SetAlgorithm(subAlgorithm); } } else { if (m_precision->GetSelection() == 0) { nfgLcp<double> *subAlgorithm = new nfgLcp<double>; subAlgorithm->SetStopAfter((m_findAll->GetValue()) ? 0 : m_stopAfter->GetValue()); subAlgorithm->SetMaxDepth((m_limitDepth->GetValue()) ? m_maxDepth->GetValue() : 0); algorithm->SetAlgorithm(subAlgorithm); } else { nfgLcp<gRational> *subAlgorithm = new nfgLcp<gRational>; subAlgorithm->SetStopAfter((m_findAll->GetValue()) ? 0 : m_stopAfter->GetValue()); subAlgorithm->SetMaxDepth((m_limitDepth->GetValue()) ? m_maxDepth->GetValue() : 0); algorithm->SetAlgorithm(subAlgorithm); } } return algorithm;}//========================================================================// class panelEfgLp//========================================================================class panelEfgLp : public panelEfgNashAlgorithm {private: wxRadioBox *m_solveUsing, *m_precision; wxCheckBox *m_findAll; wxSpinCtrl *m_stopAfter; // Private event handlers void OnFindAll(wxCommandEvent &);public: panelEfgLp(wxWindow *); efgNashAlgorithm *GetAlgorithm(void) const; DECLARE_EVENT_TABLE()};BEGIN_EVENT_TABLE(panelEfgLp, panelEfgNashAlgorithm) EVT_CHECKBOX(idCHECKBOX_FINDALL, panelEfgLp::OnFindAll)END_EVENT_TABLE()panelEfgLp::panelEfgLp(wxWindow *p_parent) : panelEfgNashAlgorithm(p_parent){ SetAutoLayout(true); wxBoxSizer *topSizer = new wxBoxSizer(wxHORIZONTAL); wxStaticBox *centerBox = new wxStaticBox(this, wxID_STATIC, "LpSolve"); wxStaticBoxSizer *centerSizer = new wxStaticBoxSizer(centerBox, wxVERTICAL); centerSizer->Add(new wxStaticText(this, wxID_STATIC, "Find Nash equilibria via linear " "program"), 0, wxALL | wxCENTER, 5); wxString solveChoices[] = { "Extensive form", "Normal form" }; m_solveUsing = new wxRadioBox(this, -1, "Find equilibria using", wxDefaultPosition, wxDefaultSize, 2, solveChoices, 1, wxRA_SPECIFY_ROWS); centerSizer->Add(m_solveUsing, 0, wxALL | wxCENTER, 5); wxString precisionChoices[] = { "Floating point", "Rational" }; m_precision = new wxRadioBox(this, -1, "Precision", wxDefaultPosition, wxDefaultSize, 2, precisionChoices, 1, wxRA_SPECIFY_ROWS); centerSizer->Add(m_precision, 0, wxALL | wxCENTER, 5); // The "find all" feature of LpSolve currently does not work; // therefore, the controls are disabled in this version wxStaticBox *stopAfterBox = new wxStaticBox(this, wxID_STATIC, "Number to find"); wxStaticBoxSizer *stopAfterSizer = new wxStaticBoxSizer(stopAfterBox, wxHORIZONTAL); m_findAll = new wxCheckBox(this, idCHECKBOX_FINDALL, "Find all"); m_findAll->SetValue(false); m_findAll->Enable(false); stopAfterSizer->Add(m_findAll, 0, wxALL | wxCENTER, 5); stopAfterSizer->Add(new wxStaticText(this, wxID_STATIC, "Stop after"), 0, wxALL | wxCENTER, 5); m_stopAfter = new wxSpinCtrl(this, -1, "1", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 10000); m_stopAfter->Enable(false); stopAfterSizer->Add(m_stopAfter, 0, wxALL | wxCENTER, 5); centerSizer->Add(stopAfterSizer, 0, wxALL | wxCENTER, 5); topSizer->Add(centerSizer, 1, wxALL | wxCENTER, 5); SetSizer(topSizer); topSizer->Fit(this); topSizer->SetSizeHints(this); Layout(); Show(false);}void panelEfgLp::OnFindAll(wxCommandEvent &){ m_stopAfter->Enable(!m_findAll->GetValue());}efgNashAlgorithm *panelEfgLp::GetAlgorithm(void) const{ SubgameSolver *algorithm = new SubgameSolver; if (m_solveUsing->GetSelection() == 0) { if (m_precision->GetSelection() == 0) { algorithm->SetAlgorithm(new efgLp<double>); } else { algorithm->SetAlgorithm(new efgLp<gRational>); } } else { if (m_precision->GetSelection() == 0) { algorithm->SetAlgorithm(new nfgLp<double>); } else { algorithm->SetAlgorithm(new nfgLp<gRational>); } } return algorithm;}//========================================================================// class panelEfgLiap//========================================================================class panelEfgLiap : public panelEfgNashAlgorithm {private: wxRadioBox *m_solveUsing; wxCheckBox *m_findAll; wxSpinCtrl *m_stopAfter, *m_numTries; wxSpinCtrl *m_maxits; // Private event handlers void OnFindAll(wxCommandEvent &);public: panelEfgLiap(wxWindow *); efgNashAlgorithm *GetAlgorithm(void) const; DECLARE_EVENT_TABLE()};BEGIN_EVENT_TABLE(panelEfgLiap, panelEfgNashAlgorithm) EVT_CHECKBOX(idCHECKBOX_FINDALL, panelEfgLiap::OnFindAll)END_EVENT_TABLE()panelEfgLiap::panelEfgLiap(wxWindow *p_parent) : panelEfgNashAlgorithm(p_parent){ SetAutoLayout(true); wxBoxSizer *topSizer = new wxBoxSizer(wxHORIZONTAL); wxStaticBox *centerBox = new wxStaticBox(this, wxID_STATIC, "LiapSolve"); wxStaticBoxSizer *centerSizer = new wxStaticBoxSizer(centerBox, wxVERTICAL); centerSizer->Add(new wxStaticText(this, wxID_STATIC, "Find Nash equilibria using " "Lyapunov function minimization"), 0, wxALL | wxCENTER, 5); wxString solveChoices[] = { "Extensive form", "Normal form" }; m_solveUsing = new wxRadioBox(this, -1, "Find equilibria using", wxDefaultPosition, wxDefaultSize, 2, solveChoices, 1, wxRA_SPECIFY_ROWS); centerSizer->Add(m_solveUsing, 0, wxALL | wxCENTER, 5); wxStaticBox *stopAfterBox = new wxStaticBox(this, wxID_STATIC, "Number to find"); wxStaticBoxSizer *stopAfterSizer = new wxStaticBoxSizer(stopAfterBox, wxHORIZONTAL); m_findAll = new wxCheckBox(this, idCHECKBOX_FINDALL, "No limit"); m_findAll->SetValue(false); stopAfterSizer->Add(m_findAll, 0, wxALL | wxCENTER, 5); stopAfterSizer->Add(new wxStaticText(this, wxID_STATIC, "Stop after"), 0, wxALL | wxCENTER, 5); m_stopAfter = new wxSpinCtrl(this, -1, "1", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 10000); stopAfterSizer->Add(m_stopAfter, 0, wxALL | wxCENTER, 5); centerSizer->Add(stopAfterSizer, 0, wxALL | wxCENTER, 5); wxStaticBox *algorithmBox = new wxStaticBox(this, wxID_STATIC, "Algorithm behavior"); wxStaticBoxSizer *algorithmSizer = new wxStaticBoxSizer(algorithmBox, wxHORIZONTAL); wxFlexGridSizer *paramSizer = new wxFlexGridSizer(2); paramSizer->Add(new wxStaticText(this, wxID_STATIC, "Number of restarts"), 0, wxALL | wxCENTER, 5); m_numTries = new wxSpinCtrl(this, -1, "100", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 10000); paramSizer->Add(m_numTries, 0, wxALL, 5); paramSizer->Add(new wxStaticText(this, wxID_STATIC, "Maximum iterations in minimization"), 0, wxALL | wxCENTER, 5); m_maxits = new wxSpinCtrl(this, -1, "500", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 10, 1000); paramSizer->Add(m_maxits, 0, wxALL | wxCENTER, 5); algorithmSizer->Add(paramSizer, 0, wxALL, 5); centerSizer->Add(algorithmSizer, 0, wxALL | wxCENTER, 5); topSizer->Add(centerSizer, 1, wxALL | wxCENTER, 0); SetSizer(topSizer); topSizer->Fit(this); topSizer->SetSizeHints(this); Layout(); Show(false);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -