⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 efgensup.cc

📁 Gambit 是一个游戏库理论软件
💻 CC
📖 第 1 页 / 共 2 页
字号:
//// $Source: /home/gambit/CVS/gambit/sources/game/efgensup.cc,v $// $Date: 2002/08/26 05:50:06 $// $Revision: 1.3 $//// DESCRIPTION:// Enumerate undominated subsupports//// This file is part of Gambit// Copyright (c) 2002, The Gambit Project//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//#include "efgensup.h"// We build a series of functions of increasing complexity.  The// final one, which is our goal, is the undominated support function.// We begin by simply enumerating all subsupports.void AllSubsupportsRECURSIVE(const EFSupport *s,			     EFSupportWithActiveInfo *sact,			     ActionCursorForSupport *c,			     gList<const EFSupport> *list){   (*list) += sact->UnderlyingSupport();  ActionCursorForSupport c_copy(*c);  do {    if ( sact->ActionIsActive((Action *)c_copy.GetAction()) ) {      sact->RemoveAction(c_copy.GetAction());      AllSubsupportsRECURSIVE(s,sact,&c_copy,list);      sact->AddAction(c_copy.GetAction());    }  } while (c_copy.GoToNext()) ;}gList<const EFSupport> AllSubsupports(const EFSupport &S){  gList<const EFSupport> answer;  EFSupportWithActiveInfo SAct(S);  ActionCursorForSupport cursor(S);  AllSubsupportsRECURSIVE(&S,&SAct,&cursor,&answer);  return answer;}// Subsupports of a given support are _path equivalent_ if they// agree on every infoset that can be reached under either, hence both,// of them.  The next routine outputs one support for each equivalence// class.  It is not for use in solution routines, but is instead a // prototype of the eventual path enumerator, which will also perform// dominance elimination.void AllInequivalentSubsupportsRECURSIVE(const EFSupport *s,					 EFSupportWithActiveInfo *sact,					 ActionCursorForSupport *c,					 gList<const EFSupport> *list){   if (sact->HasActiveActionsAtActiveInfosetsAndNoOthers())    (*list) += sact->UnderlyingSupport();  ActionCursorForSupport c_copy(*c);  do {    if ( sact->ActionIsActive((Action *)c_copy.GetAction()) ) {      gList<Infoset *> deactivated_infosets;      sact->RemoveActionReturningDeletedInfosets(c_copy.GetAction(),						 &deactivated_infosets);       if (!c_copy.DeletionsViolateActiveCommitments(sact,						    &deactivated_infosets))	AllInequivalentSubsupportsRECURSIVE(s,sact,&c_copy,list);      sact->AddAction(c_copy.GetAction());    }  } while (c_copy.GoToNext()) ;}gList<const EFSupport> AllInequivalentSubsupports(const EFSupport &S){  gList<const EFSupport> answer;  EFSupportWithActiveInfo SAct(S);  ActionCursorForSupport cursor(S);  AllInequivalentSubsupportsRECURSIVE(&S,&SAct,&cursor,&answer);  return answer;}void AllUndominatedSubsupportsRECURSIVE(const EFSupport *s,					 EFSupportWithActiveInfo *sact,					 ActionCursorForSupport *c,					const bool strong,					const bool conditional,					 gList<const EFSupport> *list,					 const gStatus &status){   bool abort = false;  bool no_deletions = true;  bool check_domination = false;  if (sact->HasActiveActionsAtActiveInfosets())     check_domination = true;  gList<Action *> deletion_list;  ActionCursorForSupport scanner(*s);  // First we collect all the actions that can be deleted.  do {    Action *this_action = (Action *)scanner.GetAction();    bool delete_this_action = false;    if ( sact->ActionIsActive(this_action) )       if ( !sact->InfosetIsActive(this_action->BelongsTo()) ) 	delete_this_action = true;        else 	if (check_domination) 	  if (sact->IsDominated(this_action,strong,conditional) ) 	    delete_this_action = true;	    if (delete_this_action) {      no_deletions = false;      if (c->IsSubsequentTo(this_action)) 	abort = true;      else 	deletion_list += this_action;    }  } while (!abort && scanner.GoToNext());  // Now we delete them, recurse, then restore  if (!abort && !no_deletions) {    gList<Action *> actual_deletions;    for (int i = 1; !abort && i <= deletion_list.Length(); i++) {      actual_deletions += deletion_list[i];      gList<Infoset *> deactivated_infosets;            sact->RemoveActionReturningDeletedInfosets(deletion_list[i],						   &deactivated_infosets); 	      if (c->DeletionsViolateActiveCommitments(sact,&deactivated_infosets))	abort = true;    }    if (!abort)      AllUndominatedSubsupportsRECURSIVE(s,					 sact,					 c,					 strong,					 conditional,					 list,					 status);        for (int i = 1; i <= actual_deletions.Length(); i++)      sact->AddAction(actual_deletions[i]);  }  // If there are no deletions, we ask if it is consistent, then recurse.  if (!abort && no_deletions) {    if (sact->HasActiveActionsAtActiveInfosetsAndNoOthers())      (*list) += sact->UnderlyingSupport();        ActionCursorForSupport c_copy(*c);        do {      if ( sact->ActionIsActive((Action *)c_copy.GetAction()) ) {		gList<Infoset *> deactivated_infosets;	sact->RemoveActionReturningDeletedInfosets(c_copy.GetAction(),						   &deactivated_infosets); 		if (!c_copy.DeletionsViolateActiveCommitments(sact,						      &deactivated_infosets))	  AllUndominatedSubsupportsRECURSIVE(s,					     sact,					     &c_copy,					     strong,					     conditional,					     list,					     status);	sact->AddAction(c_copy.GetAction());	      }    } while (c_copy.GoToNext()) ;  }}  gList<const EFSupport> AllUndominatedSubsupports(const EFSupport &S,						 const bool strong,						 const bool conditional,						 const gStatus &status){  gList<const EFSupport> answer;  EFSupportWithActiveInfo sact(S);  ActionCursorForSupport cursor(S);  AllUndominatedSubsupportsRECURSIVE(&S,				     &sact,				     &cursor,				     strong,				     conditional,				     &answer,				     status);  return answer;}void PossibleNashSubsupportsRECURSIVE(const EFSupport *s,					    EFSupportWithActiveInfo *sact,				            ActionCursorForSupport *c,				            gList<const EFSupport> *list,				      const gStatus &status){   status.Get();  bool abort = false;  bool add_support = true;  bool check_domination = false;  if (sact->HasActiveActionsAtActiveInfosets())     check_domination = true;  gList<Action *> deletion_list;  ActionCursorForSupport scanner(*s);  do {    Action *this_action = (Action *)scanner.GetAction();    bool delete_this_action = false;    if ( sact->ActionIsActive(this_action) )       if ( !sact->InfosetIsActive(this_action->BelongsTo()) )	delete_this_action = true;        else	if (check_domination) 	  if ( sact->IsDominated(this_action,true,true) ||	       sact->IsDominated(this_action,true,false) ) {	    add_support = false;	    if ( c->InfosetGuaranteedActiveByPriorCommitments(sact,						   this_action->BelongsTo()) )	      delete_this_action = true;	  }    if (delete_this_action) {      if (c->IsSubsequentTo(this_action)) 	abort = true;      else 	deletion_list += this_action;    }  } while (!abort && scanner.GoToNext());    if (!abort) {    gList<Action *> actual_deletions;    for (int i = 1; !abort && i <= deletion_list.Length(); i++) {      actual_deletions += deletion_list[i];      gList<Infoset *> deactivated_infosets;      sact->RemoveActionReturningDeletedInfosets(deletion_list[i],						   &deactivated_infosets);       if (c->DeletionsViolateActiveCommitments(sact,&deactivated_infosets))	abort = true;    }    if (!abort && deletion_list.Length() > 0)       PossibleNashSubsupportsRECURSIVE(s,sact,c,list,status);            for (int i = 1; i <= actual_deletions.Length(); i++) {      sact->AddAction(actual_deletions[i]);    }  }  if (!abort && deletion_list.Length() == 0) {    if (add_support && sact->HasActiveActionsAtActiveInfosetsAndNoOthers())      (*list) += sact->UnderlyingSupport();        ActionCursorForSupport c_copy(*c);    do {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -