本文整理汇总了Java中burlap.behavior.stochasticgames.solvers.CorrelatedEquilibriumSolver类的典型用法代码示例。如果您正苦于以下问题:Java CorrelatedEquilibriumSolver类的具体用法?Java CorrelatedEquilibriumSolver怎么用?Java CorrelatedEquilibriumSolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CorrelatedEquilibriumSolver类属于burlap.behavior.stochasticgames.solvers包,在下文中一共展示了CorrelatedEquilibriumSolver类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeColStrategy
import burlap.behavior.stochasticgames.solvers.CorrelatedEquilibriumSolver; //导入依赖的package包/类
@Override
public double[] computeColStrategy(double[][] rowPayoff,
double[][] colPayoff) {
double [][] jointStrategy;
if(this.objective != CorrelatedEquilibriumObjective.LIBERTARIAN){
jointStrategy = CorrelatedEquilibriumSolver.getCorrelatedEQJointStrategy(this.objective, rowPayoff, colPayoff);
return GeneralBimatrixSolverTools.marginalizeColPlayerStrategy(jointStrategy);
}
else{
//libertarian assumes row player request, so transpose matrices
jointStrategy = CorrelatedEquilibriumSolver.getCorrelatedEQJointStrategy(this.objective,
GeneralBimatrixSolverTools.transposeMatrix(rowPayoff), GeneralBimatrixSolverTools.transposeMatrix(colPayoff));
//return row since we transposed players
return GeneralBimatrixSolverTools.marginalizeRowPlayerStrategy(jointStrategy);
}
}
示例2: computeRowStrategy
import burlap.behavior.stochasticgames.solvers.CorrelatedEquilibriumSolver; //导入依赖的package包/类
@Override
public double[] computeRowStrategy(double[][] rowPayoff,
double[][] colPayoff) {
double [][] jointStrategy = CorrelatedEquilibriumSolver.getCorrelatedEQJointStrategy(this.objective, rowPayoff, colPayoff);
return GeneralBimatrixSolverTools.marginalizeRowPlayerStrategy(jointStrategy);
}
示例3: performBackup
import burlap.behavior.stochasticgames.solvers.CorrelatedEquilibriumSolver; //导入依赖的package包/类
@Override
public double performBackup(State s, String forAgent,
Map<String, SGAgentType> agentDefinitions, AgentQSourceMap qSourceMap) {
if(agentDefinitions.size() != 2){
throw new RuntimeException("Correlated Q only defined for two agents.");
}
String otherAgentName = null;
for(String aname : agentDefinitions.keySet()){
if(!aname.equals(forAgent)){
otherAgentName = aname;
break;
}
}
QSourceForSingleAgent forAgentQSource = qSourceMap.agentQSource(forAgent);
QSourceForSingleAgent otherAgentQSource = qSourceMap.agentQSource(otherAgentName);
List<GroundedSGAgentAction> forAgentGSAs = SGAgentAction.getAllApplicableGroundedActionsFromActionList(s, forAgent, agentDefinitions.get(forAgent).actions);
List<GroundedSGAgentAction> otherAgentGSAs = SGAgentAction.getAllApplicableGroundedActionsFromActionList(s, otherAgentName, agentDefinitions.get(otherAgentName).actions);
double [][] forPlayerPaoyff = new double[forAgentGSAs.size()][otherAgentGSAs.size()];
double [][] otherPlayerPaoyff = new double[forAgentGSAs.size()][otherAgentGSAs.size()];
for(int i = 0; i < forAgentGSAs.size(); i++){
for(int j = 0; j < otherAgentGSAs.size(); j++){
JointAction ja = new JointAction();
ja.addAction(forAgentGSAs.get(i));
ja.addAction(otherAgentGSAs.get(j));
double q1 = forAgentQSource.getQValueFor(s, ja).q;
double q2 = otherAgentQSource.getQValueFor(s, ja).q;
forPlayerPaoyff[i][j] = q1;
otherPlayerPaoyff[i][j] = q2;
}
}
double [][] jointActionProbs = CorrelatedEquilibriumSolver.getCorrelatedEQJointStrategy(this.objectiveType, forPlayerPaoyff, otherPlayerPaoyff);
double [] expectedValue = GeneralBimatrixSolverTools.expectedPayoffs(forPlayerPaoyff, otherPlayerPaoyff, jointActionProbs);
return expectedValue[0];
}
示例4: VICorrelatedTest
import burlap.behavior.stochasticgames.solvers.CorrelatedEquilibriumSolver; //导入依赖的package包/类
public static void VICorrelatedTest(){
GridGame gridGame = new GridGame();
final OOSGDomain domain = gridGame.generateDomain();
final HashableStateFactory hashingFactory = new SimpleHashableStateFactory();
final State s = GridGame.getPrisonersDilemmaInitialState();
JointRewardFunction rf = new GridGame.GGJointRewardFunction(domain, -1, 100, false);
TerminalFunction tf = new GridGame.GGTerminalFunction(domain);
SGAgentType at = GridGame.getStandardGridGameAgentType(domain);
MAValueIteration vi = new MAValueIteration(domain, rf, tf, 0.99, hashingFactory, 0., new CorrelatedQ(CorrelatedEquilibriumSolver.CorrelatedEquilibriumObjective.UTILITARIAN), 0.00015, 50);
World w = new World(domain, rf, tf, s);
//for correlated Q, use a correlated equilibrium policy joint policy
ECorrelatedQJointPolicy jp0 = new ECorrelatedQJointPolicy(CorrelatedEquilibriumSolver.CorrelatedEquilibriumObjective.UTILITARIAN, 0.);
MultiAgentDPPlanningAgent a0 = new MultiAgentDPPlanningAgent(domain, vi, new PolicyFromJointPolicy(0, jp0, true), "agent0", at);
MultiAgentDPPlanningAgent a1 = new MultiAgentDPPlanningAgent(domain, vi, new PolicyFromJointPolicy(1, jp0, true), "agent1", at);
w.join(a0);
w.join(a1);
GameEpisode ga = null;
List<GameEpisode> games = new ArrayList<GameEpisode>();
for(int i = 0; i < 10; i++){
ga = w.runGame();
games.add(ga);
}
Visualizer v = GGVisualizer.getVisualizer(9, 9);
new GameSequenceVisualizer(v, domain, games);
}
示例5: performBackup
import burlap.behavior.stochasticgames.solvers.CorrelatedEquilibriumSolver; //导入依赖的package包/类
@Override
public double performBackup(State s, int forAgent, List<SGAgentType> agentDefinitions, AgentQSourceMap qSourceMap) {
if(agentDefinitions.size() != 2){
throw new RuntimeException("CoCoQ only defined for two agents.");
}
int otherAgent = forAgent == 0 ? 1 : 0;
QSourceForSingleAgent forAgentQSource = qSourceMap.agentQSource(forAgent);
QSourceForSingleAgent otherAgentQSource = qSourceMap.agentQSource(otherAgent);
List<Action> forAgentGSAs = ActionUtils.allApplicableActionsForTypes(agentDefinitions.get(forAgent).actions, s);
List<Action> otherAgentGSAs = ActionUtils.allApplicableActionsForTypes(agentDefinitions.get(otherAgent).actions, s);
double [][] forPlayerPaoyff = new double[forAgentGSAs.size()][otherAgentGSAs.size()];
double [][] otherPlayerPaoyff = new double[forAgentGSAs.size()][otherAgentGSAs.size()];
for(int i = 0; i < forAgentGSAs.size(); i++){
for(int j = 0; j < otherAgentGSAs.size(); j++){
JointAction ja = new JointAction();
ja.setAction(forAgent, forAgentGSAs.get(i));
ja.setAction(otherAgent, otherAgentGSAs.get(j));
double q1 = forAgentQSource.getQValueFor(s, ja).q;
double q2 = otherAgentQSource.getQValueFor(s, ja).q;
forPlayerPaoyff[i][j] = q1;
otherPlayerPaoyff[i][j] = q2;
}
}
double [][] jointActionProbs = CorrelatedEquilibriumSolver.getCorrelatedEQJointStrategy(this.objectiveType, forPlayerPaoyff, otherPlayerPaoyff);
double [] expectedValue = GeneralBimatrixSolverTools.expectedPayoffs(forPlayerPaoyff, otherPlayerPaoyff, jointActionProbs);
return expectedValue[0];
}