diff --git a/prism-tests/functionality/verify/csgs/nash/test_diff_sw_fr.prism b/prism-tests/functionality/verify/csgs/nash/test_diff_sw_fr.prism new file mode 100644 index 000000000..518ad992f --- /dev/null +++ b/prism-tests/functionality/verify/csgs/nash/test_diff_sw_fr.prism @@ -0,0 +1,30 @@ +csg + +player p1 m1 endplayer +player p2 m2 endplayer + +module m1 + s : bool init false; + [a1] !s -> (s'=!s); + [b1] !s -> (s'=!s); +endmodule + +module m2 + [a2] !s -> true; + [b2] !s -> true; +endmodule + +rewards "r1" + [a1,a2] !s : 5.0; + [a1,b2] !s : 2.0; + [b1,a2] !s : 6.0; + [b1,b2] !s : 0.0; +endrewards + +rewards "r2" + [a1,a2] !s : 5.0; + [a1,b2] !s : 6.0; + [b1,a2] !s : 2.0; + [b1,b2] !s : 1.0; +endrewards + diff --git a/prism-tests/functionality/verify/csgs/nash/test_diff_sw_fr.prism.props b/prism-tests/functionality/verify/csgs/nash/test_diff_sw_fr.prism.props new file mode 100644 index 000000000..1eb2cef01 --- /dev/null +++ b/prism-tests/functionality/verify/csgs/nash/test_diff_sw_fr.prism.props @@ -0,0 +1,8 @@ +// RESULT: 16/2 +<>{NE,SW}max=?(R{"r1"}[C<=1] + R{"r2"}[C<=1]) +// RESULT: 15/2 +<>{NE,FR}max=?(R{"r1"}[C<=1] + R{"r2"}[C<=1]) +// RESULT: 44/5 +<>{CE,SW}max=?(R{"r1"}[C<=1] + R{"r2"}[C<=1]) +// RESULT: 26/3 +<>{CE,FR}max=?(R{"r1"}[C<=1] + R{"r2"}[C<=1]) diff --git a/prism/lib/libyices.2.dylib b/prism/lib/libyices.2.dylib new file mode 100755 index 000000000..532872836 Binary files /dev/null and b/prism/lib/libyices.2.dylib differ diff --git a/prism/lib/libyices.so.2.6 b/prism/lib/libyices.so.2.6 new file mode 100755 index 000000000..e5c1c10fb Binary files /dev/null and b/prism/lib/libyices.so.2.6 differ diff --git a/prism/lib/libyices.so.2.6.1 b/prism/lib/libyices.so.2.6.1 new file mode 100755 index 000000000..f8363634a Binary files /dev/null and b/prism/lib/libyices.so.2.6.1 differ diff --git a/prism/lib/libyices2java.dylib b/prism/lib/libyices2java.dylib new file mode 100755 index 000000000..f657be31c Binary files /dev/null and b/prism/lib/libyices2java.dylib differ diff --git a/prism/lib/libyices2java.jnilib b/prism/lib/libyices2java.jnilib new file mode 120000 index 000000000..46f9c690d --- /dev/null +++ b/prism/lib/libyices2java.jnilib @@ -0,0 +1 @@ +libyices2java.dylib \ No newline at end of file diff --git a/prism/lib/libyices2java.so b/prism/lib/libyices2java.so new file mode 100755 index 000000000..0d9faf7c2 Binary files /dev/null and b/prism/lib/libyices2java.so differ diff --git a/prism/lib/yices.jar b/prism/lib/yices.jar new file mode 100644 index 000000000..7212c8803 Binary files /dev/null and b/prism/lib/yices.jar differ diff --git a/prism/src/explicit/CSGCorrelated.java b/prism/src/explicit/CSGCorrelated.java new file mode 100644 index 000000000..efa8554a7 --- /dev/null +++ b/prism/src/explicit/CSGCorrelated.java @@ -0,0 +1,59 @@ +//============================================================================== +// +// Copyright (c) 2002- +// Authors: +// * Dave Parker (University of Oxford) +// * Gabriel Santos (University of Oxford) +// +//------------------------------------------------------------------------------ +// +// This file is part of PRISM. +// +// PRISM 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. +// +// PRISM 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 PRISM; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +//============================================================================== + +package explicit; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.HashMap; + +public interface CSGCorrelated { + + /** + * Computes correlated equilibria for a normal form game + * + * @param utilities Utility table as a map from action indexes to utility arrays + * @param ce_constraints An auxiliary mapping of actions to utilities (player i -> action a -> actions of -i -> utility) used to set the constraints for correlated equilibria + * @param strategies Array with individual actions for each player + * @param ce_var_map Map for joint actions + * @param crit Criterion (social-welfare = 3, fair = 4) + */ + public EquilibriumResult computeEquilibrium(HashMap> utilities, + ArrayList>> ce_constraints, + ArrayList> strategies, + HashMap ce_var_map, int crit); + + /** + * Gets the solver's name + */ + public String getSolverName(); + + public void clear(); + + public void printModel(); + +} diff --git a/prism/src/explicit/CSGCorrelatedZ3.java b/prism/src/explicit/CSGCorrelatedZ3.java new file mode 100644 index 000000000..5d59e2e29 --- /dev/null +++ b/prism/src/explicit/CSGCorrelatedZ3.java @@ -0,0 +1,284 @@ +//============================================================================== +// +// Copyright (c) 2002- +// Authors: +// * Dave Parker (University of Oxford) +// * Gabriel Santos (University of Oxford) +// +//------------------------------------------------------------------------------ +// +// This file is part of PRISM. +// +// PRISM 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. +// +// PRISM 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 PRISM; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +//============================================================================== + +package explicit; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.HashMap; + +import com.microsoft.z3.AlgebraicNum; +import com.microsoft.z3.ArithExpr; +import com.microsoft.z3.BoolExpr; +import com.microsoft.z3.Context; +import com.microsoft.z3.Expr; +import com.microsoft.z3.IntExpr; +import com.microsoft.z3.Model; +import com.microsoft.z3.Optimize; +import com.microsoft.z3.RatNum; +import com.microsoft.z3.RealExpr; +import com.microsoft.z3.Status; +import com.microsoft.z3.Version; + +import prism.PrismException; + +/** + * Z3-based implementation for correlated equilibria computation + * @author Gabriel Santos + * + */ +public class CSGCorrelatedZ3 implements CSGCorrelated { + + private RealExpr[] vars; + private RealExpr[] payoff_vars; + private RealExpr obj_var; + private ArithExpr[] payoffs; + + private HashMap cfg; + private Context ctx; + private Optimize s; + + private IntExpr zero; + private IntExpr one; + + private String name; + private int n_coalitions; + + /** + * Creates a new CSGCorrelatedZ3 (without initialisation) + */ + public CSGCorrelatedZ3() { + cfg = new HashMap(); + cfg.put("model", "true"); + ctx = new Context(cfg); + s = ctx.mkOptimize(); + name = Version.getFullVersion(); + } + + /** + * Creates a new CSGCorrelatedZ3 + * @param n_entries Number of entries in the utility table + * @param n_coalitions Number of coalitions + */ + public CSGCorrelatedZ3(int n_entries, int n_coalitions) { + cfg = new HashMap(); + cfg.put("model", "true"); + cfg.put("auto_config", "true"); + ctx = new Context(cfg); + s = ctx.mkOptimize(); + name = Version.getFullVersion(); + zero = ctx.mkInt(0); + one = ctx.mkInt(1); + vars = new RealExpr[n_entries]; + payoffs = new ArithExpr[n_coalitions]; + this.n_coalitions = n_coalitions; + for (int i = 0; i < n_entries; i++) { + vars[i] = ctx.mkRealConst("v" + i); + s.Add(ctx.mkLe(vars[i], one)); + s.Add(ctx.mkGe(vars[i], zero)); + } + payoff_vars = new RealExpr[n_coalitions]; + obj_var = ctx.mkRealConst("ob"); + } + + public EquilibriumResult computeEquilibrium(HashMap> utilities, + ArrayList>> ce_constraints, + ArrayList> strategies, + HashMap ce_var_map, int type) { + EquilibriumResult result = new EquilibriumResult(); + ArrayList payoffs_result = new ArrayList(); + ArrayList strategy_result = new ArrayList(); + Distribution d = new Distribution(); + ArithExpr expr; + BitSet is, js; + double u; + int c, q, r; + is = new BitSet(); + js = new BitSet(); + + s.Push(); + expr = ctx.mkInt(0); + + // Builds a payoff expression for each player, and one for the sum of all payoffs + for (int i = 0; i < n_coalitions; i++) { + payoffs[i] = zero; + } + for (BitSet e : utilities.keySet()) { + u = 0.0; + for (c = 0; c < n_coalitions; c++) { + u += utilities.get(e).get(c); + payoffs[c] = ctx.mkAdd(payoffs[c], ctx.mkMul(vars[ce_var_map.get(e)], ctx.mkReal(String.valueOf(utilities.get(e).get(c))))); + } + expr = ctx.mkAdd(expr, ctx.mkMul(vars[ce_var_map.get(e)], ctx.mkReal(String.valueOf(u)))); + } + for (c = 0; c < n_coalitions; c++) { + payoff_vars[c] = ctx.mkRealConst("p " + c); + s.Add(ctx.mkEq(payoff_vars[c], payoffs[c])); + } + + // In case of the fair variant (minimise the difference between the largest and smallest payoffs) + // we first need to add auxiliary constraints + // The default case is social-welfare, in which we just maximise the sum + switch (type) { + case CSGModelCheckerEquilibria.FAIR : { + RealExpr ph; + RealExpr pl; + ph = ctx.mkRealConst("ph"); // Highest payoff + pl = ctx.mkRealConst("pl"); // Lowest payoff + BoolExpr bh; + BoolExpr bl; + // Additional constraints for fair + for (int i = 0; i < n_coalitions; i++) { + bh = ctx.mkTrue(); + bl = ctx.mkTrue(); + for (int j = 0; j < n_coalitions; j++) { + if (i != j) { + bh = ctx.mkAnd(bh, ctx.mkGe(payoffs[i], payoffs[j])); + bl = ctx.mkAnd(bl, ctx.mkLe(payoffs[i], payoffs[j])); + } + } + s.Add(ctx.mkImplies(bh, ctx.mkEq(ph, payoffs[i]))); + s.Add(ctx.mkImplies(bl, ctx.mkEq(pl, payoffs[i]))); + } + s.MkMinimize(ctx.mkSub(ph, pl)); + break; + } + default : { + // Primary objective is maximising the sum + s.Add(ctx.mkEq(obj_var, expr)); + s.MkMaximize(expr); + } + } + + // Lower priority objectives of maximising the payoff of each player in decreasing order + for (c = 0; c < n_coalitions; c++) { + s.MkMaximize(payoffs[(c)]); + } + + // Constraints for correlated equilibria + for (c = 0; c < n_coalitions; c++) { + for (q = 0; q < strategies.get(c).size(); q++) { + expr = zero; + is.clear(); + is.set(strategies.get(c).get(q)); + for (r = 0; r < strategies.get(c).size(); r++) { + js.clear(); + for (BitSet e : ce_constraints.get(c).get(q).keySet()) { + is.or(e); + js.or(e); + if (q != r) { + js.set(strategies.get(c).get(r)); + expr = ctx.mkAdd(expr, ctx.mkMul(vars[ce_var_map.get(is)], + ctx.mkSub(ctx.mkReal(String.valueOf(utilities.get(is).get(c))), + ctx.mkReal(String.valueOf(utilities.get(js).get(c)))))); + } + is.andNot(e); + js.andNot(e); + } + if (q != r) { + s.Add(ctx.mkGe(expr, zero)); + } + } + } + } + + // Sets unused variables to zero + for (c = utilities.size(); c < vars.length; c++) { + s.Add(ctx.mkEq(vars[c], zero)); + } + + expr = ctx.mkInt(0); + for (c = 0; c < vars.length; c++) { + expr = ctx.mkAdd(expr, vars[c]); + } + s.Add(ctx.mkEq(expr, one)); + + /* + for (BoolExpr e : s.getAssertions()) { + System.out.println(e); + } + */ + + // If and optimal solution is found, set the values and strategies + if (s.Check() == Status.SATISFIABLE) { + for (c = 0; c < vars.length; c++) { + d.add(c, getDoubleValue(s.getModel(), vars[c])); + } + for (c = 0; c < payoff_vars.length; c++) { + payoffs_result.add(getDoubleValue(s.getModel(), payoff_vars[c])); + } + result.setStatus(CSGModelCheckerEquilibria.CSGResultStatus.SAT); + result.setPayoffVector(payoffs_result); + strategy_result.add(d); + result.setStrategy(strategy_result); + } + else { + result.setStatus(CSGModelCheckerEquilibria.CSGResultStatus.UNSAT); + } + + s.Pop(); + return result; + } + + /** + * Return a double value for a given expression (usually variable), converting from BigInt fractions + * @param model The SMT model + * @param expr The SMT expression + * @return + */ + public double getDoubleValue(Model model, Expr expr) { + RatNum v1; + AlgebraicNum v2; + if(model.getConstInterp(expr) instanceof RatNum) { + v1 = (RatNum) model.getConstInterp(expr); + return (Double) (v1.getBigIntNumerator().doubleValue() / v1.getBigIntDenominator().doubleValue()); + } + else if (model.getConstInterp(expr) instanceof AlgebraicNum) { + v2 = (AlgebraicNum) model.getConstInterp(expr); + v1 = v2.toUpper(12); + return (Double) (v1.getBigIntNumerator().doubleValue() / v1.getBigIntDenominator().doubleValue()); + } + else + return Double.NaN; + } + + public String getSolverName() { + return name; + } + + @Override + public void clear() { + + } + + @Override + public void printModel() { + // TODO Auto-generated method stub + + } + +} diff --git a/prism/src/explicit/CSGLabeledPolytopes.java b/prism/src/explicit/CSGLabeledPolytopes.java index a94aa6aaf..2ed88e4e2 100644 --- a/prism/src/explicit/CSGLabeledPolytopes.java +++ b/prism/src/explicit/CSGLabeledPolytopes.java @@ -1,3 +1,30 @@ +//============================================================================== +// +// Copyright (c) 2002- +// Authors: +// * Dave Parker (University of Oxford) +// * Gabriel Santos (University of Oxford) +// +//------------------------------------------------------------------------------ +// +// This file is part of PRISM. +// +// PRISM 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. +// +// PRISM 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 PRISM; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +//============================================================================== + package explicit; import java.util.ArrayList; @@ -10,7 +37,7 @@ public interface CSGLabeledPolytopes { public void update(int nrows, int ncols, double[][] a, double[][] b); - public void compEq() throws PrismException; + public void computeEquilibria() throws PrismException; public void compPayoffs(); diff --git a/prism/src/explicit/CSGLabeledPolytopesYicesStack.java b/prism/src/explicit/CSGLabeledPolytopesYicesStack.java index 1dca46f4c..f3f010014 100644 --- a/prism/src/explicit/CSGLabeledPolytopesYicesStack.java +++ b/prism/src/explicit/CSGLabeledPolytopesYicesStack.java @@ -11,71 +11,74 @@ import com.sri.yices.Version; import com.sri.yices.Yices; +import prism.PrismSettings; import prism.PrismException; + public class CSGLabeledPolytopesYicesStack implements CSGLabeledPolytopes { - private String solverName = "Yices"; + private String solverName; + private Config cfg; private Context ctx; - + private int realType; private int boolType; - + private int zero; private int one; private int ytrue; private int yfalse; - + private int eq; - + private int curr; - + private int[] xlabels; private int[] ylabels; - + private int[] vars; private int[] xexps; private int[] yexps; - + private int[] tmpc; private int[] tmpr; - + private com.sri.yices.Model model; - + private int xctr; private int yctr; private int c1; private int c2; - + private String[] lvp1; private String[] lvp2; - + private double[][] a; private double[][] b; private double[] p1p; private double[] p2p; - + private int neq; private int nrows; private int ncols; - + private HashMap> eqs; - private ArrayList> strat; - + private ArrayList> strat; + protected String eqPolicy; - - public CSGLabeledPolytopesYicesStack() { - - } - - public CSGLabeledPolytopesYicesStack(int nrows, int ncols) throws PrismException - { - initSolver(); - eqs = new HashMap>(); - realType = Yices.realType(); - boolType = Yices.boolType(); + + public CSGLabeledPolytopesYicesStack() { + + } + + public CSGLabeledPolytopesYicesStack(int nrows, int ncols) throws PrismException + { + initSolver(); + eqs = new HashMap>(); + realType = Yices.realType(); + boolType = Yices.boolType(); zero = Terms.intConst(0); one = Terms.intConst(1); vars = new int[nrows+ncols]; @@ -105,14 +108,14 @@ public CSGLabeledPolytopesYicesStack(int nrows, int ncols) throws PrismException ctx.assertFormula(Terms.arithLeq(v, one)); ctx.assertFormula(Terms.arithGeq(v, zero)); } - } - - public void clear() throws PrismException - { - initSolver(); - eqs = new HashMap>(); - realType = Yices.realType(); - boolType = Yices.boolType(); + } + + public void clear() throws PrismException + { + initSolver(); + eqs = new HashMap>(); + realType = Yices.realType(); + boolType = Yices.boolType(); zero = Terms.intConst(0); one = Terms.intConst(1); vars = new int[nrows+ncols]; @@ -142,37 +145,37 @@ public void clear() throws PrismException ctx.assertFormula(Terms.arithLeq(v, one)); ctx.assertFormula(Terms.arithGeq(v, zero)); } - } - - /** - * Initialise the solver - */ - private void initSolver() throws PrismException - { - try { - Config cfg = new Config("QF_LRA"); - cfg.set("mode", "push-pop"); - ctx = new Context(cfg); - cfg.close(); - solverName = "Yices " + Version.versionString; - } catch (UnsatisfiedLinkError e) { - throw new PrismException("Could not initialise Yices: " + e.getMessage()); - } - } - - @Override - public String getSolverName() - { - return solverName; - } - + } + + /** + * Initialise the solver + */ + private void initSolver() throws PrismException + { + try { + Config cfg = new Config("QF_LRA"); + cfg.set("mode", "push-pop"); + ctx = new Context(cfg); + cfg.close(); + solverName = "Yices " + Version.versionString; + } catch (UnsatisfiedLinkError e) { + throw new PrismException("Could not initialise Yices: " + e.getMessage()); + } + } + + @Override + public String getSolverName() + { + return solverName; + } + public void update(int nrows, int ncols, double[][] a, double[][] b) { this.nrows = nrows; this.ncols = ncols; this.a = a; this.b = b; } - + private void xLabels() { int l = 0; int j = 0; @@ -198,7 +201,7 @@ private void xLabels() { } } } - + private void yLabels() { int l = 0; int j = 0; @@ -224,14 +227,14 @@ private void yLabels() { } } } - + private void vMult() { for(int i = 0; i < nrows; i++) { curr = zero; for(int j = 0; j < ncols; j++) { try { curr = Terms.add(curr, Terms.mul(vars[nrows+j], - Terms.parseFloat(String.valueOf(a[i][j])))); + Terms.parseFloat(String.valueOf(a[i][j])))); } catch(Exception e) { e.printStackTrace(); @@ -244,7 +247,7 @@ private void vMult() { for(int i = 0; i < nrows; i++) { try { curr = Terms.add(curr, Terms.mul(vars[i], - Terms.parseFloat(String.valueOf(b[i][j])))); + Terms.parseFloat(String.valueOf(b[i][j])))); } catch(Exception e) { e.printStackTrace(); @@ -254,7 +257,7 @@ private void vMult() { } } - public void compEq() throws PrismException + public void computeEquilibria() throws PrismException { ArrayList dists; Distribution dist1; @@ -282,87 +285,88 @@ public void compEq() throws PrismException ctx.assertFormula(xctr); ctx.assertFormula(yctr); ctx.assertFormula(eq); - strat = new ArrayList>(); + strat = new ArrayList>(); eqs.clear(); - j = 0; - while (ctx.check() == Status.SAT) { - model = ctx.getModel(); - c1 = ytrue; - c2 = ytrue; - dists = new ArrayList(); - dist1 = new Distribution(); - dist2 = new Distribution(); - //System.out.println("---"); - //String prt = "("; - for (i = 0; i < nrows+ncols; i++) { - //p = model.bigRationalValue(vars[i]).doubleValue(); - p = model.doubleValue(vars[i]); - //prt += p; - //if (i < vars.length - 1) - //prt += ","; - //System.out.println(p); - if(p > 0) { - if(i < nrows) - dist1.add(i, p); - else - dist2.add(i - nrows, p); - } - if (j == 0) { - if (i < nrows) { - eqs.put(lvp1[i], new ArrayList()); - eqs.get(lvp1[i]).add(p); - } - else { - eqs.put(lvp2[i-nrows], new ArrayList()); - eqs.get(lvp2[i-nrows]).add(p); - } - } - else { - if (i < nrows) { - eqs.get(lvp1[i]).add(p); - } - else { - eqs.get(lvp2[i-nrows]).add(p); - } - } - } - //prt += ")"; - //System.out.println(prt); - if (eqPolicy == "first_found") { - dists.add(0, dist1); - dists.add(1, dist2); - strat.add(j, dists); - j++; - break; - } - for(i = 0; i < nrows+ncols; i++) { + + j = 0; + while (ctx.check() == Status.SAT) { + model = ctx.getModel(); + c1 = ytrue; + c2 = ytrue; + dists = new ArrayList(); + dist1 = new Distribution(); + dist2 = new Distribution(); + //System.out.println("---"); + //String prt = "("; + for (i = 0; i < nrows+ncols; i++) { + //p = model.bigRationalValue(vars[i]).doubleValue(); + p = model.doubleValue(vars[i]); + //prt += p; + //if (i < vars.length - 1) + //prt += ","; + //System.out.println(p); + if(p > 0) { + if(i < nrows) + dist1.add(i, p); + else + dist2.add(i - nrows, p); + } + if (j == 0) { + if (i < nrows) { + eqs.put(lvp1[i], new ArrayList()); + eqs.get(lvp1[i]).add(p); + } + else { + eqs.put(lvp2[i-nrows], new ArrayList()); + eqs.get(lvp2[i-nrows]).add(p); + } + } + else { + if (i < nrows) { + eqs.get(lvp1[i]).add(p); + } + else { + eqs.get(lvp2[i-nrows]).add(p); + } + } + } + //prt += ")"; + //System.out.println(prt); + if (eqPolicy == "first_found") { + dists.add(0, dist1); + dists.add(1, dist2); + strat.add(j, dists); + j++; + break; + } + for(i = 0; i < nrows+ncols; i++) { if (i < nrows) { - if (Double.compare(eqs.get(lvp1[i]).get(j), 0.0) != 0) { - c1 = Terms.and(c1, Terms.not(Terms.arithEq(vars[i], zero))); - } - else { - c1 = Terms.and(c1, Terms.arithEq(vars[i], zero)); - } + if (Double.compare(eqs.get(lvp1[i]).get(j), 0.0) != 0) { + c1 = Terms.and(c1, Terms.not(Terms.arithEq(vars[i], zero))); + } + else { + c1 = Terms.and(c1, Terms.arithEq(vars[i], zero)); + } } else { - if (Double.compare(eqs.get(lvp2[i-nrows]).get(j), 0.0) != 0) { - c2 = Terms.and(c2, Terms.not(Terms.arithEq(vars[i], zero))); - } - else { - c2 = Terms.and(c2, Terms.arithEq(vars[i], zero)); - } + if (Double.compare(eqs.get(lvp2[i-nrows]).get(j), 0.0) != 0) { + c2 = Terms.and(c2, Terms.not(Terms.arithEq(vars[i], zero))); + } + else { + c2 = Terms.and(c2, Terms.arithEq(vars[i], zero)); + } } - } - dists.add(0, dist1); - dists.add(1, dist2); - strat.add(j, dists); - j++; - ctx.assertFormula(Terms.or(Terms.not(c1), Terms.not(c2))); - } - model.close(); - neq = j; - Yices.reset(); - compPayoffs(); + } + dists.add(0, dist1); + dists.add(1, dist2); + strat.add(j, dists); + j++; + ctx.assertFormula(Terms.or(Terms.not(c1), Terms.not(c2))); + } + model.close(); + neq = j; + Yices.reset(); + compPayoffs(); } public void compPayoffs() { @@ -371,13 +375,13 @@ public void compPayoffs() { Arrays.fill(p1p, 0.0); Arrays.fill(p2p, 0.0); for(int e = 0; e < neq; e++) { - for(int i = 0; i < nrows; i++) { - for(int j = 0; j < ncols; j++) { - p1p[e] += eqs.get(lvp1[i]).get(e) * eqs.get(lvp2[j]).get(e) * a[i][j]; - p2p[e] += eqs.get(lvp1[i]).get(e) * eqs.get(lvp2[j]).get(e) * b[i][j]; - } - } - } + for(int i = 0; i < nrows; i++) { + for(int j = 0; j < ncols; j++) { + p1p[e] += eqs.get(lvp1[i]).get(e) * eqs.get(lvp2[j]).get(e) * a[i][j]; + p2p[e] += eqs.get(lvp1[i]).get(e) * eqs.get(lvp2[j]).get(e) * b[i][j]; + } + } + } } public ArrayList> getStrat() { @@ -391,7 +395,7 @@ public double[] getP1p() { public double[] getP2p() { return p2p; } - + public int getNeq() { return neq; } diff --git a/prism/src/explicit/CSGLabeledPolytopesZ3.java b/prism/src/explicit/CSGLabeledPolytopesZ3.java new file mode 100644 index 000000000..e2baaa973 --- /dev/null +++ b/prism/src/explicit/CSGLabeledPolytopesZ3.java @@ -0,0 +1,626 @@ +//============================================================================== +// +// Copyright (c) 2002- +// Authors: +// * Dave Parker (University of Oxford) +// * Gabriel Santos (University of Oxford) +// +//------------------------------------------------------------------------------ +// +// This file is part of PRISM. +// +// PRISM 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. +// +// PRISM 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 PRISM; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +//============================================================================== + +package explicit; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import org.apache.commons.math3.fraction.BigFraction; + +import com.microsoft.z3.*; +import com.microsoft.z3.Model; + +import explicit.Distribution; +import org.apache.commons.math3.util.Precision; +import java.math.BigDecimal; + +public class CSGLabeledPolytopesZ3 implements CSGLabeledPolytopes { + + private final String solverName = "Z3"; + + private RealExpr[] payvars; + private ArithExpr[] payoffs; + + private RealExpr[] vars; + private RealExpr[] p1vars; + private RealExpr[] p2vars; + private IntExpr zero; + private IntExpr one; + private BoolExpr[] xlabels; + private BoolExpr[] ylabels; + private ArithExpr[] xexps; + private ArithExpr[] yexps; + private BoolExpr eq; + private int nrows = 0; + private int ncols = 0; + private HashMap> eqs; + private int neq = 0; + private double[] p1p; + private double[] p2p; + private double[][] a; + private double[][] b; + + private String[] lvp1; + private String[] lvp2; + + private HashMap cfg; + private Context ctx; + private Solver s; + + private ArithExpr cp1; + private ArithExpr cp2; + private double time; + + private int ndigits = 9; + + private ArrayList> strat; + + public CSGLabeledPolytopesZ3() { + cfg = new HashMap(); + cfg.put("model", "true"); + ctx = new Context(cfg); + s = ctx.mkSolver(); + } + + public CSGLabeledPolytopesZ3(int nrows, int ncols, double[][] a, double[][] b) { + cfg = new HashMap(); + cfg.put("model", "true"); + ctx = new Context(cfg); + s = ctx.mkSolver(); + this.nrows = nrows; + this.ncols = ncols; + this.a = a; + this.b = b; + initialize(); + } + + public void update(int nrows, int ncols, double[][] a, double[][] b) { + s.reset(); + this.nrows = nrows; + this.ncols = ncols; + this.a = a; + this.b = b; + /* + System.out.println("-- matrix a"); + for (int row = 0; row < nrows; row++) { + System.out.println("-- row " + row + " " + Arrays.toString(a[row])); + } + System.out.println("-- matrix b"); + for (int row = 0; row < nrows; row++) { + System.out.println("-- row " + row + " " + Arrays.toString(b[row])); + } + */ + initialize(); + } + + private void initialize() { + zero = ctx.mkInt(0); + one = ctx.mkInt(1); + vars = new RealExpr[nrows+ncols]; + p1vars = new RealExpr[nrows]; + p2vars = new RealExpr[ncols]; + lvp1 = new String[nrows]; + lvp2 = new String[ncols]; + strat = new ArrayList>(); + int i = 0, j = 0; + for(; i < nrows; i++) { + vars[i] = ctx.mkRealConst("x" + i); + p1vars[i] = vars[i]; + lvp1[i] = "x" + i; + } + for(; j < ncols; j++) { + vars[i] = ctx.mkRealConst("y" + j); + p2vars[j] = vars[i]; + lvp2[j] = "y" + j; + i++; + } + for(RealExpr v : vars) { + s.add(ctx.mkLe(v, one)); + s.add(ctx.mkGe(v, zero)); + } + } + + private void xLabels() { + /* + System.out.println("-- xexps"); + for (int l = 0; l < xexps.length; l++) { + System.out.println(l + ": " + xexps[l]); + } + */ + BoolExpr[] tmp = new BoolExpr[ncols-1]; + int l = 0; + int j = 0; + xlabels = new BoolExpr[nrows+ncols]; + for(int i = 0; i < nrows+ncols; i++) { + if(i < nrows) { + xlabels[i] = ctx.mkEq(vars[i], zero); + } + else { + for(int k = 0; k < ncols; k++) { + if(j != k) { + tmp[l] = ctx.mkGe(xexps[j], xexps[k]); + l++; + } + } + xlabels[i] = tmp[0]; + if(tmp.length > 1) { + for(int m = 1; m < tmp.length; m++) { + xlabels[i] = ctx.mkAnd(xlabels[i], tmp[m]); + } + } + j++; + l = 0; + } + } + } + + private void yLabels() { + /* + System.out.println("-- yexps"); + for (int l = 0; l < yexps.length; l++) { + System.out.println(l + ": " + yexps[l]); + } + */ + BoolExpr[] tmp = new BoolExpr[nrows-1]; + int l = 0; + int j = 0; + ylabels = new BoolExpr[nrows+ncols]; + for(int i = 0; i < nrows+ncols; i++) { + if(i < nrows) { + for(int k = 0; k < nrows; k++) { + if(j != k) { + tmp[l] = ctx.mkGe(yexps[j], yexps[k]); + l++; + } + } + ylabels[i] = tmp[0]; + if(tmp.length > 1) { + for(int m = 1; m < tmp.length; m++) { + ylabels[i] = ctx.mkAnd(ylabels[i], tmp[m]); + } + } + j++; + l = 0; + } + else { + ylabels[i] = ctx.mkEq(vars[i], zero); + } + } + } + + private void vMult() { + yexps = new ArithExpr[nrows]; + xexps = new ArithExpr[ncols]; + ArithExpr curr; + ArithExpr prod; + for(int i = 0; i < nrows; i++) { + curr = zero; + for(int j = 0; j < ncols; j++) { + try { + curr = ctx.mkAdd(curr, ctx.mkMul(vars[nrows+j], getRealValue(a[i][j]))); + } + catch(Exception e) { + System.out.println(a[i][j]); + System.out.println(String.valueOf(a[i][j])); + e.printStackTrace(); + } + } + yexps[i] = curr; + } + for(int j = 0; j < ncols; j++) { + curr = zero; + for(int i = 0; i < nrows; i++) { + try { + curr = ctx.mkAdd(curr, ctx.mkMul(vars[i], getRealValue(b[i][j]))); + } + catch(Exception e) { + System.out.println(a[i][j]); + System.out.println(String.valueOf(a[i][j])); + e.printStackTrace(); + } + } + xexps[j] = curr; + } + } + + public void computeEquilibria() { + ArrayList dists; + Distribution dist1; + Distribution dist2; + double p; + Model model = null; + BoolExpr rstr; + BoolExpr prstr; + long start, end; + int i,j; + + BoolExpr c1; + BoolExpr c2; + + BoolExpr p1; + BoolExpr p2; + + //in order to check for indifference + BoolExpr xeqrst = ctx.mkTrue(); + BoolExpr yeqrst = ctx.mkTrue(); + + start = new Date().getTime(); + + vMult(); + xLabels(); + yLabels(); + + eq = ctx.mkTrue(); + for(i = 0; i < nrows+ncols; i++) { + eq = ctx.mkAnd(eq, ctx.mkOr(xlabels[i], ylabels[i])); + } + + Expr xctr = zero; + Expr yctr = zero; + + for(i = 0; i < nrows; i++) { + xctr = ctx.mkAdd((ArithExpr) xctr, vars[i]); + } + xctr = ctx.mkEq(xctr, one); + + for(j = i; j < nrows+ncols; j++) { + yctr = ctx.mkAdd((ArithExpr) yctr, vars[j]); + } + yctr = ctx.mkEq(yctr, one); + + s.add((BoolExpr) xctr); + s.add((BoolExpr) yctr); + s.add(eq); + + j = 0; + + strat = new ArrayList>(); + eqs = new HashMap> (); + + /* + System.out.println("-- xlabels"); + for (int l = 0; l < xlabels.length; l++) { + System.out.println(l + ": " + xlabels[l]); + } + + System.out.println("-- ylabels"); + for (int l = 0; l < ylabels.length; l++) { + System.out.println(l + ": " + ylabels[l]); + } + */ + + /* + for(int nv = 0; nv < p1vars.length - 1; nv++) { + xeqrst = ctx.mkAnd(xeqrst, ctx.mkEq(p1vars[nv], p1vars[nv+1])); + } + + for(int nv = 0; nv < p2vars.length - 1; nv++) { + yeqrst = ctx.mkAnd(yeqrst, ctx.mkEq(p2vars[nv], p2vars[nv+1])); + } + */ + + /*** Too strong? ***/ + + /* + for(int nv = 0; nv < p1vars.length; nv++) { + for(int nnv = 0; nnv < p1vars.length; nnv++) { + xeqrst = ctx.mkAnd(xeqrst, + ctx.mkOr( + ctx.mkNot(ctx.mkEq(p1vars[nv], p1vars[nnv])), + ctx.mkAnd(ctx.mkEq(p1vars[nv], zero), + ctx.mkEq(p1vars[nnv], zero)) + ) + ); + } + } + + for(int nv = 0; nv < p2vars.length; nv++) { + for(int nnv = 0; nnv < p2vars.length; nnv++) { + xeqrst = ctx.mkAnd(xeqrst, + ctx.mkOr( + ctx.mkNot(ctx.mkEq(p2vars[nv], p2vars[nnv])), + ctx.mkAnd(ctx.mkEq(p2vars[nv], zero), + ctx.mkEq(p2vars[nnv], zero)) + ) + ); + } + } + */ + + /*** Too strong? ***/ + + xeqrst = ctx.mkNot(xeqrst); + yeqrst = ctx.mkNot(yeqrst); + + boolean indif = false; + + addPayoffs(); + + /* + Optimize opt = ctx.mkOptimize(); + opt.Add(ctx.mkEq(payoffs[0], payvars[0])); + opt.Add(ctx.mkEq(payoffs[1], payvars[1])); + opt.MkMaximize(payvars[0]); + Optimize.Handle mx = opt.MkMaximize(payvars[0]); + Optimize.Handle my = opt.MkMaximize(payvars[1]); + */ + + while (Status.SATISFIABLE == s.check()) { + model = s.getModel(); + rstr = ctx.mkFalse(); + + c1 = ctx.mkTrue(); + c2 = ctx.mkTrue(); + + /* + if(j > 0) { + if(((BoolExpr) model.eval(xeqrst, true)).isFalse()) { + System.out.println("## Player 1 is indifferent. ##"); + indif = true; + //break; + } + if(((BoolExpr) model.eval(yeqrst, true)).isFalse()) { + System.out.println("## Player 2 is indifferent. ##"); + indif = true; + //break; + } + } + */ + + //System.out.println(getDoubleValue(model, payvars[0])); + //System.out.println(getDoubleValue(model, payvars[1])); + //compPayoffs(model); + + dists = new ArrayList(); + dist1 = new Distribution(); + dist2 = new Distribution(); + + for(i = 0; i < vars.length; i++) { + p = getDoubleValue(model, vars[i]); + if(p > 0) { + if(i < nrows) + dist1.add(i, p); + else + dist2.add(i - nrows, p); + } + if(j == 0) { + eqs.put(vars[i].getSExpr(), new ArrayList ()); + eqs.get(vars[i].getSExpr()).add(p); + } + else { + //System.out.println((RatNum) model.getConstInterp(vars[i])); + eqs.get(vars[i].getSExpr().toString()).add(p); + } + //rstr = ctx.mkOr(rstr, ctx.mkNot(ctx.mkEq(vars[i], (RealExpr) model.getConstInterp(vars[i])))); + } + + for(i = 0; i < p1vars.length; i++) { + if(((BoolExpr) model.eval(ctx.mkEq(p1vars[i], zero), true)).isFalse()) { + c1 = ctx.mkAnd(c1, ctx.mkNot(ctx.mkEq(p1vars[i], zero))); + } + else { + c1 = ctx.mkAnd(c1, ctx.mkEq(p1vars[i], zero)); + } + } + + for(i = 0; i < p2vars.length; i++) { + if(((BoolExpr) model.eval(ctx.mkEq(p2vars[i], zero), true)).isFalse()) { + c2 = ctx.mkAnd(c2, ctx.mkNot(ctx.mkEq(p2vars[i], zero))); + } + else { + c2 = ctx.mkAnd(c2, ctx.mkEq(p2vars[i], zero)); + } + } + + /* + p1 = ctx.mkAnd(c2, ctx.mkEq(payvars[0], model.getConstInterp(payvars[0]))); + p2 = ctx.mkAnd(c1, ctx.mkEq(payvars[1], model.getConstInterp(payvars[1]))); + */ + + /* + prstr = ctx.mkAnd(ctx.mkEq(payvars[0], model.getConstInterp(payvars[0])), ctx.mkEq(payvars[1], model.getConstInterp(payvars[1]))); + */ + + //System.out.println(opt.Check()); + //System.out.println(mx.getValue()); + //System.out.println(my.getValue()); + + /* + System.out.println("--"); + for(String v : eqs.keySet()) { + System.out.println(v + " " + eqs.get(v).get(j)); + } + System.out.println("--"); + */ + + //System.out.println("$$ dist1 " + dist1); + //System.out.println("$$ dist2 " + dist2); + + + dists.add(0,dist1); + dists.add(1,dist2); + strat.add(j,dists); + + j++; + s.add(ctx.mkOr(ctx.mkNot(c1), ctx.mkNot(c2))); + + //s.add(rstr); + //s.add(ctx.mkNot(p2)); + //s.add(ctx.mkNot(p1)); + } + end = new Date().getTime(); + time = (end - start)/1000.000; + //System.out.println("Time: " + time); + if(!indif) { + //System.out.println(j + " equilibrium(a)"); + } + else { + //System.out.println(j-1 + " equilibrium(a)"); + //System.out.println("## One of the players is indifferent. ##"); + } + neq = j; + } + + public void addPayoffs() { + payvars = new RealExpr[2]; + payoffs = new ArithExpr[2]; + payvars[0] = ctx.mkRealConst("pp1"); + payvars[1] = ctx.mkRealConst("pp2"); + payoffs[0] = ctx.mkInt(0); + payoffs[1] = ctx.mkInt(0); + for(int i = 0; i < nrows; i++) { + for(int j = 0; j < ncols; j++) { + payoffs[0] = ctx.mkAdd(payoffs[0], ctx.mkMul(p1vars[i], p2vars[j], getRealValue(a[i][j]))); + payoffs[1] = ctx.mkAdd(payoffs[1], ctx.mkMul(p1vars[i], p2vars[j], getRealValue(b[i][j]))); + } + } + s.add(ctx.mkEq(payvars[0], payoffs[0])); + s.add(ctx.mkEq(payvars[1], payoffs[1])); + } + + public void compPayoffs(Model model) { + double p1p = 0.0; + double p2p = 0.0; + for(int i = 0; i < nrows; i++) { + for(int j = 0; j < ncols; j++) { + p1p += getDoubleValue(model, p1vars[i])* + getDoubleValue(model, p2vars[j])*a[i][j]; + p2p += getDoubleValue(model, p1vars[i])* + getDoubleValue(model, p2vars[j])*b[i][j]; + } + } + cp1 = getRealValue(p1p); + cp2 = getRealValue(p2p); + } + + public void compPayoffs() { + p1p = new double[neq]; + p2p = new double[neq]; + Arrays.fill(p1p, 0.0); + Arrays.fill(p2p, 0.0); + for(int e = 0; e < neq; e++) { + for(int i = 0; i < nrows; i++) { + for(int j = 0; j < ncols; j++) { + //p1p[e] += eqs.get(lvp1[i].toString()).get(e) * eqs.get(lvp2[j].toString()).get(e) * Precision.round(a[i][j], 9, BigDecimal.ROUND_HALF_EVEN); + //p2p[e] += eqs.get(lvp1[i].toString()).get(e) * eqs.get(lvp2[j].toString()).get(e) * Precision.round(b[i][j], 9, BigDecimal.ROUND_HALF_EVEN); + p1p[e] += eqs.get(p1vars[i].toString()).get(e) * eqs.get(p2vars[j].toString()).get(e) * a[i][j]; + p2p[e] += eqs.get(p1vars[i].toString()).get(e) * eqs.get(p2vars[j].toString()).get(e) * b[i][j]; + } + } + } + } + + public void print() { + for(int i = 0; i < neq; i++) { + for(String v : eqs.keySet()) { + System.out.println(v + " " + eqs.get(v).get(i)); + } + System.out.println("p1 " + p1p[i]); + System.out.println("p2 " + p2p[i]); + } + } + + public double getDoubleValue(Model model, Expr expr) { + RatNum v1; + AlgebraicNum v2; + if(model.getConstInterp(expr) instanceof RatNum) { + v1 = (RatNum) model.getConstInterp(expr); + return (Double) (v1.getBigIntNumerator().doubleValue() / v1.getBigIntDenominator().doubleValue()); + } + else if (model.getConstInterp(expr) instanceof AlgebraicNum) { + v2 = (AlgebraicNum) model.getConstInterp(expr); + v1 = v2.toUpper(12); + return (Double) (v1.getBigIntNumerator().doubleValue() / v1.getBigIntDenominator().doubleValue()); + } + else + return Double.NaN; + } + + public ArithExpr getRealValue(double v) { + BigFraction fr; + ArithExpr result = null; + result = ctx.mkReal((long) (Math.pow(10, ndigits) * v)); + result = ctx.mkDiv(result, ctx.mkReal((long) (Math.pow(10, ndigits)))); + /* + try { + fr = new BigFraction(v, 0.0000000000001D, 10000); + result = ctx.mkReal(fr.getNumeratorAsLong()); + result = ctx.mkDiv(result, ctx.mkReal(fr.getDenominatorAsLong())); + } + catch (Exception e) { + e.printStackTrace(); + } + */ + return result; + } + + public RealExpr[] getP1vars() { + return p1vars; + } + + public RealExpr[] getP2vars() { + return p2vars; + } + + public double[] getP1p() { + return p1p; + } + + public double[] getP2p() { + return p2p; + } + + public int getNeq() { + return neq; + } + + public ArrayList> getStrat() { + return strat; + } + + public HashMap> getEqs() { + return eqs; + } + + public String[] getLvp1() { + return lvp1; + } + + public String[] getLvp2() { + return lvp2; + } + + @Override + public String getSolverName() { + return solverName; + } + +} diff --git a/prism/src/explicit/CSGLabeledPolytopesZ3Stack.java b/prism/src/explicit/CSGLabeledPolytopesZ3Stack.java index 7ca201134..1b80f9d5d 100644 --- a/prism/src/explicit/CSGLabeledPolytopesZ3Stack.java +++ b/prism/src/explicit/CSGLabeledPolytopesZ3Stack.java @@ -1,3 +1,30 @@ +//============================================================================== +// +// Copyright (c) 2002- +// Authors: +// * Dave Parker (University of Oxford) +// * Gabriel Santos (University of Oxford) +// +//------------------------------------------------------------------------------ +// +// This file is part of PRISM. +// +// PRISM 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. +// +// PRISM 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 PRISM; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +//============================================================================== + package explicit; import java.util.ArrayList; @@ -19,10 +46,11 @@ import prism.PrismException; + public class CSGLabeledPolytopesZ3Stack implements CSGLabeledPolytopes { - private String solverName = "Z3"; - + private String solverName; + private RealExpr[] payvars; private ArithExpr[] payoffs; private RealExpr[] vars; @@ -41,39 +69,44 @@ public class CSGLabeledPolytopesZ3Stack implements CSGLabeledPolytopes private BoolExpr eq; private int nrows = 0; private int ncols = 0; - + private BoolExpr[] tmpc; private BoolExpr[] tmpr; - + private Model model; - + private Expr xctr; private Expr yctr; private BoolExpr c1; private BoolExpr c2; - + private int neq = 0; private double[] p1p; private double[] p2p; private double[][] a; private double[][] b; - + private String[] lvp1; - private String[] lvp2; - - private Context ctx; - private Solver s; - + private String[] lvp2; + + private Context ctx; + private Solver s; + private HashMap> eqs; - private ArrayList> strat; - - public CSGLabeledPolytopesZ3Stack(int nrows, int ncols) throws PrismException - { - initSolver(); - s = ctx.mkSolver(); - eqs = new HashMap>(); + private ArrayList> strat; + + + public CSGLabeledPolytopesZ3Stack() { + + } + + public CSGLabeledPolytopesZ3Stack(int nrows, int ncols) throws PrismException + { + initSolver(); + s = ctx.mkSolver(); + eqs = new HashMap>(); zero = ctx.mkInt(0); - one = ctx.mkInt(1); + one = ctx.mkInt(1); vars = new RealExpr[nrows+ncols]; lvp1 = new String[nrows]; lvp2 = new String[ncols]; @@ -101,37 +134,31 @@ public CSGLabeledPolytopesZ3Stack(int nrows, int ncols) throws PrismException s.add(ctx.mkLe(v, one)); s.add(ctx.mkGe(v, zero)); } - } - - /** - * Initialise the solver - */ - private void initSolver() throws PrismException - { - HashMap cfg = new HashMap(); - cfg.put("model", "true"); - cfg.put("auto_config", "true"); - try { - ctx = new Context(cfg); - solverName = Version.getFullVersion(); - } catch (UnsatisfiedLinkError e) { - throw new PrismException("Could not initialise Z3: " + e.getMessage()); - } - } - - @Override - public String getSolverName() - { - return solverName; - } - + } + + /** + * Initialise the solver + */ + private void initSolver() throws PrismException + { + HashMap cfg = new HashMap(); + cfg.put("model", "true"); + cfg.put("auto_config", "true"); + try { + ctx = new Context(cfg); + solverName = Version.getFullVersion(); + } catch (UnsatisfiedLinkError e) { + throw new PrismException("Could not initialise Z3: " + e.getMessage()); + } + } + public void update(int nrows, int ncols, double[][] a, double[][] b) { this.nrows = nrows; this.ncols = ncols; this.a = a; this.b = b; } - + private void xLabels() { int l = 0; int j = 0; @@ -157,7 +184,7 @@ private void xLabels() { } } } - + private void yLabels() { int l = 0; int j = 0; @@ -183,7 +210,7 @@ private void yLabels() { } } } - + private void vMult() { for(int i = 0; i < nrows; i++) { curr = zero; @@ -214,8 +241,8 @@ private void vMult() { xexps[j] = curr; } } - - public void compEq() { + + public void computeEquilibria() { ArrayList dists; Distribution dist1; Distribution dist2; @@ -232,7 +259,7 @@ public void compEq() { /* if (st == 1) System.out.println(xlabels[i]); - */ + */ eq = ctx.mkAnd(eq, ctx.mkOr(xlabels[i], ylabels[i])); } for(i = 0; i < nrows; i++) { @@ -246,77 +273,75 @@ public void compEq() { s.add((BoolExpr) xctr); s.add((BoolExpr) yctr); s.add(eq); - strat = new ArrayList>(); + strat = new ArrayList>(); eqs.clear(); - j = 0; - while (Status.SATISFIABLE == s.check()) { - model = s.getModel(); - c1 = ytrue; - c2 = ytrue; - dists = new ArrayList(); - dist1 = new Distribution(); - dist2 = new Distribution(); - //System.out.println("---"); - for (i = 0; i < nrows+ncols; i++) { - //p = model.bigRationalValue(vars[i]).doubleValue(); - p = getDoubleValue(model, vars[i]); - //System.out.println(p); - if(p > 0) { - if(i < nrows) - dist1.add(i, p); - else - dist2.add(i - nrows, p); - } - if (j == 0) { - if (i < nrows) { - eqs.put(lvp1[i], new ArrayList()); - eqs.get(lvp1[i]).add(p); - } - else { - eqs.put(lvp2[i-nrows], new ArrayList()); - eqs.get(lvp2[i-nrows]).add(p); - } - } - else { - if (i < nrows) { - eqs.get(lvp1[i]).add(p); - } - else { - eqs.get(lvp2[i-nrows]).add(p); - } - } - } - for(i = 0; i < nrows+ncols; i++) { + j = 0; + while (Status.SATISFIABLE == s.check()) { + model = s.getModel(); + c1 = ytrue; + c2 = ytrue; + dists = new ArrayList(); + dist1 = new Distribution(); + dist2 = new Distribution(); + //System.out.println("---"); + for (i = 0; i < nrows+ncols; i++) { + //p = model.bigRationalValue(vars[i]).doubleValue(); + p = getDoubleValue(model, vars[i]); + //System.out.println(p); + if(p > 0) { + if(i < nrows) + dist1.add(i, p); + else + dist2.add(i - nrows, p); + } + if (j == 0) { + if (i < nrows) { + eqs.put(lvp1[i], new ArrayList()); + eqs.get(lvp1[i]).add(p); + } + else { + eqs.put(lvp2[i-nrows], new ArrayList()); + eqs.get(lvp2[i-nrows]).add(p); + } + } + else { + if (i < nrows) { + eqs.get(lvp1[i]).add(p); + } + else { + eqs.get(lvp2[i-nrows]).add(p); + } + } + } + for(i = 0; i < nrows+ncols; i++) { if (i < nrows) { - //if (Double.compare(model.bigRationalValue(vars[i]).doubleValue(), 0.0) != 0) { - if (Double.compare(eqs.get(lvp1[i]).get(j), 0.0) != 0) { - c1 = ctx.mkAnd(c1, ctx.mkNot(ctx.mkEq(vars[i], zero))); - } - else { - c1 = ctx.mkAnd(c1, ctx.mkEq(vars[i], zero)); - } + //if (Double.compare(model.bigRationalValue(vars[i]).doubleValue(), 0.0) != 0) { + if (Double.compare(eqs.get(lvp1[i]).get(j), 0.0) != 0) { + c1 = ctx.mkAnd(c1, ctx.mkNot(ctx.mkEq(vars[i], zero))); + } + else { + c1 = ctx.mkAnd(c1, ctx.mkEq(vars[i], zero)); + } } else { - //if (Double.compare(model.bigRationalValue(vars[i]).doubleValue(), 0.0) != 0) { - if (Double.compare(eqs.get(lvp2[i-nrows]).get(j), 0.0) != 0) { - c2 = ctx.mkAnd(c2, ctx.mkNot(ctx.mkEq(vars[i], zero))); - } - else { - c2 = ctx.mkAnd(c2, ctx.mkEq(vars[i], zero)); - } + //if (Double.compare(model.bigRationalValue(vars[i]).doubleValue(), 0.0) != 0) { + if (Double.compare(eqs.get(lvp2[i-nrows]).get(j), 0.0) != 0) { + c2 = ctx.mkAnd(c2, ctx.mkNot(ctx.mkEq(vars[i], zero))); + } + else { + c2 = ctx.mkAnd(c2, ctx.mkEq(vars[i], zero)); + } } - } - dists.add(0, dist1); - dists.add(1, dist2); - strat.add(j, dists); - j++; - s.add(ctx.mkOr(ctx.mkNot(c1), ctx.mkNot(c2))); - } + } + dists.add(0, dist1); + dists.add(1, dist2); + strat.add(j, dists); + j++; + s.add(ctx.mkOr(ctx.mkNot(c1), ctx.mkNot(c2))); + } //System.out.println(eqs); - s.pop(); - //YicesWrapper.garbage_collect(); - //YicesWrapper.yices_exit(); - neq = j; + s.pop(); + neq = j; } public void compPayoffs() { @@ -325,19 +350,19 @@ public void compPayoffs() { Arrays.fill(p1p, 0.0); Arrays.fill(p2p, 0.0); for(int e = 0; e < neq; e++) { - for(int i = 0; i < nrows; i++) { - for(int j = 0; j < ncols; j++) { - p1p[e] += eqs.get(lvp1[i]).get(e) * eqs.get(lvp2[j]).get(e) * a[i][j]; - p2p[e] += eqs.get(lvp1[i]).get(e) * eqs.get(lvp2[j]).get(e) * b[i][j]; - } - } - } + for(int i = 0; i < nrows; i++) { + for(int j = 0; j < ncols; j++) { + p1p[e] += eqs.get(lvp1[i]).get(e) * eqs.get(lvp2[j]).get(e) * a[i][j]; + p2p[e] += eqs.get(lvp1[i]).get(e) * eqs.get(lvp2[j]).get(e) * b[i][j]; + } + } + } } public double getDoubleValue(Model model, Expr expr) { RatNum v1; AlgebraicNum v2; - if(model.getConstInterp(expr) instanceof RatNum) { + if (model.getConstInterp(expr) instanceof RatNum) { v1 = (RatNum) model.getConstInterp(expr); return (Double) (v1.getBigIntNumerator().doubleValue() / v1.getBigIntDenominator().doubleValue()); } @@ -349,6 +374,12 @@ else if (model.getConstInterp(expr) instanceof AlgebraicNum) { else return Double.NaN; } + + @Override + public String getSolverName() + { + return solverName; + } public ArrayList> getStrat() { return strat; @@ -361,13 +392,13 @@ public double[] getP1p() { public double[] getP2p() { return p2p; } - + public int getNeq() { return neq; } public void clear() { - + } - + } diff --git a/prism/src/explicit/CSGModelChecker.java b/prism/src/explicit/CSGModelChecker.java index 0ddd5eb0b..cdab04ebb 100644 --- a/prism/src/explicit/CSGModelChecker.java +++ b/prism/src/explicit/CSGModelChecker.java @@ -3,7 +3,7 @@ // Copyright (c) 2002- // Authors: // * Dave Parker (University of Oxford) -// * Gabriel Santos (University of Oxford) +// * Gabriel Santos (University of Oxford) // //------------------------------------------------------------------------------ // @@ -74,7 +74,6 @@ public class CSGModelChecker extends ProbModelChecker protected HashMap adv; // probably shouldn't be global or be here at all - protected double scaleFactor = getSettings().getDouble(PrismSettings.PRISM_ZS_LP_SCALE_FACTOR); // Info about the current coalitions for model checking @@ -94,6 +93,8 @@ public class CSGModelChecker extends ProbModelChecker protected int maxRows; /** For the current coalition, the max number of columns in the matrix game across all CSG states */ protected int maxCols; + /** For each coalition, the max number of actions across all CSG states */ + protected int[] maxNumActions; /** For each coalition, the average number of actions across all CSG states */ protected double[] avgNumActions; @@ -117,6 +118,8 @@ public class CSGModelChecker extends ProbModelChecker /** True if all matrix values are equal */ protected boolean allEqual; + /** Which solver to use for linear programming */ + protected String lpSolver; protected long timerVal; @@ -131,6 +134,7 @@ public CSGModelChecker(PrismComponent parent) throws PrismException probabilities = new HashMap>(); actions = new ArrayList>(); strategies = new ArrayList>(); + lpSolver = getSettings().getString(PrismSettings.PRISM_CSG_LPSOLVER); } // Numerical computation functions @@ -138,6 +142,7 @@ public CSGModelChecker(PrismComponent parent) throws PrismException /** * Compute next-state probabilities. * i.e. compute the probability of being in a state in {@code target} in the next step. + * * @param csg The CSG * @param target Target states * @param min1 Min or max probabilities for player 1 (true=min, false=max) @@ -146,17 +151,72 @@ public CSGModelChecker(PrismComponent parent) throws PrismException */ public ModelCheckerResult computeNextProbs(CSG csg, BitSet target, boolean min1, boolean min2, Coalition coalition) throws PrismException { - ModelCheckerResult res = null; + ModelCheckerResult res = new ModelCheckerResult(); + LpSolve lp; + ArrayList> mgame = new ArrayList>(); + Map mmap = null; + List>>> lstrat = null; + List> kstrat = null; + double[] nsol = new double[csg.getNumStates()]; + long timer; + int s, i; + if (genStrat || exportAdv) { + mmap = new HashMap(); + kstrat = new ArrayList>(); + lstrat = new ArrayList>>>(1); + lstrat.add(0, new ArrayList>>()); + lstrat.get(0).add(0, new ArrayList>()); + for (i = 0; i < csg.getNumStates(); i++) { + lstrat.get(0).get(0).add(i, null); + kstrat.add(i, null); + } + } if (verbosity >= 1) mainLog.println("\nStarting next probabilistic reachability for CSGs..."); + timer = System.currentTimeMillis(); buildCoalitions(csg, coalition, min1); switch (solnMethod) { case VALUE_ITERATION: - res = computeReachProbsValIter(csg, new BitSet(), new BitSet(), 1, true, min1); + for (s = 0; s < csg.getNumStates(); s++) { + nsol[s] = target.get(s)? 1.0 : 0.0; + } + try { + lp = LpSolve.makeLp(maxCols + 1, maxRows + 1); + lp.setVerbose(LpSolve.CRITICAL); + if (min1) + lp.resizeLp(0, maxCols + 1); + else + lp.resizeLp(0, maxRows + 1); + + } catch (Exception e) { + e.printStackTrace(); + throw new PrismException(e.toString()); + } + for (s = 0; s < csg.getNumStates(); s++) { + mgame = buildMatrixGame(csg, null, mmap, nsol, s, min1); + nsol[s] = val(lp, mgame, kstrat, mmap, s, true, min1); + if ((genStrat || exportAdv)) { + // player -> iteration -> state -> indexes -> value + if (lstrat.get(0).get(0).get(s) == null) { + lstrat.get(0).get(0).set(s, kstrat.get(s)); + } else if (!lstrat.get(0).get(0).get(s).equals(kstrat.get(s))) { + lstrat.get(0).get(0).set(s, kstrat.get(s)); + } + } + } break; default: throw new PrismException("Unknown CSG solution method " + solnMethod); } + timer = System.currentTimeMillis() - timer; + mainLog.println("Next probability computation took " + 1 + " iters and " + timer / 1000.0 + " seconds."); + res.soln = nsol; + res.lastSoln = null; + res.numIters = 1; + res.timeTaken = timer / 1000.0; + res.timePre = 0.0; + if (genStrat || exportAdv) + res.strat = new CSGStrategy(csg, lstrat, new BitSet(), target, new BitSet(), CSGStrategyType.ZERO_SUM); return res; } @@ -164,6 +224,7 @@ public ModelCheckerResult computeNextProbs(CSG csg, BitSet target, boolean min1, * Compute bounded reachability/until probabilities. * i.e. compute the min/max probability of reaching a state in {@code target}, * within k steps, and while remaining in states in {@code remain}. + * * @param csg The CSG * @param remain Remain in these states (optional: null means "all") * @param target Target states @@ -200,6 +261,7 @@ public ModelCheckerResult computeBoundedReachProbs(CSG csg, BitSet remain, BitSe * Compute until probabilities. * i.e. compute the min/max probability of reaching a state in {@code target}, * and while remaining in states in {@code remain}. + * * @param csg The CSG * @param remain Remain in these states (optional: null means "all") * @param target Target states @@ -216,6 +278,7 @@ public ModelCheckerResult computeUntilProbs(CSG csg, BitSet remain, BitSet targe * Compute bounded until probabilities. * i.e. compute the min/max probability of reaching a state in {@code target}, * within k steps, and while remaining in states in {@code remain}. + * * @param csg The CSG * @param remain Remain in these states (optional: null means "all") * @param target Target states @@ -227,12 +290,19 @@ public ModelCheckerResult computeUntilProbs(CSG csg, BitSet remain, BitSet targe public ModelCheckerResult computeBoundedUntilProbs(CSG csg, BitSet remain, BitSet target, int k, boolean min1, boolean min2, Coalition coalition) throws PrismException { - return computeUntilProbs(csg, remain, target, k, min1, min2, coalition); + ModelCheckerResult res; + Boolean tmp; + tmp = precomp; + precomp = false; + res = computeUntilProbs(csg, remain, target, k, min1, min2, coalition); + precomp = tmp; + return res; } /** * Compute (possibly bounded) reachability probabilities. * i.e. compute the min/max probability of reaching a state in {@code target}. + * * @param csg The CSG * @param target Target states * @param k Bound @@ -259,7 +329,7 @@ public ModelCheckerResult computeReachProbs(CSG csg, BitSet target, boolean min1 yes.or(target); - // If <>Pmax=?[F phi], sets coaltiion to compute <>Pmax>=1 [G ¬phi] to compute the set "no", that is, the + // If <>Pmax=?[F phi], sets coalition to compute <>Pmax>=1 [G ¬phi] to compute the set "no", that is, the // set of states from which N\C can ensure that C will not to reach phi // If <>Pmin=?[F phi], sets coalition to compute <>Pmax>=1 [G ¬phi] to compute the set "no", that is, the // set of states from which C can ensure not to reach phi @@ -310,6 +380,7 @@ public ModelCheckerResult computeReachProbs(CSG csg, BitSet target, boolean min1 * Compute (possibly bounded) reachability/until probabilities. * i.e. compute the min/max probability of reaching a state in {@code target}, * and while remaining in states in {@code remain}. + * * @param csg The CSG * @param remain Remain in these states (optional: null means "all") * @param target Target states @@ -325,7 +396,7 @@ public ModelCheckerResult computeUntilProbs(CSG csg, BitSet remain, BitSet targe ModelCheckerResult res = null; BitSet no, tmp, yes; int n, numYes, numNo; - long timerProb0; + long timerProb0, timerProb1; if (verbosity >= 1) mainLog.println("\nStarting probabilistic reachability (until)..."); n = csg.getNumStates(); @@ -338,10 +409,10 @@ public ModelCheckerResult computeUntilProbs(CSG csg, BitSet remain, BitSet targe tmp.andNot(target); tmp.andNot(remain); - // If <>Pmax=?[F phi], sets coaltiion to compute <>Pmax>=1 [G ¬phi] to compute the set "no", that is, the - // set of states from which N\C can ensure that C will not to reach phi - // If <>Pmin=?[F phi], sets coalition to compute <>Pmax>=1 [G ¬phi] to compute the set "no", that is, the - // set of states from which C can ensure not to reach phi + // If <>Pmax=?[phi1 U phi2], sets coalition to compute <>Pmax>=1 [G ¬phi2] to compute the set "no", that is, the + // set of states from which N\C can ensure that C will not to reach phi2 + // If <>Pmin=?[phi1 U phi2], sets coalition to compute <>Pmax>=1 [G ¬phi2] to compute the set "no", that is, the + // set of states from which C can ensure not to reach phi2 buildCoalitions(csg, coalition, !min1); timerProb0 = System.currentTimeMillis(); @@ -351,15 +422,29 @@ public ModelCheckerResult computeUntilProbs(CSG csg, BitSet remain, BitSet targe no = G(csg, no); } timerProb0 = System.currentTimeMillis() - timerProb0; - no.or(tmp); tmp.clear(); + tmp.set(0, n); + tmp.andNot(remain); + tmp.andNot(target); + no.or(tmp); + + // If <>Pmax=?[phi1 U ph2], sets coalition to compute <>Pmax>=1 [F phi2] to compute the set "yes"", that is, the + // set of states from which C can reach phi with proability 1 while remaining in phi1 + // If <>Pmin=? [phi1 U phi2], sets coalition to compute <>Pmax>=1 [F phi2] to compute the set "yes", that is, the + // set of state from which N\C can force C to reach phi with probability 1 while remaining in phi1 + + buildCoalitions(csg, coalition, min1); + timerProb1 = System.currentTimeMillis(); + if (precomp && prob1) { + yes.or(AF(csg, remain, target)); + } + timerProb1 = System.currentTimeMillis() - timerProb1; yes.or(target); + numYes = yes.cardinality(); numNo = no.cardinality(); - buildCoalitions(csg, coalition, min1); - if (verbosity >= 1) mainLog.println("target=" + target.cardinality() + ", yes=" + numYes + ", no=" + numNo + ", maybe=" + (n - (numYes + numNo))); switch (solnMethod) { @@ -371,13 +456,15 @@ public ModelCheckerResult computeUntilProbs(CSG csg, BitSet remain, BitSet targe } res.timeProb0 = timerProb0 / 1000.0; + res.timePre = (timerProb0 + timerProb1) / 1000.0; if (verbosity >= 1) - mainLog.println("Precomputation took " + timerProb0 / 1000.0 + " seconds."); + mainLog.println("Precomputation took " + res.timePre / 1000.0 + " seconds."); return res; } /** * Compute reachability probabilities using value iteration. + * * @param csg The CSG * @param no Probability 0 states * @param yes Probability 1 states @@ -391,9 +478,8 @@ public ModelCheckerResult computeReachProbsValIter(CSG csg, BitSet no, BitSet ye if ((genStrat || exportAdv) && bounded) { throw new PrismException("Strategy synthesis for bounded properties is not supported yet."); } - ModelCheckerResult res = new ModelCheckerResult(); LpSolve lp; - ArrayList> mgame = new ArrayList>(); + ArrayList> mgame; List>>> lstrat = null; List> kstrat = null; Map mmap = null; @@ -406,6 +492,7 @@ public ModelCheckerResult computeReachProbsValIter(CSG csg, BitSet no, BitSet ye if (genStrat || exportAdv) { mmap = new HashMap(); kstrat = new ArrayList>(); + // player -> iteration -> state -> indexes -> value lstrat = new ArrayList>>>(); lstrat.add(0, new ArrayList>>()); lstrat.get(0).add(0, new ArrayList>()); @@ -442,30 +529,11 @@ public ModelCheckerResult computeReachProbsValIter(CSG csg, BitSet no, BitSet ye for (s = 0; s < csg.getNumStates(); s++) { if (!known.get(s)) { mgame = buildMatrixGame(csg, null, mmap, ntmp, s, min); - try { - if (min) - lp.resizeLp(0, maxCols + 1); - else - lp.resizeLp(0, maxRows + 1); - - } catch (LpSolveException e) { - throw new PrismException("Exception raised by lpSolve when resizing linear program for state " + s + " at iteration " + k); - } nsol[s] = val(lp, mgame, kstrat, mmap, s, false, min); // player -> iteration -> state -> indexes -> value - if (bounded && (genStrat || exportAdv)) { - if (lstrat.get(0).get(k).get(s) == null || !lstrat.get(0).get(k - 1).get(s).equals(kstrat.get(s))) { - lstrat.get(0).get(k).set(s, kstrat.get(s)); - } else { - lstrat.get(0).get(k).set(s, lstrat.get(0).get(k - 1).get(s)); - } - } else if (genStrat || exportAdv) { - if (lstrat.get(0).get(0).get(s) == null) { - lstrat.get(0).get(0).set(s, kstrat.get(s)); - } else if (!lstrat.get(0).get(0).get(s).equals(kstrat.get(s))) { - lstrat.get(0).get(0).set(s, kstrat.get(s)); - } - } + if (genStrat || exportAdv) { + updateStrategy(kstrat, lstrat, k, s, bounded); + } } else if (genStrat || exportAdv) { lstrat.get(0).get(0).add(s, null); } @@ -482,6 +550,7 @@ public ModelCheckerResult computeReachProbsValIter(CSG csg, BitSet no, BitSet ye } mainLog.println("\nValue iteration converged after " + k + " iterations."); timer = System.currentTimeMillis() - timer; + ModelCheckerResult res = new ModelCheckerResult(); res.soln = nsol; res.numIters = k; if (genStrat || exportAdv) @@ -493,6 +562,7 @@ public ModelCheckerResult computeReachProbsValIter(CSG csg, BitSet no, BitSet ye /** * Compute instantaneous expected rewards, * i.e. compute the min/max expected reward of the states after {@code k} steps. + * * @param csg The CSG * @param csgRewards The rewards * @param coalition The coalition of players which define player 1 @@ -559,6 +629,7 @@ public ModelCheckerResult computeInstantaneousRewards(CSG csg, CSGRewards csgRew /** * Compute expected cumulative rewards, * i.e. compute the min/max expected reward accumulated within {@code k} steps. + * * @param csg The CSG * @param csgRewards The rewards * @param coalition The coalition of players which define player 1 @@ -586,20 +657,7 @@ public ModelCheckerResult computeCumulativeRewards(CSG csg, CSGRewards csgReward /** * Compute expected total rewards, * i.e. compute the min/max expected reward accumulated. - * @param csg The CSG - * @param csgRewards The rewards - * @param coalition The coalition of players which define player 1 - * @param min1 Min or max probabilities for player 1 (true=min, false=max) - * @param min2 Min or max probabilities for player 2 (true=min, false=max) - */ - public ModelCheckerResult computeTotalRewards(CSG csg, CSGRewards csgRewards, boolean min1, boolean min2, Coalition coalition) throws PrismException - { - return computeTotalRewards(csg, csgRewards, coalition, min1, min2); - } - - /** - * Compute expected total rewards, - * i.e. compute the min/max expected reward accumulated. + * * @param csg The CSG * @param rewards The rewards * @param coalition The coalition of players which define player 1 @@ -683,23 +741,7 @@ public ModelCheckerResult computeTotalRewards(CSG csg, CSGRewards rewards, Coali /** * Compute expected reachability rewards. * i.e. compute the min/max reward accumulated to reach a state in {@code target}. - * @param csg The CSG - * @param rewards The rewards - * @param target Target states - * @param unreachingSemantics How to handle paths not reaching target - * @param min1 Min or max probabilities for player 1 (true=min, false=max) - * @param min2 Min or max probabilities for player 2 (true=min, false=max) - * @param coalition The coalition of players which define player 1 - */ - public ModelCheckerResult computeReachRewards(CSG csg, CSGRewards rewards, BitSet target, int unreachingSemantics, boolean min1, boolean min2, - Coalition coalition) throws PrismException - { - return computeReachRewards(csg, coalition, rewards, target, min1, min2, unreachingSemantics); - } - - /** - * Compute expected reachability rewards. - * i.e. compute the min/max reward accumulated to reach a state in {@code target}. + * * @param csg The CSG * @param coalition The coalition of players which define player 1 * @param rewards The rewards @@ -708,8 +750,8 @@ public ModelCheckerResult computeReachRewards(CSG csg, CSGRewards rewards, BitSe * @param min2 Min or max probabilities for player 2 (true=min, false=max) * @param unreachingSemantics How to handle paths not reaching target */ - public ModelCheckerResult computeReachRewards(CSG csg, Coalition coalition, CSGRewards rewards, BitSet target, boolean min1, boolean min2, - int unreachingSemantics) throws PrismException + public ModelCheckerResult computeReachRewards(CSG csg, CSGRewards rewards, BitSet target, int unreachingSemantics, boolean min1, boolean min2, + Coalition coalition) throws PrismException { // TODO: confirm that the case min1==min2 is not handled switch (unreachingSemantics) { @@ -727,6 +769,7 @@ public ModelCheckerResult computeReachRewards(CSG csg, Coalition coalition, CSGR /** * Compute expected reachability rewards (infinite if not reaching target). * i.e. compute the min/max reward accumulated to reach a state in {@code target}. + * * @param csg The CSG * @param coalition The coalition of players which define player 1 * @param rewards The rewards @@ -870,6 +913,7 @@ public ModelCheckerResult computeReachRewardsInfinity(CSG csg, Coalition coaliti /** * Compute expected reachability rewards (cumnulated value if not reaching target). * i.e. compute the min/max reward accumulated to reach a state in {@code target}. + * * @param csg The CSG * @param coalition The coalition of players which define player 1 * @param rewards The rewards @@ -962,6 +1006,7 @@ public ModelCheckerResult computeReachRewardsCumulative(CSG csg, Coalition coali /** * Compute expected reachability rewards using value iteration. + * * @param csg The CSG * @param rewards The rewards * @param target Target states @@ -992,7 +1037,8 @@ public ModelCheckerResult computeReachRewardsValIter(CSG csg, CSGRewards rewards if (genStrat || exportAdv) { mmap = new HashMap(); kstrat = new ArrayList>(); - lstrat = new ArrayList>>>(1); + // player -> iteration -> state -> indexes -> value + lstrat = new ArrayList>>>(); lstrat.add(0, new ArrayList>>()); lstrat.get(0).add(0, new ArrayList>()); for (i = 0; i < csg.getNumStates(); i++) { @@ -1038,29 +1084,11 @@ public ModelCheckerResult computeReachRewardsValIter(CSG csg, CSGRewards rewards for (s = 0; s < csg.getNumStates(); s++) { if (unknown.get(s)) { mgame = buildMatrixGame(csg, rewards, mmap, ntmp, s, min); - try { - if (min) - lp.resizeLp(0, maxCols + 1); - else - lp.resizeLp(0, maxRows + 1); - } catch (LpSolveException e) { - throw new PrismException("Exception raised by lpSolve when resizing linear program for state " + s + " at iteration " + k); - } nsol[s] = val(lp, mgame, kstrat, mmap, s, true, min); nsol[s] += rewards.getStateReward(s); - if (bounded && (genStrat || exportAdv)) { + if (genStrat || exportAdv) { // player -> iteration -> state -> indexes -> value - if (lstrat.get(0).get(k).get(s) == null || !lstrat.get(0).get(k - 1).get(s).equals(kstrat.get(s))) { - lstrat.get(0).get(k).set(s, kstrat.get(s)); - } else { - lstrat.get(0).get(k).set(s, lstrat.get(0).get(k - 1).get(s)); - } - } else if (genStrat || exportAdv) { - if (lstrat.get(0).get(0).get(s) == null) { - lstrat.get(0).get(0).set(s, kstrat.get(s)); - } else if (!lstrat.get(0).get(0).get(s).equals(kstrat.get(s))) { - lstrat.get(0).get(0).set(s, kstrat.get(s)); - } + updateStrategy(kstrat, lstrat, k, s, bounded); } } } @@ -1083,63 +1111,194 @@ public ModelCheckerResult computeReachRewardsValIter(CSG csg, CSGRewards rewards res.timeTaken = timer / 1000.0; return res; } - + + /** + * Deal with two-player bounded probabilistic reachability formulae + * + * @param csg The CSG + * @param coalitions A list of two coalitions + * @param exprs The list of objectives + * @param targets The list of sets of target states + * @param remain The list of sets of states we need to remain in (in case of until) + * @param bounds The list of the objectives' bounds (if applicable) + * @param min Whether we're minimising for the first coalition + * @return + * @throws PrismException + */ public ModelCheckerResult computeProbBoundedEquilibria(CSG csg, List coalitions, List exprs, BitSet[] targets, - BitSet[] remain, int[] bounds, boolean min) throws PrismException + BitSet[] remain, int[] bounds, int eqType, int crit, boolean min) throws PrismException { ModelCheckerResult res = new ModelCheckerResult(); CSGModelCheckerEquilibria csgeq = new CSGModelCheckerEquilibria(this); - res = csgeq.computeBoundedEquilibria(csg, coalitions, null, exprs, targets, remain, bounds, min); + res = csgeq.computeBoundedEquilibria(csg, coalitions, null, exprs, targets, remain, bounds, eqType, crit, min); return res; } - public ModelCheckerResult computeProbReachEquilibria(CSG csg, List coalitions, BitSet[] targets, BitSet[] remain, boolean min) - throws PrismException + /** + * Deal with two-player probabilistic reachability formulae + * + * @param csg The CSG + * @param coalitions A list of two coalitions + * @param targets The list of sets of target states + * @param remain The list of sets of states we need to remain in (in case of until) + * @param min Whether we're minimising for the first coalition + * @return + * @throws PrismException + */ + public ModelCheckerResult computeProbReachEquilibria(CSG csg, List coalitions, BitSet[] targets, BitSet[] remain, + int eqType, int crit, boolean min) throws PrismException { ModelCheckerResult res = new ModelCheckerResult(); CSGModelCheckerEquilibria csgeq = new CSGModelCheckerEquilibria(this); - res = csgeq.computeReachEquilibria(csg, coalitions, null, targets, remain, min); + res = csgeq.computeReachEquilibria(csg, coalitions, null, targets, remain, eqType, crit, min); return res; } + /** + * Deal with two-player bounded reachability rewards + * + * @param csg The CSG + * @param coalitions A list of two coalitions + * @param rewards The list of reward structures + * @param exprs The list of objectives + * @param bounds The list of the objectives' bounds (if applicable) + * @param min Whether we're minimising for the first coalition + * @return + * @throws PrismException + */ public ModelCheckerResult computeRewBoundedEquilibria(CSG csg, List coalitions, List rewards, List exprs, - int[] bounds, boolean min) throws PrismException + int[] bounds, int eqType, int crit, boolean min) throws PrismException { ModelCheckerResult res = new ModelCheckerResult(); CSGModelCheckerEquilibria csgeq = new CSGModelCheckerEquilibria(this); - res = csgeq.computeBoundedEquilibria(csg, coalitions, rewards, exprs, null, null, bounds, min); + res = csgeq.computeBoundedEquilibria(csg, coalitions, rewards, exprs, null, null, bounds, eqType, crit, min); return res; } - public ModelCheckerResult computeRewReachEquilibria(CSG csg, List coalitions, List rewards, BitSet[] targets, boolean min) + /** + * Deal with two-player reachability rewards formulae + * + * @param csg The CSG + * @param coalitions A list of two coalitions + * @param rewards The list of reward structures + * @param targets The list of sets of target states + * @param min Whether we're minimising for the first coalition + * @return + * @throws PrismException + */ + public ModelCheckerResult computeRewReachEquilibria(CSG csg, List coalitions, List rewards, BitSet[] targets, + int eqType, int crit, boolean min) throws PrismException { ModelCheckerResult res = new ModelCheckerResult(); CSGModelCheckerEquilibria csgeq = new CSGModelCheckerEquilibria(this); - res = csgeq.computeReachEquilibria(csg, coalitions, rewards, targets, null, min); + res = csgeq.computeReachEquilibria(csg, coalitions, rewards, targets, null, eqType, crit, min); return res; } - public ModelCheckerResult computeMultiProbReachEquilibria(CSG csg, List coalitions, BitSet[] targets, BitSet[] remain, boolean min) + /** + * Deal with multi-player bounded probabilistic formulae + * + * @param csg + * @param coalitions + * @param targets + * @param remain + * @param bounds + * @param eqType + * @param crit + * @param min + * @return + * @throws PrismException + */ + public ModelCheckerResult computeMultiProbBoundedEquilibria(CSG csg, List coalitions, BitSet[] targets, BitSet[] remain, + int [] bounds, int eqType, int crit, boolean min) throws PrismException { + ModelCheckerResult res = new ModelCheckerResult(); + CSGModelCheckerEquilibria csgeq = new CSGModelCheckerEquilibria(this); + res = csgeq.computeMultiBoundedEquilibria(csg, coalitions, null, null, null, null, bounds, eqType, crit, min); + return res; + } + + /** + * Deal with multi-player bounded reward formulae + * + * @param csg + * @param coalitions + * @param rewards + * @param exprs + * @param bounds + * @param eqType + * @param crit + * @param min + * @return + * @throws PrismException + */ + public ModelCheckerResult computeMultiRewBoundedEquilibria(CSG csg, List coalitions, List rewards, List exprs, + int[] bounds, int eqType, int crit, boolean min) throws PrismException { + ModelCheckerResult res = new ModelCheckerResult(); + CSGModelCheckerEquilibria csgeq = new CSGModelCheckerEquilibria(this); + res = csgeq.computeMultiBoundedEquilibria(csg, coalitions, rewards, exprs, null, null, bounds, eqType, crit, min); + return res; + } + + /** + * Deal with multi-player probabilistic reachability formulae + * + * @param csg The CSG + * @param coalitions The list of coalitions + * @param targets The list of sets of target states + * @param remain The list of sets of states we need to remain in (in case of until) + * @param min Whether we're minimising for the first coalition + * @return + * @throws PrismException + */ + public ModelCheckerResult computeMultiProbReachEquilibria(CSG csg, List coalitions, BitSet[] targets, BitSet[] remain, + int eqType, int crit, boolean min) throws PrismException { ModelCheckerResult res = new ModelCheckerResult(); CSGModelCheckerEquilibria csgeq = new CSGModelCheckerEquilibria(this); - res = csgeq.computeMultiReachEquilibria(csg, coalitions, null, targets, remain, min); + res = csgeq.computeMultiReachEquilibria(csg, coalitions, null, targets, remain, eqType, crit, min); return res; } - public ModelCheckerResult computeMultiRewReachEquilibria(CSG csg, List coalitions, List rewards, BitSet[] targets, boolean min) + /** + * Deal with multi-player reachability rewards formulae + * + * @param csg The CSG + * @param coalitions The list of coalitions + * @param rewards The list of reward structures + * @param targets The list of sets of target states + * @param min Whether we're minimising for the first coalition + * @return + * @throws PrismException + */ + public ModelCheckerResult computeMultiRewReachEquilibria(CSG csg, List coalitions, List rewards, BitSet[] targets, + int eqType, int crit, boolean min) throws PrismException { ModelCheckerResult res = new ModelCheckerResult(); CSGModelCheckerEquilibria csgeq = new CSGModelCheckerEquilibria(this); - res = csgeq.computeMultiReachEquilibria(csg, coalitions, rewards, targets, null, min); + res = csgeq.computeMultiReachEquilibria(csg, coalitions, rewards, targets, null, eqType, crit, min); return res; } + /** + * Deal with computing mixed bounded and unbounded equilibria. + * + * @param csg The CSG + * @param coalitions The list of coalitions + * @param rewards The list of reward structures + * @param exprs The list of objectives + * @param bounded Index of the objectives which are bounded + * @param targets The list of sets of target states + * @param remain The list of sets of states we need to remain in (in case of until) + * @param bounds The list of the objectives' bounds (if applicable) + * @param min Whether we're minimising for the first coalition + * @return + * @throws PrismException + */ public ModelCheckerResult computeMixedEquilibria(CSG csg, List coalitions, List rewards, List exprs, - BitSet bounded, BitSet[] targets, BitSet[] remain, int[] bounds, boolean min) throws PrismException + BitSet bounded, BitSet[] targets, BitSet[] remain, int[] bounds, int eqType, int crit, boolean min) throws PrismException { ModelCheckerResult res = new ModelCheckerResult(); CSGModelCheckerEquilibria csgeq = new CSGModelCheckerEquilibria(this); @@ -1183,7 +1342,9 @@ public ModelCheckerResult computeMixedEquilibria(CSG csg, List coalit AcceptanceType[] allowedAcceptance = { AcceptanceType.RABIN, AcceptanceType.REACH, AcceptanceType.BUCHI, AcceptanceType.STREETT, AcceptanceType.GENERIC }; - //csg.exportToDotFile(path + "/model.dot"); + /* + csg.exportToDotFile(path + "/model.dot"); + */ if (rew) { BitSet all = new BitSet(); @@ -1194,10 +1355,10 @@ public ModelCheckerResult computeMixedEquilibria(CSG csg, List coalit targets[index] = all; switch (exprs.get(index).getOperator()) { case ExpressionTemporal.R_I: - da = constructDRAForInstant("L0", false, new IntegerBound(null, false, bounds[index] + 1, false)); + da = constructDRAForInstant("L0", new IntegerBound(null, false, bounds[index] + 1, false)); break; case ExpressionTemporal.R_C: - da = constructDRAForInstant("L0", false, new IntegerBound(null, false, bounds[index], false)); + da = constructDRAForInstant("L0", new IntegerBound(null, false, bounds[index], false)); break; } @@ -1227,7 +1388,9 @@ public ModelCheckerResult computeMixedEquilibria(CSG csg, List coalit ((ModelExplicit) product.productModel).clearInitialStates(); ((ModelExplicit) product.productModel).addInitialState(product.getModelState(csg.getFirstInitialState())); - //product.productModel.exportToDotFile(path + "/product.dot"); + /* + product.productModel.exportToDotFile(path + "/product.dot"); + */ /* try { @@ -1333,15 +1496,18 @@ public ModelCheckerResult computeMixedEquilibria(CSG csg, List coalit } res = csgeq.computeReachEquilibria(csg_rm, coalitions, csg_rew_rm, filtered_targets, null); */ - res = csgeq.computeReachEquilibria(product.productModel, coalitions, newrewards, newtargets, null, min); + res = csgeq.computeReachEquilibria(product.productModel, coalitions, newrewards, newtargets, null, eqType, crit, min); } else { - res = csgeq.computeReachEquilibria(product.productModel, coalitions, null, newtargets, newremain, min); + res = csgeq.computeReachEquilibria(product.productModel, coalitions, null, newtargets, newremain, eqType, crit, min); } return res; } - // Precomputation methods + // Precomputation methods (almost surely) + /* + * Auxiliary method (as defined in L. Alfaro and T. Henzinger, Concurrent Omega-Regular Games) + */ public BitSet A(ArrayList> mdist, BitSet v2, BitSet y) { BitSet result = new BitSet(); @@ -1359,6 +1525,9 @@ public BitSet A(ArrayList> mdist, BitSet v2, BitSet y) return result; } + /* + * Auxiliary method (as defined in L. Alfaro and T. Henzinger, Concurrent Omega-Regular Games) + */ public BitSet B(ArrayList> mdist, BitSet v1, BitSet x) { BitSet result = new BitSet(); @@ -1377,6 +1546,10 @@ public BitSet B(ArrayList> mdist, BitSet v1, BitSet x) return result; } + + /* + * Auxiliary method for AF (as defined in L. Alfaro and T. Henzinger, Concurrent Omega-Regular Games) + */ public BitSet apreXY(CSG csg, BitSet x, BitSet y) throws PrismException { ArrayList> mdist; @@ -1389,6 +1562,9 @@ public BitSet apreXY(CSG csg, BitSet x, BitSet y) throws PrismException return result; } + /* + * Eventually b + */ public BitSet AF(CSG csg, BitSet b) throws PrismException { int n = csg.getNumStates(); @@ -1416,7 +1592,42 @@ public BitSet AF(CSG csg, BitSet b) throws PrismException } return y; } + + /* + * Eventually b, while remaining in a + */ + public BitSet AF(CSG csg, BitSet a, BitSet b) throws PrismException + { + int n = csg.getNumStates(); + BitSet x, y, sol1; + x = new BitSet(); + y = new BitSet(); + y.set(0, n); + sol1 = new BitSet(); + boolean done_x, done_y; + done_y = false; + while (!done_y) { + done_x = false; + x.clear(); + while (!done_x) { + sol1.clear(); + sol1.or(apreXY(csg, x, y)); + sol1.and(a); + sol1.or(b); + done_x = x.equals(sol1); + x.clear(); + x.or(sol1); + } + done_y = y.equals(x); + y.clear(); + y.or(x); + } + return y; + } + /* + * Auxiliary method for AFG (as defined in L. Alfaro and T. Henzinger, Concurrent Omega-Regular Games) + */ public boolean apreXYZ(ArrayList> mdist, BitSet x, BitSet y, BitSet z) { BitSet a, ab, e, v; @@ -1439,6 +1650,9 @@ public boolean apreXYZ(ArrayList> mdist, BitSet x, BitSe return !(v.isEmpty()); } + /* + * Auxiliary method for AFG (as defined in L. Alfaro and T. Henzinger, Concurrent Omega-Regular Games) + */ public BitSet apreXYZ(CSG csg, BitSet x, BitSet y, BitSet z) throws PrismException { ArrayList> mdist; @@ -1450,6 +1664,9 @@ public BitSet apreXYZ(CSG csg, BitSet x, BitSet y, BitSet z) throws PrismExcepti return result; } + /* + * Eventually globally b + */ public BitSet AFG(CSG csg, BitSet b) throws PrismException { int n = csg.getNumStates(); @@ -1516,7 +1733,10 @@ public void pre1(CSG csg, BitSet x, BitSet sol) throws PrismException sol.set(s, pre1(mdist, x)); } } - + + /* + * Globally b + */ public BitSet G(CSG csg, BitSet b) throws PrismException { int n = csg.getNumStates(); @@ -1538,6 +1758,32 @@ public BitSet G(CSG csg, BitSet b) throws PrismException // Utility methods for CSG solving + /** + * Update the strategy + * + * @param kstrat The strategies for all states computed in iteration k + * @param lstrat The overall strategy + * @param k Iteration k, if bounded + * @param s The index of the state + * @param bounded + */ + public void updateStrategy(List> kstrat, List>>> lstrat, int k, int s, boolean bounded) { + // player -> iteration -> state -> indexes -> value + if (bounded) { + if (lstrat.get(0).get(k).get(s) == null || !lstrat.get(0).get(k - 1).get(s).equals(kstrat.get(s))) { + lstrat.get(0).get(k).set(s, kstrat.get(s)); + } else { + lstrat.get(0).get(k).set(s, lstrat.get(0).get(k - 1).get(s)); + } + } else { + if (lstrat.get(0).get(0).get(s) == null) { + lstrat.get(0).get(0).set(s, kstrat.get(s)); + } else if (!lstrat.get(0).get(0).get(s).equals(kstrat.get(s))) { + lstrat.get(0).get(0).set(s, kstrat.get(s)); + } + } + } + /** * Compute and store information about coalitions (for a zero-sum problem): * - numPlayers and numCoalitions @@ -1599,6 +1845,8 @@ public void buildCoalitions(CSG csg, Coalition coalition, boolean min) throws Pr * Find the max size of the matrix game needed across any CSG state, * for the current coalition (as stored in coalitionIndexes). * Also compute/report the average number of actions for each coalition across all CSG states. + * + * @param csg The CSG */ public void findMaxRowsCols(CSG csg) { @@ -1627,6 +1875,14 @@ public void findMaxRowsCols(CSG csg) + PrismUtils.formatDouble2dp(avgNumActions[1]) + ")"); } + /** + * Build a matrix game with the transition distributions for state s. + * + * @param csg The CSG + * @param s Index of state to build matrix game for + * @return + * @throws PrismException + */ public ArrayList> buildMatrixDist(CSG csg, int s) throws PrismException { ArrayList> mdist = new ArrayList>(); @@ -1868,7 +2124,7 @@ public double val(LpSolve lp, ArrayList> mgame, List> mgame, List> mgame, List> mgame, List> mgame, boole //lp.printLp(); } - public static DA constructDRAForInstant(String labelA, boolean negateA, IntegerBound bounds) + /** + * Constructs the DRA for the CSGxDRA product when computing mixed bounded equilibria. + * @param labelA Label for accepting states + * @param bounds Bound for either cumulative or instant rewards + * @return + */ + public static DA constructDRAForInstant(String labelA, IntegerBound bounds) { DA dra; List apList = new ArrayList(); @@ -2121,11 +2384,7 @@ public static DA constructDRAForInstant(String labelA, // edge not labeled with the target label edge_no = new BitSet(); - if (negateA) { - edge_no.set(0); // no = a, yes = !a - } else { - edge_yes.set(0); // yes = a, no = !a - } + edge_yes.set(0); // yes = a, no = !a int yes_state = states - 1; int next_counter; @@ -2176,7 +2435,7 @@ public void filterStates(CSG csg, CSGSimple csg_rm, List rewards, Li for (int c = 0; c < csg.getNumChoices(s); c++) { // gets all choices Distribution d = new Distribution(); csg.forEachTransition(s, c, (__, t, pr) -> { // gets all targets - if (!map_state.keySet().contains(t)) { //if not yet explored + if (!map_state.keySet().contains(t)) { // if not yet explored map_state.put(t, csg_rm.addState()); filterStates(csg, csg_rm, rewards, rew_rm, t); } diff --git a/prism/src/explicit/CSGModelCheckerEquilibria.java b/prism/src/explicit/CSGModelCheckerEquilibria.java index ac5303a83..eb9b3a9e7 100644 --- a/prism/src/explicit/CSGModelCheckerEquilibria.java +++ b/prism/src/explicit/CSGModelCheckerEquilibria.java @@ -3,7 +3,7 @@ // Copyright (c) 2002- // Authors: // * Dave Parker (University of Oxford) -// * Gabriel Santos (University of Oxford) +// * Gabriel Santos (University of Oxford) // //------------------------------------------------------------------------------ // @@ -28,8 +28,6 @@ package explicit; import java.math.BigDecimal; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; @@ -39,23 +37,20 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.stream.Collectors; import org.apache.commons.math3.util.Precision; import explicit.CSGModelCheckerEquilibria.CSGResultStatus; -import explicit.ProbModelChecker.TermCrit; import explicit.rewards.CSGRewards; -import explicit.rewards.CSGRewardsSimple; import explicit.rewards.MDPRewards; -import parser.State; -import parser.VarList; import parser.ast.Coalition; -import parser.ast.Declaration; -import parser.ast.DeclarationBool; -import parser.ast.DeclarationInt; -import parser.ast.Expression; import parser.ast.ExpressionTemporal; import prism.Pair; import prism.PrismComponent; @@ -79,45 +74,73 @@ public class CSGModelCheckerEquilibria extends CSGModelChecker { private ArrayList>>> products; //[id payoff player i] private ArrayList payoffs; - + /** Gradient of the objective function (multi-player Nash) */ private HashMap>>> gradient; //{action j -> [player i, action j (index)]} private HashMap mapActionIndex; + /** Supports for a normal form game (indexed by coalition) */ private ArrayList> supports; + /** Pure supports for a normal form game (indexed by coalition) */ + private ArrayList psupports; + /** All (joint-action) supports for a given normal form game */ private ArrayList allSupports; + + /** Exclusive to correlated equilibria */ + private ArrayList>> ceConstraints; + private HashMap ceVarMap; + + /** Dominated actions */ protected BitSet[] dominated; + /** Dominating actions */ protected BitSet[] dominating; + /** Set with all the players */ protected BitSet players; - //smt solver for labelled polytopes - protected CSGLabeledPolytopes eqslps; - //smt solver for support enumeration - protected CSGSupportEnumeration eqssmt; - + /** SMT solver for labelled polytopes */ + protected CSGLabeledPolytopes smtLabeleldPolytopes; + /** SMT solver for support enumeration */ + protected CSGSupportEnumeration smtSupportEnumeration; + /** Numerical solver for support enumeration */ + protected CSGSupportEnumeration nlpSupportEnumeration; + /** Solver for correlated equilibria */ + protected CSGCorrelated ceSolver; + /** Name of the SMT solver */ protected String smtSolver; - + /** Whether to check for the assumption for equilibria model checking */ + protected boolean assumptionCheck = true; + /** Types and criteria for equilibria */ + public static final int NASH = 1; + public static final int CORR = 2; + public static final int SWEQ = 3; + public static final int FAIR = 4; + + /** Different status for SMT equilibria computation */ public enum CSGResultStatus { SAT, UNKNOWN, UNSAT; } + /** + * Create a new CSGModelCheckerEquilibria, inherit basic state from parent (unless null). + */ public CSGModelCheckerEquilibria(PrismComponent parent) throws PrismException { super(parent); players = new BitSet(); + psupports = new ArrayList(); supports = new ArrayList>(); - allSupports = new ArrayList(); - + allSupports = new ArrayList(); mapActionIndex = new HashMap(); products = new ArrayList>>>(); assertions = new HashMap>>>(); + ceConstraints = new ArrayList>>(); + ceVarMap = new HashMap(); gradient = new HashMap>>>(); payoffs = new ArrayList(); - mdpmc = new MDPModelChecker(parent); mdpmc.setVerbosity(0); - mdpmc.setSilentPrecomputations(true); - + mdpmc.setSilentPrecomputations(true); + assumptionCheck = getSettings().getBoolean(PrismSettings.PRISM_EQ_ASSUMPTION_CHECK); smtSolver = getSettings().getString(PrismSettings.PRISM_SMT_SOLVER); switch (smtSolver) { case "Z3": @@ -129,16 +152,48 @@ public CSGModelCheckerEquilibria(PrismComponent parent) throws PrismException { } } - public void setSolver() throws PrismException { - switch (smtSolver) { - case "Z3": - eqslps = new CSGLabeledPolytopesZ3Stack(maxRows, maxCols); + + /** + * Sets the solver according to the settings and the equilibrium type. + * + * @param eqType Correlated/Nash + * @return Name + * @throws PrismException + */ + public String setSolver(int eqType) throws PrismException { + String name = null; + switch (eqType) { + case CORR: + switch (lpSolver) { + case "Z3": + ceSolver = new CSGCorrelatedZ3(maxRows * maxCols, numCoalitions); + name = ceSolver.getSolverName(); + break; + default: throw new PrismException("Unsupported solver for correlated equilibria computation"); + } break; - case "Yices": - eqslps = new CSGLabeledPolytopesYicesStack(); + default: { + switch (smtSolver) { + case "Z3": + smtLabeleldPolytopes = new CSGLabeledPolytopesZ3Stack(maxRows, maxCols); + name = smtLabeleldPolytopes.getSolverName(); + break; + case "Yices": + smtLabeleldPolytopes = new CSGLabeledPolytopesYicesStack(); + name = smtLabeleldPolytopes.getSolverName(); + } + } } + return name; } + /** + * Compute and store information about coalitions (for a nonzero-sum problem): + * + * @param csg The CSG + * @param coalitions The list of coalitions + * @throws PrismException + */ public void buildCoalitions(CSG csg, List coalitions) throws PrismException { if (coalitions == null || coalitions.isEmpty()) throw new PrismException("Coalitions must not be empty"); @@ -175,6 +230,9 @@ public void buildCoalitions(CSG csg, List coalitions) throws PrismExc players.set(0, numCoalitions); } + /* + * Builds and stores all supports as BitSets of action indexes. + */ public void buildAllSupports() { BitSet support; for (int p = 0; p < numCoalitions; p++) { @@ -192,6 +250,12 @@ public void buildAllSupports() { } } + /** + * Auxiliary method for building the set of supports. + * + * @param supp Current support + * @param p Player index + */ public void buildAllSupportsAux(BitSet supp, int p) { for (BitSet s : supports.get(p)) { BitSet curr = (BitSet) supp.clone(); @@ -206,6 +270,13 @@ public void buildAllSupportsAux(BitSet supp, int p) { } } + /** + * Builds all supports for a specific player. + * + * @param supp Current support + * @param p Player index + * @param a Action index + */ public void buildSupportsPlayer(BitSet supp, int p, int a) { BitSet gt0 = (BitSet) supp.clone(); if (!dominated[p].get(strategies.get(p).get(a))) { @@ -226,6 +297,46 @@ public void buildSupportsPlayer(BitSet supp, int p, int a) { } } + /** + * Finds maximum and average number of actions for all coalitions. + * + * @param csg The CSG + */ + public void findMaxAvgAct(CSG csg) { + String max = "("; + String avg = "("; + int c, p, n, s; + maxRows = 0; + maxCols = 0; + avgNumActions = new double[numCoalitions]; + Arrays.fill(avgNumActions, 0.0); + maxNumActions = new int[numCoalitions]; + Arrays.fill(maxNumActions, 0); + for (s = 0; s < csg.getNumStates(); s++) { + for (c = 0; c < numCoalitions; c++) { + n = 1; + for (p = coalitionIndexes[c].nextSetBit(0); p >= 0; p = coalitionIndexes[c].nextSetBit(p + 1)) { + n *= csg.getIndexesForPlayer(s, p).cardinality(); + } + maxNumActions[c] = (maxNumActions[c] < n)? n : maxNumActions[c]; + avgNumActions[c] += n; + } + } + for (c = 0; c < numCoalitions; c++) { + avgNumActions[c] /= csg.getNumStates(); + max += (c < numCoalitions -1)? maxNumActions[c] + "," : maxNumActions[c] + ")"; + avg += (c < numCoalitions -1)? PrismUtils.formatDouble2dp(avgNumActions[c]) + "," : PrismUtils.formatDouble2dp(avgNumActions[c]) + ")"; + } + mainLog.println("Max/avg (actions): " + max + "/" + avg); + } + + /** + * Finds dominated actions for a specific player. + * + * @param p Player index + * @return + * @throws PrismException + */ public BitSet findDominated(int p) throws PrismException { Pair pair1, pair2; BitSet domi = new BitSet(); @@ -259,6 +370,13 @@ public BitSet findDominated(int p) throws PrismException { return domi; } + /** + * Finds dominating actions for a specific player. + * + * @param p Player index + * @return + * @throws PrismException + */ public BitSet findDominating(int p) throws PrismException { Pair pair1, pair2; BitSet domi = new BitSet(); @@ -291,6 +409,12 @@ public BitSet findDominating(int p) throws PrismException { return domi; } + /** + * Finds row and column indexes for the maximum entry in a matrix. + * + * @param a Matrix + * @return + */ public int[] findMaxIndexes(double[][] a) { int result[] = new int[2]; result[0] = 0; @@ -308,6 +432,150 @@ public int[] findMaxIndexes(double[][] a) { return result; } + /** + * Checks whether all entries in the utility table are zero. + * + * @return + */ + public boolean checkAllZeroEntries() { + boolean allzero = true; + for (BitSet entry : utilities.keySet()) { + for (int p = 0; p < numCoalitions; p++) { + allzero = allzero && Double.compare(utilities.get(entry).get(p), 0.0) == 0; + if (!allzero) + break; + } + if (!allzero) + break; + } + return allzero; + } + + /** + * Finds the SWNE for when just one player has choices. + * + * @param mmap Index map + * @param strats Overall strategy + * @param eqstrat Strategy for the current state + * @param active Active player + * @return + */ + public double[][] findSWNEOnePlayer(List> mmap, List>> strats, List> eqstrat, BitSet active) { + BitSet support = null; + double[][] result; + double sumt, sumv, v; + int p1, p2; + result = new double[1][numCoalitions]; + p1 = active.nextSetBit(0); + v = Double.NEGATIVE_INFINITY; + sumv = Double.NEGATIVE_INFINITY; + sumt = Double.NEGATIVE_INFINITY; + for (BitSet entry : utilities.keySet()) { + sumv = 0.0; + for (p2 = 0; p2 < numCoalitions; p2++) { + sumv += utilities.get(entry).get(p2); // computes sum of utilities + } + if (Double.compare(utilities.get(entry).get(p1), v) > 0) { // maximizes for player who has a choice + support = entry; + sumt = 0.0; + v = utilities.get(entry).get(p1); + for (p2 = 0; p2 < numCoalitions; p2++) { + result[0][p2] = utilities.get(entry).get(p2); + sumt += utilities.get(entry).get(p2); // sum of the utilities for the selected entry + } + } + else if (Double.compare(utilities.get(entry).get(p1), v) == 0 && Double.compare(sumv, sumt) > 0) { // case utility for player is the same but sum is higher + support = entry; + sumt = 0.0; + for (p2 = 0; p2 < numCoalitions; p2++) { + result[0][p2] = utilities.get(entry).get(p2); + sumt += utilities.get(entry).get(p2); + } + } + } + if (genStrat || exportAdv) { + eqstrat = new ArrayList>(); + extractStrategyFromSupport(mmap, eqstrat, support); + strats.add(eqstrat); + } + return result; + } + + /** + * Extracts the SWNE for when there is only one support. + * + * @param mmap Index map + * @param strats Overall strategy + * @param eqstrat + * @return + */ + public double[][] findSWNEUniqueSupport(List> mmap, List>> strats, List> eqstrat) { + double[][] result; + result = new double[1][numCoalitions]; + for (BitSet entry : allSupports) { + for (int p = 0; p < numCoalitions; p++) { + result[0][p] = utilities.get(entry).get(p); + } + if (genStrat || exportAdv) { + eqstrat = new ArrayList>(); + extractStrategyFromSupport(mmap, eqstrat, entry); + strats.add(eqstrat); + } + } + return result; + } + + /** + * Extracts the strategy for a given support. + * + * @param mmap Index map + * @param eqstrat Strategy for the current state + * @param support Support + */ + public void extractStrategyFromSupport(List> mmap, List> eqstrat, BitSet support) { + BitSet indx = new BitSet(); + int a, i, p; + for (p = 0; p < numCoalitions; p++) { + indx.clear(); + for (a = 0; a < strategies.get(p).size(); a++) { + indx.set(strategies.get(p).get(a)); + } + indx.and(support); + i = indx.nextSetBit(0); + eqstrat.add(p, new HashMap()); + eqstrat.get(p).put(mmap.get(p).get(strategies.get(p).indexOf(i)), 1.0); // indexOf should be changed + } + } + + /** + * Extract the strategy for the case of an unique equilibrium. + * + * @param eq Equilibria + * @param mmap Index map + * @return + */ + public ArrayList> extractStrategyFromEquilibrium(EquilibriumResult eq, List> mmap) { + ArrayList> eqstrat = new ArrayList>(); + for (int p = 0; p < numCoalitions; p++) { + eqstrat.add(p, new HashMap()); + for (int t : eq.getStrategy().get(p).getSupport()) { + eqstrat.get(p).put(mmap.get(p).get(t), eq.getStrategy().get(p).get(t)); + } + } + return eqstrat; + } + + /** + * Build info needed for the utility table to solve a CSG state s. + * + * @param csg The CSG + * @param rewards List of rewards + * @param mmap Index map + * @param val Current values for each state + * @param s State index + * @param min Whether minimising/maximising + * @throws PrismException + */ public void buildStepGame(CSG csg, List rewards, List> mmap, double[][] val, int s, boolean min) throws PrismException { Map imap = new HashMap(); BitSet jidx; @@ -318,13 +586,16 @@ public void buildStepGame(CSG csg, List rewards, List()); + psupports.add(c, new BitSet()); strategies.add(c, new ArrayList()); } for (t = 0; t < csg.getNumChoices(s); t++) { @@ -349,6 +620,7 @@ public void buildStepGame(CSG csg, List rewards, List= 0; i = tmp.nextSetBit(i + 1)) { @@ -365,28 +637,55 @@ public void buildStepGame(CSG csg, List rewards, List()); + ceVarMap.put(jidx, utilities.keySet().size() - 1); for (c = 0; c < numCoalitions; c++) { v = 0.0; - for (Iterator> iter = csg.getTransitionsIterator(s, t); iter.hasNext(); ) { - Map.Entry e = iter.next(); - v += e.getValue() * val[c][e.getKey()]; - } + for (int d : csg.getChoice(s, t).getSupport()) { + if (!Double.isNaN(val[c][d])) { + v += csg.getChoice(s, t).get(d) * val[c][d]; + } + else { + mainLog.println("val[c][d]: " + val[c][d]); + mainLog.println("\n## state " + s); + mainLog.println("-- strategies " + strategies); + mainLog.println("-- actions " + actions); + mainLog.println("-- utilities " + utilities); + throw new PrismException("Error in building game for state " + s); + } + } if (rewards != null) { if (rewards.get(c) != null) v += rewards.get(c).getTransitionReward(s, t); } - v = Precision.round(v, 12, BigDecimal.ROUND_FLOOR); + v = Precision.round(v, 12, BigDecimal.ROUND_HALF_EVEN); utilities.get(jidx).add(c, (min)? -1.0 * v : v); // might have to add min (v, 1.0) due to assertions for probabilistic } } //System.out.println("-- imap " + imap); - //System.out.println("\n## state " + s); - //System.out.println("-- strategies " + strategies); - //System.out.println("-- actions " + actions); - //System.out.println("-- utilities " + utilities); + //if (s == csg.getFirstInitialState()) { + //System.out.println("\n## state " + s); + //System.out.println("-- strategies " + strategies); + //System.out.println("-- actions " + actions); + //System.out.println("-- utilities " + utilities); + //System.out.println("-- mmap " + mmap); + //} } - public ArrayList>> buildBiMatrixGame(CSG csg, CSGRewards r1, CSGRewards r2, List> mmap, List> nmap, double[][] val, int s, boolean min) throws PrismException { + /** + * Builds a bimatrix game (two-player case). + * + * @param csg The CSG + * @param r1 Rewards for the first coalition + * @param r2 Rewards for the second coalition + * @param mmap Index map + * @param nmap Reduced index map + * @param val Current values for each state + * @param s State index + * @param min Whether minimising/maximising + * @return + * @throws PrismException + */ + public ArrayList>> buildBimatrixGame(CSG csg, CSGRewards r1, CSGRewards r2, List> mmap, List> nmap, double[][] val, int s, boolean min) throws PrismException { ArrayList>> bmgame = new ArrayList>>(); ArrayList rewards = null; BitSet action = new BitSet(); @@ -446,11 +745,17 @@ public ArrayList>> buildBiMatrixGame(CSG csg, CSGRew return bmgame; } + /** + * Clear various structures used in model checking. + * + */ public void clear() { + // Would be better to clear the internal arrays/maps supports.clear(); allSupports.clear(); products.clear(); assertions.clear(); + ceConstraints.clear(); gradient.clear(); payoffs.clear(); mapActionIndex.clear(); @@ -458,6 +763,7 @@ public void clear() { supports.add(c, new ArrayList()); products.add(c, new ArrayList>>()); assertions.put(c, new HashMap>>()); + ceConstraints.add(c, new ArrayList>()); gradient.put(c, new HashMap>>()); for(int a = 0; a < strategies.get(c).size(); a++) { products.get(c).add(a, new ArrayList>()); @@ -470,16 +776,19 @@ public void clear() { } } + /** + * Builds info used in multi-player equilibria (Nash and Correlated). + * + * @throws PrismException + */ public void computeAssertions() throws PrismException { int c, q; BitSet ps; BitSet acts = new BitSet(); for (c = 0; c < numCoalitions; c++) { - //System.out.println("\n-- player " + c + " "); ps = (BitSet) players.clone(); ps.clear(c); for (q = 0; q < strategies.get(c).size(); q++) { - //System.out.println("-- action " + q); acts.clear(); acts.set(strategies.get(c).get(q)); assertions.get(c).put(q, prodAction(acts, ps, q, c)); @@ -491,7 +800,6 @@ public void computeAssertions() throws PrismException { System.out.println("-- strategies "); System.out.println(strategies); - System.out.println("-- assertions "); for (c = 0; c < numCoalitions; c++) { System.out.println("--- player " + c); @@ -499,9 +807,8 @@ public void computeAssertions() throws PrismException { System.out.println("---- action " + q + " " + assertions.get(c).get(q)); } - /* - //System.out.println("-- gradient "); - //System.out.println(gradient); + System.out.println("-- gradient "); + System.out.println(gradient); System.out.println("-- map "); for (int i : map.keySet()) { System.out.println(i + "= " + Arrays.toString(map.get(i))); @@ -509,6 +816,16 @@ public void computeAssertions() throws PrismException { */ } + /** + * + * + * @param prod + * @param sp + * @param act + * @param p + * @return + * @throws PrismException + */ public ArrayList> prodAction(BitSet prod, BitSet sp, int act, int p) throws PrismException { prodAction(new Pair(new BitSet(), 0.0), prod, sp, act, p); ArrayList> sum = new ArrayList>(); @@ -519,6 +836,16 @@ public ArrayList> prodAction(BitSet prod, BitSet sp, int ac return sum; } + /** + * + * + * @param expr + * @param prod + * @param sp + * @param act + * @param p + * @throws PrismException + */ public void prodAction(Pair expr, BitSet prod, BitSet sp, int act, int p) throws PrismException { BitSet set; BitSet curr = (BitSet) sp.clone(); @@ -562,6 +889,14 @@ else if(products.get(p).get(act) == null) } } + /** + * + * + * @param csg + * @param target + * @param n + * @return + */ public double[][] computeBoundedReachProbs(CSG csg, BitSet target, int n) { double[][] sol = new double[n][csg.getNumStates()]; double[] sol1 = new double[csg.getNumStates()]; @@ -591,7 +926,23 @@ public double[][] computeBoundedReachProbs(CSG csg, BitSet target, int n) { return sol; } - public ModelCheckerResult computeBoundedEquilibria(CSG csg, List coalitions, List rewards, List exprs, BitSet[] targets, BitSet[] remain, int[] bounds, boolean min) throws PrismException { + /** + * Deal with two-player bounded equilibria. + * + * @param csg + * @param coalitions + * @param rewards + * @param exprs + * @param targets + * @param remain + * @param bounds + * @param eqType + * @param crit + * @param min + * @return + * @throws PrismException + */ + public ModelCheckerResult computeBoundedEquilibria(CSG csg, List coalitions, List rewards, List exprs, BitSet[] targets, BitSet[] remain, int[] bounds, int eqType, int crit, boolean min) throws PrismException { if (genStrat || exportAdv) { throw new PrismException("Strategy synthesis for bounded properties is not supported yet."); } @@ -603,8 +954,7 @@ public ModelCheckerResult computeBoundedEquilibria(CSG csg, List coal double[][] sol = new double[coalitions.size()][csg.getNumStates()]; double[][] tmp = new double[coalitions.size()][csg.getNumStates()]; double[][] val = new double[coalitions.size()][csg.getNumStates()]; - double[][] eq; - double[] sw; + double[] eq; double[] r = new double[csg.getNumStates()]; int i, j, n1, n2, k, s; boolean rew; @@ -614,8 +964,7 @@ public ModelCheckerResult computeBoundedEquilibria(CSG csg, List coal buildCoalitions(csg, coalitions); findMaxRowsCols(csg); - setSolver(); - mainLog.println("Starting bounded equilibria computation (solver=" + eqslps.getSolverName() + ")..."); + mainLog.println("Starting bounded equilibria computation (solver=" + setSolver(eqType) + ")..."); dominated = new BitSet[numCoalitions]; dominating = new BitSet[numCoalitions]; @@ -632,11 +981,10 @@ public ModelCheckerResult computeBoundedEquilibria(CSG csg, List coal } } for (s = 0; s < csg.getNumStates(); s++) { - eq = stepEquilibria(csg, null, null, null, eqslps, null, sol, s, min); - sw = swne(eq, null, min); - tmp[0][s] = sw[1]; - tmp[1][s] = sw[2]; - r[s] = sw[1] + sw[2]; + eq = stepEquilibriaTwoPlayer(csg, null, null, null, sol, s, eqType, crit, rew, min); + tmp[0][s] = eq[1]; + tmp[1][s] = eq[2]; + r[s] = eq[1] + eq[2]; } mainLog.println("\nCoalition results (initial state): (" + tmp[0][csg.getFirstInitialState()] + "," + tmp[1][csg.getFirstInitialState()] + ")"); res.soln = r; @@ -736,10 +1084,9 @@ public ModelCheckerResult computeBoundedEquilibria(CSG csg, List coal if (!(exprs.get(i).getOperator() == ExpressionTemporal.R_C)) newRewards.set(i, null); } - eq = stepEquilibria(csg, newRewards.get(0), newRewards.get(1), null, eqslps, null, sol, s, min); - sw = swne(eq, null, min); - tmp[0][s] = sw[1]; - tmp[1][s] = sw[2]; + eq = stepEquilibriaTwoPlayer(csg, newRewards, null, null, sol, s, eqType, crit, rew, min); + tmp[0][s] = eq[1]; + tmp[1][s] = eq[2]; } else { if (targets[0].get(s) && targets[1].get(s)) { @@ -767,10 +1114,9 @@ else if(!phi1[2].get(s)) { tmp[1][s] = 0.0; } else { - eq = stepEquilibria(csg, null, null, null, eqslps, null, sol, s, min); - sw = swne(eq, null, min); - tmp[0][s] = sw[1]; - tmp[1][s] = sw[2]; + eq = stepEquilibriaTwoPlayer(csg, null, null, null, sol, s, eqType, crit, rew, min); + tmp[0][s] = eq[1]; + tmp[1][s] = eq[2]; } } } @@ -837,271 +1183,168 @@ else if (n1 == 0) { return res; } - public ModelCheckerResult computeMultiReachEquilibria(CSG csg, List coalitions, List rewards, BitSet[] targets, BitSet[] remain, boolean min) throws PrismException { + /** + * Deal with multi-player bounded equilibria (unfinished). + * + * @param csg + * @param coalitions + * @param rewards + * @param exprs + * @param targets + * @param remain + * @param bounds + * @param eqType + * @param crit + * @param min + * @return + * @throws PrismException + */ + public ModelCheckerResult computeMultiBoundedEquilibria(CSG csg, List coalitions, List rewards, List exprs, BitSet[] targets, BitSet[] remain, int[] bounds, int eqType, int crit, boolean min) throws PrismException { + mainLog.println("\n# Running bounded multi-player equilibria...\n"); + if (genStrat || exportAdv) { + throw new PrismException("Strategy synthesis for bounded properties is not yet supported"); + } ModelCheckerResult res = new ModelCheckerResult(); - Declaration[] goals = new Declaration[coalitions.size()]; - //Map common = new HashMap(); - List>>> lstrat = null; - List>> sstrat = null; List> mmap = null; - Set games = new HashSet(); - BitSet unsat = new BitSet(); - BitSet ps; double[][] sol; double[][] val; double[][] tmp; double[][] eq; double[] r; double[] sw; - int i, j, k, n, p, s, t, v; + long timeTaken; boolean done, rew; + int c, k, s, t = -1; + sol = new double[coalitions.size()][csg.getNumStates()]; + val = new double[coalitions.size()][csg.getNumStates()]; + tmp = new double[coalitions.size()][csg.getNumStates()]; + r = new double[csg.getNumStates()]; + rew = rewards != null; buildCoalitions(csg, coalitions); dominated = new BitSet[numCoalitions]; dominating = new BitSet[numCoalitions]; - - VarList newvarlist = (VarList) csg.getVarList().clone(); - - for (p = 0; p < coalitions.size(); p++) { - ps = (BitSet) players.clone(); - ps.clear(p); - goals[p] = new Declaration("_" + p, new DeclarationBool()); - buildSubGames(games, ps, p); - newvarlist.addVar(goals[p].getName(), goals[p].getDeclType(), 0, csg.getConstantValues()); - } - games.add((BitSet) players.clone()); - unsat.set(0, csg.getNumStates()); - for (BitSet subgame : games) { - //BitSet intersec = new BitSet(); - //intersec.set(0, csg.getNumStates()); // intersec only seems to be used to define common, which later does not seem to be used - for (p = 0; p < coalitions.size(); p++) { - unsat.andNot(targets[p]); - // if (subgame.get(p)) - // intersec.and(targets[p]); - // else - // intersec.andNot(targets[p]); - } - //common.put(subgame, intersec); // common does not seem to be used afterwards - } - - //System.out.println("-- common " + common); - - CSGSimple newmodel = new CSGSimple(); - newmodel.copyPlayerInfo(csg); - newmodel.setActions(csg.getActions()); - newmodel.setIndexes(csg.getIndexes()); - newmodel.setIdles(csg.getIdles()); - - List newstatelist = new ArrayList(); - BitSet explored = new BitSet(); - BitSet isubgame = new BitSet(); - - s = csg.getFirstInitialState(); - - State initial = new State(csg.getVarList().getNumVars() + numCoalitions); - for (v = 0; v < csg.getVarList().getNumVars(); v++) { - initial.setValue(v, csg.getStatesList().get(s).varValues[v]); - } - - Map extmap = new HashMap(); - - if (unsat.get(s)) { - for (p = 0; p < numCoalitions; p++) { - initial.setValue(newvarlist.getIndex(goals[p].getName()), false); - } - } - else { - for (p = 0; p < numCoalitions; p++) { - if (targets[p].get(s)) { - initial.setValue(newvarlist.getIndex(goals[p].getName()), true); - isubgame.set(p); - } - else { - initial.setValue(newvarlist.getIndex(goals[p].getName()), false); - } - } - } - - //System.out.println("-- isubgame " + isubgame); - - mainLog.println("\nBuilding extended model..."); - - Map nomap = new HashMap(); - Map subgames = new HashMap(); - - n = newmodel.addState(); - newstatelist.add(n , initial); - newmodel.addInitialState(n); - - newmodel.setVarList(newvarlist); - newmodel.setStatesList(newstatelist); - - nomap.put(n, s); - extmap.put(initial.hashCode(), n); - explored.set(n); - exploreSat(csg, newmodel, nomap, extmap, subgames, newstatelist, newvarlist, goals, targets, explored, isubgame, n); - - //System.out.println("-- nomap " + nomap); - - /* - for (BitSet subset : common.keySet()) { - for (s = common.get(subset).nextSetBit(0); s >= 0; s = common.get(subset).nextSetBit(s + 1)) { - subgames.put(subset, new BitSet()); - subgames.get(subset).set(onmap.get(s)); - exploreSat(csg, newmodel, subgames, onmap, newstatelist, newvarlist, goals, targets, subset, explored, onmap.get(s)); - } - } - */ - - System.out.println("-- subgames " + subgames); - - Path currentRelativePath = Paths.get(""); - String path = currentRelativePath.toAbsolutePath().toString(); - PrismFileLog pflog = new PrismFileLog(path + "/newmodel.dot"); - newmodel.exportToDotFile(pflog, null, true); - - pflog = new PrismFileLog(path + "/model.dot"); - csg.exportToDotFile(pflog, null, true); - - mainLog.print("\n" + newmodel.infoStringTable() + "\n"); + findMaxAvgAct(csg); - sol = new double[coalitions.size()][newmodel.getNumStates()]; - val = new double[coalitions.size()][newmodel.getNumStates()]; - tmp = new double[coalitions.size()][newmodel.getNumStates()]; - r = new double[newmodel.getNumStates()]; - - List newrewards = null; if (rew) { - newrewards = new ArrayList(); - for (p = 0; p < numCoalitions; p++) { - newrewards.add(p, new CSGRewardsSimple(newmodel.getNumStates())); + t = exprs.get(0).getOperator(); + for (int i = 1; i < exprs.size(); i++) { + if (t != exprs.get(i).getOperator()) + throw new PrismException("Properties with mixed operators are not yet supported"); } - for (s = 0; s < newmodel.getNumStates(); s++) { - for (p = 0; p < numCoalitions; p++) { - ((CSGRewardsSimple) newrewards.get(p)).setStateReward(s, rewards.get(p).getStateReward(nomap.get(s))); - for (t = 0; t < newmodel.getNumChoices(s); t++) { - ((CSGRewardsSimple) newrewards.get(p)).setTransitionReward(s, t, rewards.get(p).getTransitionReward(nomap.get(s), t)); + if (t == ExpressionTemporal.R_C) { + for (c = 0; c < numCoalitions; c++) { + for (s = 0; s < csg.getNumStates(); s++) { + sol[c][s] = 0.0; } } } - for (BitSet subgame : subgames.keySet()) { - for (p = 0; p < numCoalitions; p++) { - if (subgame.get(p)) { - for (s = subgames.get(subgame).nextSetBit(0); s >= 0; s = subgames.get(subgame).nextSetBit(s + 1)) { - ((CSGRewardsSimple) newrewards.get(p)).setStateReward(s, 0.0); - for (t = 0; t < newmodel.getNumChoices(s); t++) { - ((CSGRewardsSimple) newrewards.get(p)).setTransitionReward(s, t, 0.0); - } - } + else { + for (c = 0; c < numCoalitions; c++) { + for (s = 0; s < csg.getNumStates(); s++) { + sol[c][s] = ((min)? -1 * rewards.get(c).getStateReward(s) : rewards.get(c).getStateReward(s)); } } } } else { - for (BitSet subgame : subgames.keySet()) { - for (p = 0; p < numCoalitions; p++) { - if (subgame.get(p)) { - for (s = subgames.get(subgame).nextSetBit(0); s >= 0; s = subgames.get(subgame).nextSetBit(s + 1)) { - sol[p][s] = 1.0; - } - } + for (s = 0; s < csg.getNumStates(); s++) { + for (c = 0; c < numCoalitions; c++) { + if (targets[c].get(s)) + sol[c][s] = 1.0; } } + } + + for (c = 0; c < numCoalitions; c++) { + Arrays.fill(tmp[c], 0.0); + Arrays.fill(val[c], 0.0); } - /* - for (s = 0; s < newmodel.getNumStates(); s++) { - System.out.println("## old " + nomap.get(s) + " " + csg.getStatesList().get(nomap.get(s))); - System.out.println("## new " + s + " " + newmodel.getStatesList().get(s)); - for (p = 0; p < numCoalitions; p++) { - System.out.println("-- player " + p); - System.out.println("-- state rewards old " + rewards.get(p).getStateReward(nomap.get(s))); - System.out.println("-- state rewards new " + newrewards.get(p).getStateReward(s)); - for (t = 0; t < newmodel.getNumChoices(s); t++) { - System.out.println("-- trans rewards old " + csg.getAction(nomap.get(s), t) + " " + rewards.get(p).getTransitionReward(nomap.get(s), t)); - System.out.println("-- trans rewards new " + newmodel.getAction(s, t) + " " + newrewards.get(p).getTransitionReward(s, t)); + + switch (eqType) { + case CORR : { + int maxSize = 1; + for (c = 0; c < numCoalitions; c++) { + maxSize = maxSize * maxNumActions[c]; + } + switch (lpSolver) { + case "Z3" : + ceSolver = new CSGCorrelatedZ3(maxSize, numCoalitions); + break; + default : + throw new PrismException("Solver not yet supported"); } } + default : { + smtSupportEnumeration = new CSGSupportEnumerationZ3(maxNumActions, numCoalitions); + } } - System.exit(1); + smtSupportEnumeration.setIndexes(strategies); + smtSupportEnumeration.setNumPlayers(numCoalitions); + smtSupportEnumeration.init(); + + /* + nlpSupportEnumeration = new CSGSupportEnumerationGurobi(maxNumActions, numCoalitions); + nlpSupportEnumeration.setIndexes(strategies); + nlpSupportEnumeration.setNumPlayers(numCoalitions); */ - if (genStrat || exportAdv) { - mmap = new ArrayList>(); - sstrat = new ArrayList>>(); - lstrat = new ArrayList>>>(); - for (i = 0; i < coalitions.size(); i++) { - mmap.add(i, new HashMap()); - lstrat.add(i, new ArrayList>>()); - lstrat.get(i).add(0, new ArrayList>()); - for (j = 0; j < newmodel.getNumStates(); j++) { - lstrat.get(i).get(0).add(j, null); - } - } - } - - for (p = 0; p < numCoalitions; p++) { - Arrays.fill(tmp[p], 0.0); - Arrays.fill(val[p], 0.0); - } - String sols; + done = true; k = 0; + timeTaken = System.currentTimeMillis(); while (true) { - //System.out.print(k + ": "); - for (s = 0; s < newmodel.getNumStates(); s++) { - //System.out.println("\n## s " + s + " " + newmodel.getStatesList().get(s)); - if (genStrat || exportAdv) { - sstrat = new ArrayList>>(); - for (i = 0; i < coalitions.size(); i++) { - mmap.get(i).clear(); - } - } - if (rew) { - eq = stepEquilibria(newmodel, newrewards, mmap, sstrat, sol, s, min); - addStateRewards(eq, newrewards, s, min); - } - else { - eq = stepEquilibria(newmodel, null, mmap, sstrat, sol, s, min); - } - sw = swne(eq, sstrat, min); - for (p = 0; p < numCoalitions; p++) { - val[p][s] = sw[p + 1]; - } - if (genStrat || exportAdv) { - for (p = 0; p < coalitions.size(); p++) { - if (lstrat.get(p).get(0).get(s) == null) { - lstrat.get(p).get(0).set(s, sstrat.get(0).get(p)); + for (s = 0; s < csg.getNumStates(); s++) { + //System.out.println("\ns " + s); + sw = null; + switch (eqType) { + case CORR : { + if (rew) { + if (t == ExpressionTemporal.R_C) { + sw = stepCorrelatedEquilibria(csg, rewards, mmap, null, sol, s, min, crit); + } + else { + sw = stepCorrelatedEquilibria(csg, null, mmap, null, sol, s, min, crit); + } + } + break; + } + default : { + if (rew) { + if (t == ExpressionTemporal.R_C) { + eq = stepEquilibria(csg, rewards, mmap, null, sol, s, min); + addStateRewards(eq, rewards, s, min); + } + else { + eq = stepEquilibria(csg, null, mmap, null, sol, s, min); + } } - else if (!lstrat.get(0).get(0).get(s).equals(sstrat.get(0).get(p)) && checkEquilibriumChange(sol, sw, s)) { // will have to change for min - lstrat.get(p).get(0).set(s, sstrat.get(0).get(p)); + else { + eq = stepEquilibria(csg, null, mmap, null, sol, s, min); } - } + sw = swne(eq, null, min); + } + } + for (c = 0; c < numCoalitions; c++) { + val[c][s] = sw[c + 1]; } } - for (s = 0; s < newmodel.getNumStates(); s++) { - for (p = 0; p < numCoalitions; p++) { - sol[p][s] = val[p][s]; + for (s = 0; s < csg.getNumStates(); s++) { + for (c = 0; c < numCoalitions; c++) { + sol[c][s] = val[c][s]; } r[s] = 0.0; - for (p = 0; p < numCoalitions; p++) { - r[s] += sol[p][s]; + for (c = 0; c < numCoalitions; c++) { + r[s] += sol[c][s]; } } - //System.out.println(); - sols = "("; - for (p = 0; p < numCoalitions; p++) { - if (p < numCoalitions - 1) - sols += sol[p][newmodel.getFirstInitialState()] + ","; - else - sols += sol[p][newmodel.getFirstInitialState()] + ")"; - //System.out.println(p + " " + sol[p][newmodel.getFirstInitialState()]); - done = done & PrismUtils.doublesAreClose(sol[p], tmp[p], 1e-6, true); + for (c = 0; c < numCoalitions; c++) { + done = done & PrismUtils.doublesAreClose(sol[c], tmp[c], termCritParam, termCrit == TermCrit.ABSOLUTE); } - System.out.println(k + ": " + sols); k++; - if (done) { + if (done || k == bounds[0]) { break; } else if (!done && k == maxIters) { @@ -1109,115 +1352,579 @@ else if (!done && k == maxIters) { } else { done = true; - for (p = 0; p < numCoalitions; p++) { - //System.out.println(Arrays.toString(sol[p])); - tmp[p] = Arrays.copyOf(sol[p], sol[p].length); + for (c = 0; c < numCoalitions; c++) { + tmp[c] = Arrays.copyOf(sol[c], sol[c].length); } } } + timeTaken = System.currentTimeMillis() - timeTaken; mainLog.println(); - for (p = 0; p < numCoalitions; p++) { - mainLog.println("Result for coalition " + coalitions.get(p) + ": " + sol[p][newmodel.getFirstInitialState()] + " (value in the intial state)."); + for (c = 0; c < numCoalitions; c++) { + mainLog.println("Result for coalition " + coalitions.get(c) + ": " + sol[c][csg.getFirstInitialState()] + " (value in the intial state)."); } r = new double[csg.getNumStates()]; - for (s = 0; s < newmodel.getNumStates(); s++) { - r[nomap.get(s)] = 0.0; - for (p = 0; p < numCoalitions; p++) { - r[nomap.get(s)] += sol[p][s]; + for (s = 0; s < csg.getNumStates(); s++) { + r[s] = 0.0; + for (c = 0; c < numCoalitions; c++) { + r[s] += sol[c][s]; } } - if (genStrat || exportAdv) - res.strat = new CSGStrategy(newmodel, lstrat, subgames, numCoalitions, CSGStrategyType.EQUILIBRIA_M); res.soln = r; res.numIters = k; + res.timeTaken = timeTaken / 1000.0; return res; } - public boolean checkEquilibriumChange(double[][] sol, double[] eq, int s) { - int p; - boolean result = true; - for (p = 0; p < numCoalitions; p++) { - result = result && Double.compare(sol[p][s], eq[p + 1]) == 0; - if (!result) - return true; - } - return false; - } - - public void exploreSat(CSG csg, CSGSimple newmodel, Map nomap, Map extmap, Map subgames, List newstatelist, - VarList newvarlist, Declaration[] goals, BitSet[] targets, BitSet explored, BitSet subgame, int s) { - int l; - explored.set(s); - if (!subgame.isEmpty()) { - if (!subgames.containsKey(subgame)) - subgames.put(subgame, new BitSet()); - subgames.get(subgame).set(s); - } - for (int t = 0; t < csg.getNumChoices(nomap.get(s)); t++) { - Distribution d = new Distribution(); - - for (Iterator> iter = csg.getTransitionsIterator(nomap.get(s), t); iter.hasNext(); ) { - Map.Entry e = iter.next(); - int u = e.getKey(); - State ustate = new State(newstatelist.get(s)); - BitSet usubgame = new BitSet(); - usubgame.or(subgame); - for (int v = 0; v < csg.getVarList().getNumVars(); v++) { - ustate.setValue(v, csg.getStatesList().get(u).varValues[v]); - } - for (int p = 0; p < numCoalitions; p++) { - if (targets[p].get(u)) { - ustate.setValue(newvarlist.getIndex(goals[p].getName()), true); - usubgame.set(p); - } - } - int m; - if (!extmap.containsKey(ustate.hashCode())) { - m = newmodel.addState(); - nomap.put(m, u); - extmap.put(ustate.hashCode(), m); - newstatelist.add(m, ustate); - } - else { - m = extmap.get(ustate.hashCode()); - } - if (!explored.get(m)) - exploreSat(csg, newmodel, nomap, extmap, subgames, newstatelist, newvarlist, goals, targets, explored, usubgame, m); - d.add(m, e.getValue()); - } - l = newmodel.addActionLabelledChoice(s, d, csg.getAction(nomap.get(s), t)); - newmodel.setIndexes(s, l, csg.getIndexes(nomap.get(s), t)); - } + /** + * + * + * @param n + * @param s + * @return + */ + public ModelCheckerResultMulti zeroModelCheckerResultMulti(int n, int s) { + ModelCheckerResultMulti res = new ModelCheckerResultMulti(); + double[][] soln = new double[n][s]; + for (int i = 0; i < n; i++) { + Arrays.fill(soln[i], 0.0); + } + res.solnMulti = soln; + return res; } - public void buildSubGames(Set games, BitSet sp, int p) { - BitSet prod = new BitSet(); - prod.set(p); - games.add((BitSet) prod.clone()); - for(int cp = sp.nextSetBit(0); cp >= 0; cp = sp.nextSetBit(cp + 1)) { - BitSet newprod = new BitSet(); - newprod.or(prod); - newprod.set(cp); - games.add(newprod); - } + /** + * + * + * @param csg + * @param targets + * @param remain + * @return + */ + public ModelCheckerResultMulti initialiseModelCheckerResultMulti(CSG csg, BitSet[] targets, BitSet[] remain) { + ModelCheckerResultMulti res = new ModelCheckerResultMulti(); + double[][] soln = new double[numCoalitions][csg.getNumStates()]; + for (int i = 0; i < numCoalitions; i++) { + Arrays.fill(soln[i], 0.0); + } + res.solnMulti = soln; + return res; } - public ModelCheckerResult computeReachEquilibria(CSG csg, List coalitions, List rewards, BitSet[] targets, BitSet[] remain, boolean min) throws PrismException { - ModelCheckerResult[] obj = new ModelCheckerResult[coalitions.size()]; + /** + * Deal with multi-player infinite-horizon equilibria (unfinished). + * + * @param csg + * @param coalitions + * @param rewards + * @param targets + * @param remain + * @param eqType + * @param crit + * @param min + * @return + * @throws PrismException + */ + public ModelCheckerResult computeMultiReachEquilibria(CSG csg, List coalitions, List rewards, BitSet[] targets, BitSet[] remain, int eqType, int crit, boolean min) throws PrismException { + System.out.println("# Multi-player equilibria new..."); ModelCheckerResult res = new ModelCheckerResult(); - List>>> lstrat = null; - List>> sstrat = null; - List> mmap = null; - BitSet[] only = new BitSet[targets.length]; - BitSet[] phi1 = new BitSet[3]; - BitSet known = new BitSet(); - BitSet temp = new BitSet(); - double[][] sol = new double[coalitions.size()][csg.getNumStates()]; - double[][] val = new double[coalitions.size()][csg.getNumStates()]; - double[][] tmp = new double[coalitions.size()][csg.getNumStates()]; - double[][] eq; + Map precomp; + Map> subgames = new HashMap>(); + BitSet tmp; + double[][] sol; + double[] r; + int c, s; + boolean rew; + + rew = rewards != null; + precomp = new HashMap(); + + buildCoalitions(csg, coalitions); + dominated = new BitSet[numCoalitions]; + dominating = new BitSet[numCoalitions]; + findMaxAvgAct(csg); + + for (c = 1; c < coalitions.size(); c++) { + subgames.put(c, new HashSet()); + } + + for (c = 0; c < coalitions.size(); c++) { + tmp = (BitSet) players.clone(); + tmp.clear(c); + buildSubGames(subgames, tmp, c); + } + + System.out.println("# Subgames"); + System.out.println(subgames); + + smtSupportEnumeration = new CSGSupportEnumerationZ3(maxNumActions, numCoalitions); + smtSupportEnumeration.setIndexes(strategies); + smtSupportEnumeration.setNumPlayers(numCoalitions); + smtSupportEnumeration.init(); + + /* + nlpSupportEnumeration = new CSGSupportEnumerationGurobi(maxNumActions, numCoalitions); + nlpSupportEnumeration.setIndexes(strategies); + nlpSupportEnumeration.setNumPlayers(numCoalitions); + */ + + for (c = numCoalitions; c > 0; c--) { + if (c == numCoalitions) { + tmp = new BitSet(); + tmp.set(0, numCoalitions); + precomp.put(tmp, zeroModelCheckerResultMulti(numCoalitions, csg.getNumStates())); + } + else { + for (BitSet E : subgames.get(c)) { + System.out.println(E); + precomp.put(E, computeMultiReachEquilibriaRewRec(csg, coalitions, rewards, targets, precomp, E, min, true)); + System.out.println(Arrays.toString(precomp.get(E).solnMulti)); + System.out.println("/"); + } + } + } + + if (rew) + sol = computeMultiReachEquilibriaRewRec(csg, coalitions, rewards, targets, precomp, new BitSet(), min, true).solnMulti; + else + sol = computeMultiReachEquilibriaProbRec(csg, coalitions, targets, remain, new BitSet(), new BitSet(), min, true).solnMulti; + + r = new double[csg.getNumStates()]; + for (s = 0; s < csg.getNumStates(); s++) { + r[s] = 0.0; + for (c = 0; c < numCoalitions; c++) { + r[s] += sol[c][s]; + } + } + res.soln = r; + System.exit(1); + return res; + } + + /** + * Deal with multi-player infinite-horizon (probabilistic) equilibria (unfinished). + * + * @param csg + * @param coalitions + * @param targets + * @param remain + * @param D + * @param E + * @param min + * @param main + * @return + * @throws PrismException + */ + public ModelCheckerResultMulti computeMultiReachEquilibriaProbRec(CSG csg, List coalitions, BitSet[] targets, BitSet[] remain, BitSet D, BitSet E, boolean min, boolean main) throws PrismException { + //System.out.println("# Multi-player equilibria rec..."); + ModelCheckerResultMulti res = new ModelCheckerResultMulti(); + List>>> lstrat = null; + List>> sstrat = null; + List> mmap = null; + BitSet newD, newE, uniD, uniE; + double[][] sol = new double[coalitions.size()][csg.getNumStates()]; + double[][] val = new double[coalitions.size()][csg.getNumStates()]; + double[][] tmp = new double[coalitions.size()][csg.getNumStates()]; + double[][] sub; + double[][] eqs; + double[] sel; + String sols; + int c, i, j, k, s; + boolean done; + + if (genStrat || exportAdv) { + mmap = new ArrayList>(); + sstrat = new ArrayList>>(); + lstrat = new ArrayList>>>(); + for (i = 0; i < coalitions.size(); i++) { + mmap.add(i, new HashMap()); + lstrat.add(i, new ArrayList>>()); + lstrat.get(i).add(0, new ArrayList>()); + for (j = 0; j < csg.getNumStates(); j++) { + lstrat.get(i).get(0).add(j, null); + } + } + } + for (c = 0; c < numCoalitions; c++) { + Arrays.fill(tmp[c], 0.0); + Arrays.fill(val[c], 0.0); + } + //System.out.println("-- D"); + //System.out.println(Arrays.toString(D)); + //System.out.println("-- E"); + //System.out.println(Arrays.toString(E)); + done = true; + k = 0; + while (true) { + for (s = 0; s < csg.getNumStates(); s++) { + newD = new BitSet(); + newE = new BitSet(); + for (c = 0; c < numCoalitions; c++) { + if (targets[c].get(s)) { + newD.set(c); + } + if (remain[c] != null && !remain[c].isEmpty()) { + if (!targets[c].get(s) && !remain[c].get(s)) { + newE.set(c); + } + } + } + newD.andNot(D); + newD.andNot(E); + newE.andNot(D); + newE.andNot(E); + if (genStrat || exportAdv) { + sstrat = new ArrayList>>(); + for (i = 0; i < coalitions.size(); i++) { + mmap.get(i).clear(); + } + } + if (D.cardinality() + E.cardinality() == numCoalitions) { + for (c = 0; c < numCoalitions; c++) { + val[c][s] = D.get(c)? 1.0 : 0.0; + } + } + else if (k == 0) { + for (c = 0; c < numCoalitions; c++) { + val[c][s] = targets[c].get(s)? 1.0 : 0.0; + } + } + else if (!newD.isEmpty()) { + //System.out.println("* Subgame of state " + s + ": " + csg.getStatesList().get(s)); + uniD = new BitSet(); + uniD.or(D); + uniD.or(newD); + sub = computeMultiReachEquilibriaProbRec(csg, coalitions, targets, remain, uniD, E, min, false).solnMulti; + for (c = 0; c < numCoalitions; c++) { + val[c][s] = sub[c][s]; + } + } + else if (!newE.isEmpty()) { + //System.out.println("* Subgame of state " + s + ": " + csg.getStatesList().get(s)); + uniE = new BitSet(); + uniE.or(E); + uniE.or(newE); + sub = computeMultiReachEquilibriaProbRec(csg, coalitions, targets, remain, D, uniE, min, false).solnMulti; + for (c = 0; c < numCoalitions; c++) { + val[c][s] = sub[c][s]; + } + } + else { + for (c = 0; c < numCoalitions; c++) { + if (D.get(c)) + sol[c][s] = 1.0; + else if (E.get(c)) + sol[c][s] = 0.0; + } + eqs = stepEquilibria(csg, null, mmap, sstrat, sol, s, min); + sel = swne(eqs, sstrat, min); + for (c = 0; c < numCoalitions; c++) { + val[c][s] = sel[c + 1]; + } + } + } + for (s = 0; s < csg.getNumStates(); s++) { + for (c = 0; c < numCoalitions; c++) { + sol[c][s] = E.get(c)? 0.0 : D.get(c)? 1.0 : val[c][s]; + } + } + sols = "("; + for (c = 0; c < numCoalitions; c++) { + if (c < numCoalitions - 1) + sols += sol[c][csg.getFirstInitialState()] + ","; + else + sols += sol[c][csg.getFirstInitialState()] + ")"; + done = done & PrismUtils.doublesAreClose(sol[c], tmp[c], termCritParam, termCrit == TermCrit.ABSOLUTE); + } + if (main) + mainLog.println(k + ": " + sols); + k++; + if (done && k > 1) { + break; + } + else if (!done && k == maxIters) { + throw new PrismException("Could not converge after " + k + " iterations"); + } + else { + done = true; + for (c = 0; c < numCoalitions; c++) { + tmp[c] = Arrays.copyOf(sol[c], sol[c].length); + } + } + } + res.solnMulti = sol; + res.numIters = k; + return res; + } + + /** + * Deal with multi-player infinite-horizon (probabilistic) equilibria (unfinished). + * + * @param csg + * @param coalitions + * @param rewards + * @param targets + * @param subgames + * @param D + * @param min + * @param main + * @return + * @throws PrismException + */ + public ModelCheckerResultMulti computeMultiReachEquilibriaRewRec(CSG csg, List coalitions, List rewards, BitSet[] targets, Map subgames, BitSet D, boolean min, boolean main) throws PrismException { + //System.out.println("# Multi-player equilibria rec..."); + ModelCheckerResultMulti res = new ModelCheckerResultMulti(); + ModelCheckerResultMulti sub; + List>>> lstrat = null; + List>> sstrat = null; + List> mmap = null; + BitSet newD, uniD; + double[][] sol = new double[coalitions.size()][csg.getNumStates()]; + double[][] val = new double[coalitions.size()][csg.getNumStates()]; + double[][] tmp = new double[coalitions.size()][csg.getNumStates()]; + double[][] eqs; + double[] sel; + String sols; + int c, i, j, k, s; + boolean done; + + if (genStrat || exportAdv) { + mmap = new ArrayList>(); + sstrat = new ArrayList>>(); + lstrat = new ArrayList>>>(); + for (i = 0; i < coalitions.size(); i++) { + mmap.add(i, new HashMap()); + lstrat.add(i, new ArrayList>>()); + lstrat.get(i).add(0, new ArrayList>()); + for (j = 0; j < csg.getNumStates(); j++) { + lstrat.get(i).get(0).add(j, null); + } + } + } + for (c = 0; c < numCoalitions; c++) { + Arrays.fill(tmp[c], 0.0); + Arrays.fill(val[c], 0.0); + } + //System.out.println("-- D"); + //System.out.println(D); + done = true; + k = 0; + while (true) { + for (s = 0; s < csg.getNumStates(); s++) { + newD = new BitSet(); + for (c = 0; c < numCoalitions; c++) { + if (targets[c].get(s)) { + newD.set(c); + } + } + newD.andNot(D); + if (D.cardinality() == numCoalitions) { + for (c = 0; c < numCoalitions; c++) { + val[c][s] = 0.0; + } + } + else if (k == 0) { + for (c = 0; c < numCoalitions; c++) { + val[c][s] = 0.0; + } + } + else if (!newD.isEmpty()) { + //System.out.println("* Subgame of state " + s + ": " + csg.getStatesList().get(s)); + if (genStrat || exportAdv) { + if (res.subGames == null) + res.subGames = new HashMap(); + } + uniD = new BitSet(); + uniD.or(D); + uniD.or(newD); + /* + if (!subgames.containsKey(uniD)) { + sub = computeMultiReachEquilibriaRewRec(csg, coalitions, rewards, targets, subgames, uniD, min, false); + if (genStrat || exportAdv) { + res.subGames.put(sub.D, sub); + } + subgames.put(uniD, sub); + } + else { + sub = subgames.get(uniD); + } + */ + sub = subgames.get(uniD); + for (c = 0; c < numCoalitions; c++) { + val[c][s] = sub.solnMulti[c][s]; + } + } + else { + if (genStrat || exportAdv) { + sstrat = new ArrayList>>(); + for (c = 0; c < coalitions.size(); c++) { + mmap.get(c).clear(); + } + } + for (c = 0; c < numCoalitions; c++) { + if (D.get(c)) + sol[c][s] = 0.0; + } + eqs = stepEquilibria(csg, rewards, mmap, sstrat, sol, s, min); + sel = swne(eqs, sstrat, min); + for (c = 0; c < numCoalitions; c++) { + val[c][s] = sel[c + 1]; + } + if (genStrat || exportAdv) { + if (main && s==0) { + System.out.println(sstrat); + } + // Doesn't work like this, needs to add memory + for (c = 0; c < coalitions.size(); c++) { + if (lstrat.get(c).get(0).get(s) == null) { + lstrat.get(c).get(0).set(s, sstrat.get(0).get(c)); + } + else if (!lstrat.get(0).get(0).get(s).equals(sstrat.get(0).get(c)) && checkEquilibriumChange(sol, sel, s)) { // will have to change for min + lstrat.get(c).get(0).set(s, sstrat.get(0).get(c)); + } + } + } + } + } + for (s = 0; s < csg.getNumStates(); s++) { + for (c = 0; c < numCoalitions; c++) { + sol[c][s] = val[c][s]; + sol[c][s] += (D.get(c))? 0.0 : ((min)? -1.0 * rewards.get(c).getStateReward(s) : rewards.get(c).getStateReward(s)); + } + } + sols = "("; + for (c = 0; c < numCoalitions; c++) { + if (c < numCoalitions - 1) + sols += sol[c][csg.getFirstInitialState()] + ","; + else + sols += sol[c][csg.getFirstInitialState()] + ")"; + done = done & PrismUtils.doublesAreClose(sol[c], tmp[c], termCritParam, termCrit == TermCrit.ABSOLUTE); + } + if (main) + mainLog.println(k + ": " + sols); + k++; + if (done && k > 1) { + break; + } + else if (!done && k == maxIters) { + throw new PrismException("Could not converge after " + k + " iterations"); + } + else { + done = true; + for (c = 0; c < numCoalitions; c++) { + tmp[c] = Arrays.copyOf(sol[c], sol[c].length); + } + } + } + if (genStrat || exportAdv) { + res.D = D; + res.strat = new CSGStrategy(csg, lstrat, null, numCoalitions, CSGStrategyType.EQUILIBRIA_M); + if (main) { + System.out.println(D); + System.out.println(res.strat); + for (Entry entry1 : res.subGames.entrySet()) { + System.out.println(entry1.getKey()); + System.out.println(entry1.getValue().strat); + if (entry1.getValue().subGames != null) { + for (Entry entry2 : entry1.getValue().subGames.entrySet()) { + System.out.println(entry2.getKey()); + System.out.println(entry2.getValue().strat); + } + } + } + } + } + res.solnMulti = sol; + res.numIters = k; + return res; + } + + /** + * + * + * @param sol + * @param eq + * @param s + * @return + */ + public boolean checkEquilibriumChange(double[][] sol, double[] eq, int s) { + int p; + boolean result = true; + for (p = 0; p < numCoalitions; p++) { + result = result && Double.compare(sol[p][s], eq[p + 1]) == 0; + if (!result) + return true; + } + return false; + } + + /** + * + * + * @param games + * @param sp + * @param p + */ + public void buildSubGames(Set games, BitSet sp, int p) { + BitSet prod = new BitSet(); + prod.set(p); + games.add((BitSet) prod.clone()); + for(int cp = sp.nextSetBit(0); cp >= 0; cp = sp.nextSetBit(cp + 1)) { + BitSet newprod = new BitSet(); + newprod.or(prod); + newprod.set(cp); + games.add(newprod); + } + } + + /** + * + * + * @param games + * @param sp + * @param p + */ + public void buildSubGames(Map> games, BitSet sp, int p) { + BitSet prod = new BitSet(); + prod.set(p); + games.get(prod.cardinality()).add((BitSet) prod.clone()); + for(int cp = sp.nextSetBit(0); cp >= 0; cp = sp.nextSetBit(cp + 1)) { + BitSet newprod = new BitSet(); + newprod.or(prod); + newprod.set(cp); + games.get(newprod.cardinality()).add(newprod); + } + } + + /** + * + * + * @param csg + * @param coalitions + * @param rewards + * @param targets + * @param remain + * @param eqType + * @param crit + * @param min + * @return + * @throws PrismException + */ + public ModelCheckerResult computeReachEquilibria(CSG csg, List coalitions, List rewards, BitSet[] targets, BitSet[] remain, int eqType, int crit, boolean min) throws PrismException { + ModelCheckerResult[] obj = new ModelCheckerResult[coalitions.size()]; + ModelCheckerResult res = new ModelCheckerResult(); + List>>> lstrat = null; + List>> sstrat = null; + List> mmap = null; + BitSet[] only = new BitSet[targets.length]; + BitSet[] phi1 = new BitSet[3]; + BitSet known = new BitSet(); + BitSet temp = new BitSet(); + double[][] sol = new double[coalitions.size()][csg.getNumStates()]; + double[][] val = new double[coalitions.size()][csg.getNumStates()]; + double[][] tmp = new double[coalitions.size()][csg.getNumStates()]; + double[] eq; double[] r = new double[csg.getNumStates()]; - double[] sw; + //double[] sw; int i, j, k, p, s; boolean done, rew; long timePrecomp; @@ -1274,12 +1981,29 @@ public ModelCheckerResult computeReachEquilibria(CSG csg, List coalit dominating = new BitSet[numCoalitions]; mainLog.println(); findMaxRowsCols(csg); - setSolver(); - mainLog.println("Starting equilibria computation (solver=" + eqslps.getSolverName() + ")..."); - // Add an exception somewhere for reachability rewards and states with positive rewards that do not reach the targets + mainLog.println("Starting equilibria computation (solver=" + setSolver(eqType) + ")..."); + mainLog.println("Checking whether all objctives are reachable..."); + + if (assumptionCheck) { + for (i = 0; i < targets.length; i++) { + temp.clear(); + if (!rew) { + if (remain[i] != null) { + temp.or(remain[i]); + temp.flip(0, csg.getNumStates()); + temp.andNot(targets[i]); + } + } + temp.or(mdpmc.prob0((MDP) csg, null, targets[i], false, null)); + temp.or(targets[i]); + if (mdpmc.prob1((MDP) csg, null, temp, true, null).cardinality() != csg.getNumStates()) + throw new PrismException("At least one of the objectives is not reachable with probability 1 from all states"); + } + } + k = 0; - if (rew) { + if (rew) { // Precompuation for rewards timePrecomp = System.currentTimeMillis(); for (i = 0; i < targets.length; i++) { @@ -1354,25 +2078,32 @@ else if (!phi1[2].get(s)) { mmap.add(p, new HashMap()); } } - if (rew) { - eq = stepEquilibria(csg, rewards.get(0), rewards.get(1), mmap, eqslps, sstrat, sol, s, min); - } - else { - eq = stepEquilibria(csg, null, null, mmap, eqslps, sstrat, sol, s, min); - } - sw = swne(eq, sstrat, min); - val[0][s] = sw[1]; - val[1][s] = sw[2]; + eq = stepEquilibriaTwoPlayer(csg, rewards, mmap, sstrat, sol, s, eqType, crit, rew, min); + val[0][s] = eq[1]; + val[1][s] = eq[2]; // player -> iteration -> state -> indexes -> value - if (genStrat || exportAdv) { - for (p = 0; p < coalitions.size(); p++) { - if (lstrat.get(p).get(0).get(s) == null) { - lstrat.get(p).get(0).set(s, sstrat.get(0).get(p)); + if (genStrat || exportAdv) { + switch (eqType) { + case CORR: { + if (lstrat.get(0).get(0).get(s) == null) { + lstrat.get(0).get(0).set(s, sstrat.get(0).get(0)); + } + else if (!lstrat.get(0).get(0).get(s).equals(sstrat.get(0).get(0)) && checkEquilibriumChange(sol, eq, s)) { + lstrat.get(0).get(0).set(s, sstrat.get(0).get(0)); + } + break; } - else if (!lstrat.get(0).get(0).get(s).equals(sstrat.get(0).get(p)) && checkEquilibriumChange(sol, sw, s)) { - lstrat.get(p).get(0).set(s, sstrat.get(0).get(p)); + default: { + for (p = 0; p < coalitions.size(); p++) { + if (lstrat.get(p).get(0).get(s) == null) { + lstrat.get(p).get(0).set(s, sstrat.get(0).get(p)); + } + else if (!lstrat.get(0).get(0).get(s).equals(sstrat.get(0).get(p)) && checkEquilibriumChange(sol, eq, s)) { + lstrat.get(p).get(0).set(s, sstrat.get(0).get(p)); + } + } } - } + } } } // loop over states @@ -1415,15 +2146,104 @@ else if (!done && k == maxIters) { mainLog.println("Coalition results (initial state): (" + sol[0][csg.getFirstInitialState()] + "," + sol[1][csg.getFirstInitialState()] + ")"); res.soln = r; if (genStrat || exportAdv) { - if (rew) - res.strat = new CSGStrategy(csg, lstrat, obj, targets, CSGStrategyType.EQUILIBRIA_R); - else - res.strat = new CSGStrategy(csg, lstrat, obj, targets, CSGStrategyType.EQUILIBRIA_P); + switch (eqType) { + case CORR: { + if (rew) + res.strat = new CSGStrategy(csg, lstrat, obj, targets, CSGStrategyType.EQUILIBRIA_CE_R); + else + res.strat = new CSGStrategy(csg, lstrat, obj, targets, CSGStrategyType.EQUILIBRIA_CE_P); + break; + } + default: { + if (rew) + res.strat = new CSGStrategy(csg, lstrat, obj, targets, CSGStrategyType.EQUILIBRIA_R); + else + res.strat = new CSGStrategy(csg, lstrat, obj, targets, CSGStrategyType.EQUILIBRIA_P); + } + } } res.numIters = k; return res; } + /** + * Selects the equilibrium that minimises the difference among the highest and lowest payoffs. + * + * @param eqs The set of equilibria + * @param strats Strategy to be updated + * @param min If minimising + * @return + */ + public double[] fair(double[][] eqs, List>> strats, boolean min) { + List> dist = null; + BitSet ifr = new BitSet(); + double[] eq = new double[numCoalitions+1]; + double[][] df = new double[eqs.length][2]; + double diff; + int i, p; + for (p = 0; p < numCoalitions; p++) { // gets first equilibrium + eq[0] += eqs[0][p]; + eq[p+1] = eqs[0][p]; + } + df[0][0] = Arrays.stream(eqs[0]).max().getAsDouble(); + df[0][1] = Arrays.stream(eqs[0]).min().getAsDouble(); + diff = df[0][0] - df[0][1]; + ifr.set(0); + if (strats != null) + dist = strats.get(0); + for (i = 1; i < eqs.length; i++) { + df[i][0] = Arrays.stream(eqs[i]).max().getAsDouble(); + df[i][1] = Arrays.stream(eqs[i]).min().getAsDouble(); + if (Double.compare(df[i][0]-df[i][1], diff) < 0) { + diff = df[i][0]-df[i][1]; + ifr.clear(); + ifr.set(i); + } + else if (Double.compare(df[i][0]-df[i][1], diff) == 0) { + ifr.set(i); + } + } + if (ifr.cardinality() == 1) { //if there is one single equilibrium that minimises the difference, we're done + i = ifr.nextSetBit(0); + eq[0] = 0.0; + for (p = 0; p < numCoalitions; p++) { + eq[0] += eqs[i][p]; + eq[p+1] = eqs[i][p]; + } + if(strats != null) + dist = strats.get(i); + final List> strat = dist; + if (strats != null) + strats.removeIf((List> e) -> !e.equals(strat)); + if (min) { + for (i = 0; i < eq.length; i++) + eq[i] = -1.0 * eq[i]; + } + return eq; + } + else { // if not, we have to look at the sum + double[][] neweqs = new double[ifr.cardinality()][numCoalitions]; + int j = 0; + for (i = ifr.nextSetBit(0); i >=0; i = ifr.nextSetBit(i+1)) { + for (p = 0; p < numCoalitions; p++) { + neweqs[j][p] = eqs[i][p]; + if (strats != null) + Collections.swap(strats, i, j); + } + j++; + } + return swne(neweqs, strats, min); + } + } + + /** + * Selects the equilibrium that maximises the sum of payoffs. + * + * @param eqs The set of equilibria. + * @param strats The strategy to be updated. + * @param min If minimising. + * @return + */ public double[] swne(double[][] eqs, List>> strats, boolean min) { List> dist = null; BitSet isw = new BitSet(); @@ -1480,6 +2300,14 @@ else if (Double.compare(sum, eq[0]) == 0) { return eq; } + /** + * + * + * @param indexes + * @param eqs + * @param eq + * @return + */ public int findMaxEqIndexes(BitSet indexes, double[][] eqs, double eq[]) { int idx; BitSet tmp = new BitSet(); @@ -1518,21 +2346,15 @@ else if (Double.compare(eqs[i][p], max) == 0) { } } - public void extractStrategyFromSupport(ArrayList> eqstrat, List> mmap, BitSet support) { - BitSet indx; - int a, i, p; - for (p = 0; p < numCoalitions; p++) { - indx = new BitSet(); - for (a = 0; a < strategies.get(p).size(); a++) { - indx.set(strategies.get(p).get(a)); - } - indx.and(support); - i = indx.nextSetBit(0); - eqstrat.add(p, new HashMap()); - eqstrat.get(p).put(mmap.get(p).get(strategies.get(p).indexOf(i)), 1.0); // indexOf should be changed - } - } - + /** + * + * + * @param eqs + * @param csgRewards1 + * @param csgRewards2 + * @param s + * @param min + */ public void addStateRewards(double[][] eqs, CSGRewards csgRewards1, CSGRewards csgRewards2, int s, boolean min) { for (int e = 0; e < eqs.length; e++) { if (csgRewards1 != null) @@ -1542,6 +2364,14 @@ public void addStateRewards(double[][] eqs, CSGRewards csgRewards1, CSGRewards c } } + /** + * + * + * @param eqs + * @param rewards + * @param s + * @param min + */ public void addStateRewards(double[][] eqs, List rewards, int s, boolean min) { int e, p; for (e = 0; e < eqs.length; e++) { @@ -1552,254 +2382,414 @@ public void addStateRewards(double[][] eqs, List rewards, int s, boo } } - public double[][] stepEquilibria(CSG csg, List rewards, List> mmap, List>> strats, double[][] val, int s, boolean min) throws PrismException { - Pair> eqsresult; - ArrayList eq; - ArrayList> eqs = new ArrayList>(); + /** + * + * + * @param eqs + * @param rewards + * @param s + * @param min + */ + public void addStateRewards(double[] eqs, List rewards, int s, boolean min) { + for (int p = 0; p < numCoalitions; p++) { + if (rewards.get(p) != null) + eqs[p+1] += ((min)? -1.0 * rewards.get(p).getStateReward(s) : rewards.get(p).getStateReward(s)); + } + } + + /** + * + * + * @param csg + * @param rewards + * @param mmap + * @param strats + * @param val + * @param s + * @param min + * @param crit + * @return + * @throws PrismException + */ + public double[] stepCorrelatedEquilibria(CSG csg, List rewards, List> mmap, List>> strats, + double[][] val, int s, boolean min, int crit) throws PrismException { + EquilibriumResult result; ArrayList> eqstrat = null; - BitSet active; - BitSet support = null; - long time; - double[][] result; - double sumt, sumv, v; - int n, p, p1, p2; - + BitSet idx = null, ps, tmp = null; + double[] eqs = new double[numCoalitions+1]; + int c, i, q; buildStepGame(csg, rewards, mmap, val, s, min); - active = csg.getConcurrentPlayers(s); - - time = System.currentTimeMillis(); - if (active.cardinality() == 1) { // in case just one player has a choice - result = new double[1][numCoalitions]; - p1 = active.nextSetBit(0); - v = Double.NEGATIVE_INFINITY; - sumv = Double.NEGATIVE_INFINITY; - sumt = Double.NEGATIVE_INFINITY; - for (BitSet entry : utilities.keySet()) { - sumv = 0.0; - for (p2 = 0; p2 < numCoalitions; p2++) { - sumv += utilities.get(entry).get(p2); // computes sum of utilities - } - if (utilities.get(entry).get(p1) > v) { // maximizes for player who has a choice - support = entry; - sumt = 0.0; - v = utilities.get(entry).get(p1); - for (p2 = 0; p2 < numCoalitions; p2++) { - result[0][p2] = utilities.get(entry).get(p2); - sumt += utilities.get(entry).get(p2); // sum of the utilities for the selected entry - } + clear(); + computeAssertions(); + for (c = 0; c < numCoalitions; c++) { + for (q = 0; q < strategies.get(c).size(); q++) { + ceConstraints.get(c).add(q, new HashMap()); + for (Pair e : assertions.get(c).get(q)) { + ps = new BitSet(); + ps.or(e.getKey()); + ceConstraints.get(c).get(q).put(ps, e.second); + } + } + } + if (genStrat || exportAdv) { + eqstrat = new ArrayList>(); + eqstrat.add(new HashMap()); + tmp = new BitSet(); + } + if (utilities.size() == 1) { + for (BitSet e : utilities.keySet()) { + for (c = 0; c < numCoalitions; c++) { + eqs[0] += utilities.get(e).get(c); + eqs[c+1] = utilities.get(e).get(c); } - else if (utilities.get(entry).get(p1) == v && sumv > sumt) { // case utility for player is the same but sum is higher - support = entry; - sumt = 0.0; - for (p2 = 0; p2 < numCoalitions; p2++) { - result[0][p2] = utilities.get(entry).get(p2); - sumt += utilities.get(entry).get(p2); + if (genStrat || exportAdv) { + idx = new BitSet(); + for (c = 0; c < numCoalitions; c++) { + tmp.clear(); + tmp.or(psupports.get(c)); + tmp.and(e); + i = tmp.nextSetBit(0); + idx.or(mmap.get(c).get(strategies.get(c).indexOf(i))); } + eqstrat.get(0).put(idx, 1.0); } } if (genStrat || exportAdv) { - eqstrat = new ArrayList>(); - extractStrategyFromSupport(eqstrat, mmap, support); - strats.add(eqstrat); + strats.add(0, eqstrat); } - return result; - } - else { - boolean allzero = true; - for (BitSet entry : utilities.keySet()) { - for (p = 0; p < numCoalitions; p++) { - allzero = allzero && Double.compare(utilities.get(entry).get(p), 0.0) == 0; - if (!allzero) - break; + } + else { + result = ceSolver.computeEquilibrium(utilities, ceConstraints, strategies, ceVarMap, crit); + if (result.getStatus() == CSGResultStatus.SAT) { + eqs[0] = 0.0; + for (Double d : result.getPayoffVector()) { + eqs[0] += d; } - if (!allzero) - break; - } - if (allzero) { - result = new double[1][numCoalitions]; - Arrays.fill(result[0], 0.0); - if (genStrat || exportAdv) { - eqstrat = new ArrayList>(); - extractStrategyFromSupport(eqstrat, mmap, (BitSet) utilities.keySet().toArray()[0]); - strats.add(eqstrat); + Arrays.fill(eqs, 0.0); + for (c = 0; c < numCoalitions; c++) { + eqs[c+1] = result.getPayoffVector().get(c); } - return result; - } - if (utilities.keySet().size() == 1) { - result = new double[1][numCoalitions]; - for (BitSet entry : utilities.keySet()) { - for (p = 0; p < numCoalitions; p++) { - result[0][p] = utilities.get(entry).get(p); - } + for (BitSet e : ceVarMap.keySet()) { if (genStrat || exportAdv) { - eqstrat = new ArrayList>(); - extractStrategyFromSupport(eqstrat, mmap, entry); - strats.add(eqstrat); + idx = new BitSet(); + for (c = 0; c < numCoalitions; c++) { + tmp.clear(); + tmp.or(psupports.get(c)); + tmp.and(e); + i = tmp.nextSetBit(0); + idx.or(mmap.get(c).get(strategies.get(c).indexOf(i))); + } + if (Double.compare(result.getStrategy().get(0).get(ceVarMap.get(e)), 0.0) > 0) + eqstrat.get(0).put(idx, result.getStrategy().get(0).get(ceVarMap.get(e))); } } - //System.out.println("-- actions " + actions); - //System.out.println("-- strategies " + strategies); - //System.out.println(utilities); - return result; + if (genStrat || exportAdv) { + strats.add(0, eqstrat); + } + } + else { + throw new PrismException(ceSolver.getSolverName() + " could not find an optimal solution for state " + s); + } + } + if (rewards != null) + addStateRewards(eqs, rewards, s, min); + if (min) { + for (i = 0; i < eqs.length; i++) + eqs[i] = -1.0 * eqs[i]; + } + return eqs; + } + + /* + public ArrayList stepParallelEquilibriaGurobi(HashSet supports) { + ArrayList eqs = new ArrayList(); + List> tasks = new ArrayList>(); + //supportCount = 0; + //System.out.println("Total supports: " + supports.size()); + for (final BitSet supp : supports) { + Callable c = new Callable() { + @Override + public EquilibriumResult call() throws Exception { + return stepEquilibriaGurobi(supp); + } + }; + tasks.add(c); + } + //ExecutorService exec = Executors.newCachedThreadPool(); + //ExecutorService exec = Executors.newFixedThreadPool(allSupports.size()); + ExecutorService exec = Executors.newFixedThreadPool(5); + //ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); + //ExecutorService exec = Executors.newSingleThreadExecutor(); + try { + List> results = exec.invokeAll(tasks); + for (Future result : results) { + if (result.get().getStatus() == CSGResultStatus.SAT) { + eqs.add(result.get()); + } } + } + catch (Exception e) { + e.printStackTrace(); + } + finally { + exec.shutdown(); + } + return eqs; + } + + public EquilibriumResult stepEquilibriaGurobi(BitSet supp) { + CSGSupportEnumerationGurobi nlpSupportEnumeration; + EquilibriumResult result = null; + nlpSupportEnumeration = new CSGSupportEnumerationGurobi(maxNumActions, numCoalitions); + nlpSupportEnumeration.setIndexes(strategies); + nlpSupportEnumeration.setNumPlayers(numCoalitions); + nlpSupportEnumeration.translateAssertions(assertions, mapActionIndex); + result = nlpSupportEnumeration.computeEquilibria(supp, mapActionIndex); + return result; + } + */ + + /** + * + * + * @param csg + * @param rewards + * @param mmap + * @param strats + * @param val + * @param s + * @param min + * @return + * @throws PrismException + */ + public double[][] stepEquilibria(CSG csg, List rewards, List> mmap, List>> strats, + double[][] val, int s, boolean min) throws PrismException { + EquilibriumResult eqsresult; + EquilibriumResult eqsresultnlp; + ArrayList> equilibria = new ArrayList>(); + ArrayList> eqstrat = null; + BitSet active; + long time; + double[][] result; + int n, p; + + buildStepGame(csg, rewards, mmap, val, s, min); + active = csg.getConcurrentPlayers(s); + + time = System.currentTimeMillis(); + + // Case when just one player has a choice + if (active.cardinality() == 1) { + return findSWNEOnePlayer(mmap, strats, eqstrat, active); + } + else { clear(); computeAssertions(); for (p = 0; p < numCoalitions; p++) { dominated[p] = findDominated(p); dominating[p] = findDominating(p); - //dominated[p] = new BitSet(); - //dominating[p] = new BitSet(); - //if (!dominated[p].isEmpty()) - //System.out.println("dominated " + p + " " + dominated[p]); - //if (!dominating[p].isEmpty()) - //System.out.println("dominating " + p + " " + dominating[p]); - } - //System.out.println("## " + s); - buildAllSupports(); - - eqssmt.setIndexes(strategies); - eqssmt.setNumPlayers(numCoalitions); - eqssmt.init(); - eqssmt.translateAssertions(assertions, mapActionIndex); - - /* - eqss.setNumPlayers(numCoalitions); - eqss.setIndexes(strategies); - eqss.setAssertions(assertions); - eqss.setGradient(gradient); - eqss.init(); - */ - - /* - //if (s == ?) { - System.out.println("\n-- assertions "); - for (int c = 0; c < numCoalitions; c++) { - System.out.println("--- player " + c); - for (int q = 0; q < strategies.get(c).size(); q++) - System.out.println("---- action " + actions.get(c).get(q) + " is " + strategies.get(c).get(q) + " " + assertions.get(c).get(q)); - } - //} - */ - - /* - if (genStrat || exportAdv) { - eqstrat = new ArrayList>(); - for (int p = 0; p < 2; p++) { - eqstrat.add(p, new HashMap()); - for (int t : nash.getStrat().get(e).get(p).getSupport()) { - eqstrat.get(p).put(mmap.get(p).get(t), nash.getStrat().get(e).get(p).get(t)); - } - } - strats.add(e, eqstrat); } - */ - - if (allSupports.size() == 1) { + buildAllSupports(); + if (checkAllZeroEntries()) { result = new double[1][numCoalitions]; - for (BitSet entry : allSupports) { - for (p = 0; p < numCoalitions; p++) { - result[0][p] = utilities.get(entry).get(p); - } - /* - String act = ""; - if (s == ?) { - //for (int i = entry.nextSetBit(0); i >= 0; i = entry.nextSetBit(i + 1)) { - // act += "[" + csg.getActions().get(i) + "]"; - //} - System.out.println("## Equilibrium (unique entry or dominating) " + entry + " " + act); - } - */ - if (genStrat || exportAdv) { - eqstrat = new ArrayList>(); - extractStrategyFromSupport(eqstrat, mmap, entry); - strats.add(eqstrat); - } + Arrays.fill(result[0], 0.0); + if (genStrat || exportAdv) { + eqstrat = new ArrayList>(); + extractStrategyFromSupport(mmap, eqstrat, (BitSet) utilities.keySet().toArray()[0]); + strats.add(eqstrat); } return result; } + if (utilities.size() == 1) { + return findSWNEUniqueSupport(mmap, strats, eqstrat); + } + + smtSupportEnumeration.translateAssertions(assertions, mapActionIndex); + //nlpSupportEnumeration.translateAssertions(assertions, mapActionIndex); + + if (allSupports.size()== 1) { + return findSWNEUniqueSupport(mmap, strats, eqstrat); + } else { - //System.out.println("Solver call"); - //System.out.println(utilities); - for (int supp = 0; supp < allSupports.size(); supp++) { - //if (allSupports.get(supp).cardinality() == 25) - //System.out.println("\n ## Support " + allSupports.get(supp)); - //System.out.println("## Support " + allSupports.get(supp)); - eqsresult = eqssmt.computeEquilibria(allSupports.get(supp), mapActionIndex, s); - //eqsresult = new Pair>(CSGResultStatus.UNKNOWN, new ArrayList()); - if (eqsresult.first == CSGResultStatus.SAT) { - /* - String act = ""; - if (s == 0) { - //System.out.println(csg.getActions()); - //for (int i = allSupports.get(supp).nextSetBit(0); i >= 0; i = allSupports.get(supp).nextSetBit(i + 1)) { - // act += "[" + csg.getActions().get(i) + "]"; - //} - System.out.println("## Equilibrium " + allSupports.get(supp) + " " + act); + HashSet unknown = new HashSet(); + HashSet unsat = new HashSet(); + HashSet sat = new HashSet(); + + //System.out.println(allSupports.size()); + for (BitSet supp : allSupports) { + + //System.out.println("\n" + supp); + if (supp.cardinality() < numCoalitions) { + mainLog.println("Support: " + supp); + for (int k = 0; k < numCoalitions; k++) { + mainLog.println("Player " + k); + mainLog.println("Dominating: " + dominating[k]); + mainLog.println("Dominated: " + dominated[k]); + mainLog.println("Action indexes: " + actionIndexes[k]); + mainLog.println("Strategies:" + strategies.get(k)); + mainLog.println("Supports:" + supports.get(k)); } - */ - eq = eqsresult.second; - eqs.add(eq); - //System.out.println("-- mmap " + mmap); - //System.out.println("-- strat " + eqssmt.getStrat()); + throw new PrismException("Problem with support"); + } + + eqsresult = smtSupportEnumeration.computeEquilibria(supp, mapActionIndex); + //eqsresult = nlpSupportEnumeration.computeEquilibria(supp, mapActionIndex); + + + if (eqsresult.getStatus() == CSGResultStatus.SAT) { + sat.add(supp); + + //eqsresult = nlpSupportEnumeration.computeEquilibria(supp, mapActionIndex); + + equilibria.add(eqsresult.getPayoffVector()); if (genStrat || exportAdv) { - eqstrat = new ArrayList>(); - for (p = 0; p < numCoalitions; p++) { - eqstrat.add(p, new HashMap()); - for (int t : eqssmt.getStrat().get(p).getSupport()) { - eqstrat.get(p).put(mmap.get(p).get(t), eqssmt.getStrat().get(p).get(t)); - } - //System.out.println("-- strat " + p + " " + eqstrat.get(p)); - } - strats.add(eqstrat); - //System.out.println("-- strats " + strats); + strats.add(extractStrategyFromEquilibrium(eqsresult, mmap)); + } + //System.out.println(equilibria); + + /* + if (eqsresult.getStatus() != eqsresultnlp.getStatus()) { + System.out.println("SMT: " + eqsresult.getStatus()); + System.out.println("NLP: " + eqsresultnlp.getStatus()); + throw new PrismException("Solvers differ."); } + */ + //System.out.println("sat"); + } + else if (eqsresult.getStatus() == CSGResultStatus.UNKNOWN) { + unknown.add(supp); - time = System.currentTimeMillis() - time; - //mainLog.println("\nFound an equilibirum in " + time / 1000.0 + " seconds."); - //System.out.println(eq); - //System.exit(1); + //eqsresult = nlpSupportEnumeration.computeEquilibria(supp, mapActionIndex); + /* + if (eqsresult.getStatus() == CSGResultStatus.SAT) { + equilibria.add(eqsresult.getPayoffVector()); + } + */ + //System.out.println("unknown"); + } + else if (eqsresult.getStatus() == CSGResultStatus.UNSAT) { + unsat.add(supp); + //System.out.println("unsat"); + /* + if (eqsresult.getStatus() != eqsresultnlp.getStatus()) { + System.out.println("SMT: " + eqsresult.getStatus()); + System.out.println("NLP: " + eqsresultnlp.getStatus()); + throw new PrismException("Solvers differ."); + } + */ } + } + + if (sat.size() != 0) { /* - else if (eqsresult.first == CSGResultStatus.UNKNOWN) {// && allSupports.get(supp).cardinality() == 18) { - //System.out.println("UNKNOWN " + allSupports.get(supp)); - eqss.setNumPlayers(numCoalitions); - eqss.setMap(map); - eqss.setIndexes(strategies); - eqss.setAssertions(assertions); - eqss.setGradient(gradient); - eqss.init(); - //System.out.println("## Support " + allSupports.get(supp)); - eqsresult = eqss.computeEquilibria(allSupports.get(supp), map, s); - if (eqsresult.first == CSGResultStatus.SAT) { - //System.out.println("## Equilibrium found " + allSupports.get(supp)); - eq = eqsresult.second; - eqs.add(eq); - - time = System.currentTimeMillis() - time; - mainLog.println("\nFound an equilibirum in " + time / 1000.0 + " seconds."); - System.out.println(eq); - System.exit(1); + for (EquilibriumResult eq : stepParallelEquilibriaGurobi(sat)) { + equilibria.add(eq.getPayoffVector()); + if (genStrat || exportAdv) { + strats.add(extractStrategyFromEquilibrium(eq, mmap)); } + //if (s == csg.getFirstInitialState()) { + // System.out.println("-- strat " + eq.getStrategy()); + //} } */ } - } - - //System.out.println(eqs); - - result = new double[eqs.size()][numCoalitions]; - - for (n = 0; n < eqs.size(); n++) { + //System.out.println("Sat supports: " + sat.size() + " " + (System.currentTimeMillis() - par)/1000.00 + " s"); + + //par = System.currentTimeMillis(); + //System.out.println("Unknown supports: " + unknown.size()); + if (unknown.size() != 0) { + /* + for (EquilibriumResult eq : stepParallelEquilibriaGurobi(unknown)) { + equilibria.add(eq.getPayoffVector()); + if (genStrat || exportAdv) { + strats.add(extractStrategyFromEquilibrium(eq, mmap)); + } + //if (s == csg.getFirstInitialState()) { + // System.out.println("-- strat " + eq.getStrategy()); + //} + } + */ + } + + //System.out.println("Unknown supports: " + unknown.size() + " " + (System.currentTimeMillis() - par)/1000.00 + " s"); + } + result = new double[equilibria.size()][numCoalitions]; + for (n = 0; n < equilibria.size(); n++) { for (p = 0; p < numCoalitions; p++) { - result[n][p] = eqs.get(n).get(p); + result[n][p] = equilibria.get(n).get(p); } } } return result; } - public double[][] stepEquilibria(CSG csg, CSGRewards csgRewards1, CSGRewards csgRewards2, List> mmap, CSGLabeledPolytopes nash, - List>> strats, double[][] val, int s, boolean min) throws PrismException { + /** + * Returns the equilibrium (array of values) and updates strategies for the two-player case. + * + * @param csg + * @param rewards + * @param mmap + * @param strats + * @param val + * @param s + * @param eqType + * @param crit + * @param rew + * @param min + * @return + * @throws PrismException + */ + public double[] stepEquilibriaTwoPlayer(CSG csg, List rewards, List> mmap, List>> strats, + double[][] val, int s, int eqType, int crit, boolean rew, boolean min) throws PrismException { + double[][] equilibria; + double[] equilibrium; + + switch (eqType) { + case CORR : { + if (rew) { + equilibrium = stepCorrelatedEquilibria(csg, rewards, mmap, strats, val, s, min, crit); + } + else + equilibrium = stepCorrelatedEquilibria(csg, null, mmap, strats, val, s, min, crit); + break; + } + default : { + if (rew) { + equilibria = stepNashEquilibria(csg, rewards.get(0), rewards.get(1), mmap, strats, val, s, min); + } + else { + equilibria = stepNashEquilibria(csg, null, null, mmap, strats, val, s, min); + } + switch (crit) { + case FAIR : { + equilibrium = fair(equilibria, strats, min); + break; + } + default : { + equilibrium = swne(equilibria, strats, min); + } + } + } + } + return equilibrium; + } + + /** + * Computes Nash equilibria for a bimatrix game. + * + * @param csg + * @param csgRewards1 + * @param csgRewards2 + * @param mmap + * @param strats + * @param val + * @param s + * @param min + * @return + * @throws PrismException + */ + public double[][] stepNashEquilibria(CSG csg, CSGRewards csgRewards1, CSGRewards csgRewards2, List> mmap, + List>> strats, double[][] val, int s, boolean min) throws PrismException { Map d1 = null; Map d2 = null; ArrayList> eqstrat; @@ -1817,7 +2807,7 @@ public double[][] stepEquilibria(CSG csg, CSGRewards csgRewards1, CSGRewards csg mmap.add(p, new HashMap()); nmap.add(p, new ArrayList()); } - bmgame = buildBiMatrixGame(csg, csgRewards1, csgRewards2, mmap, nmap, val, s, min); + bmgame = buildBimatrixGame(csg, csgRewards1, csgRewards2, mmap, nmap, val, s, min); nrows = bmgame.get(0).size(); ncols = bmgame.get(0).get(0).size(); val1s = new double[nrows][ncols]; @@ -1891,20 +2881,20 @@ public double[][] stepEquilibria(CSG csg, CSGRewards csgRewards1, CSGRewards csg addStateRewards(result, csgRewards1, csgRewards2, s, min); } else { // both players have choices and matrices are not trivial, call solver - nash.update(nrows, ncols, val1s, val2s); - nash.compEq(); - nash.compPayoffs(); - result = new double[nash.getNeq()][2]; - for (int e = 0; e < nash.getNeq(); e++) { - result[e][0] = nash.getP1p()[e]; - result[e][1] = nash.getP2p()[e]; + smtLabeleldPolytopes.update(nrows, ncols, val1s, val2s); + smtLabeleldPolytopes.computeEquilibria(); + smtLabeleldPolytopes.compPayoffs(); + result = new double[smtLabeleldPolytopes.getNeq()][2]; + for (int e = 0; e < smtLabeleldPolytopes.getNeq(); e++) { + result[e][0] = smtLabeleldPolytopes.getP1p()[e]; + result[e][1] = smtLabeleldPolytopes.getP2p()[e]; if (genStrat || exportAdv) { eqstrat = new ArrayList>(); for (int p = 0; p < 2; p++) { eqstrat.add(p, new HashMap()); //System.out.println("-- strat from solver " + nash.getStrat().get(e).get(p).getSupport()); - for (int t : nash.getStrat().get(e).get(p).getSupport()) { - eqstrat.get(p).put(mmap.get(p).get(nmap.get(p).get(t)), nash.getStrat().get(e).get(p).get(t)); + for (int t : smtLabeleldPolytopes.getStrat().get(e).get(p).getSupport()) { + eqstrat.get(p).put(mmap.get(p).get(nmap.get(p).get(t)), smtLabeleldPolytopes.getStrat().get(e).get(p).get(t)); } } strats.add(e, eqstrat); @@ -1928,7 +2918,7 @@ public double[][] stepEquilibria(CSG csg, CSGRewards csgRewards1, CSGRewards csg addStateRewards(result, csgRewards1, csgRewards2, s, min); } } - else { // just one of the players have choices + else { // just one of the players has choices result = new double[1][2]; double vt1, vt2, sumv, sumt; if(genStrat || exportAdv) { diff --git a/prism/src/explicit/CSGSupportEnumeration.java b/prism/src/explicit/CSGSupportEnumeration.java index b45753e8d..d779008ed 100644 --- a/prism/src/explicit/CSGSupportEnumeration.java +++ b/prism/src/explicit/CSGSupportEnumeration.java @@ -16,7 +16,7 @@ public interface CSGSupportEnumeration { public void setIndexes(ArrayList> a); - public Pair> computeEquilibria(BitSet supp, HashMap map, int s); + public EquilibriumResult computeEquilibria(BitSet supp, HashMap map); public void computeConstraints(BitSet supp); @@ -28,6 +28,8 @@ public interface CSGSupportEnumeration { public void setAssertions(HashMap>>> assertions); + public void setMap(HashMap map); + public ArrayList getStrat(); } diff --git a/prism/src/explicit/CSGSupportEnumerationZ3.java b/prism/src/explicit/CSGSupportEnumerationZ3.java index 91d44773f..8aa62395a 100644 --- a/prism/src/explicit/CSGSupportEnumerationZ3.java +++ b/prism/src/explicit/CSGSupportEnumerationZ3.java @@ -1,3 +1,30 @@ +//============================================================================== +// +// Copyright (c) 2002- +// Authors: +// * Dave Parker (University of Oxford) +// * Gabriel Santos (University of Oxford) +// +//------------------------------------------------------------------------------ +// +// This file is part of PRISM. +// +// PRISM 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. +// +// PRISM 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 PRISM; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +//============================================================================== + package explicit; import java.util.ArrayList; @@ -24,33 +51,35 @@ public class CSGSupportEnumerationZ3 implements CSGSupportEnumeration { private HashMap cfg; private Context ctx; - private Solver s; - - private ArrayList payoffs; - private ArrayList> strategies; + private Solver s; + private HashMap> assertions; + private ArrayList> strategies; private ArrayList> indexes; - + private ArrayList payoffs; + private IntNum zero; private IntNum one; - + private BitSet players; private BoolExpr support; - - private int numPlayers; + + private int numCoalitions; private Params params; - - private ArrayList strat; - - private int ndigits = 9; - + + private ArrayList strat; + public CSGSupportEnumerationZ3() { - cfg = new HashMap(); - cfg.put("model", "true"); - ctx = new Context(cfg); - s = ctx.mkSolver(); - - params = ctx.mkParams(); + + } + + public CSGSupportEnumerationZ3(int[] maxActions, int numCoalitions) { + cfg = new HashMap(); + cfg.put("model", "true"); + ctx = new Context(cfg); + s = ctx.mkSolver(); + + params = ctx.mkParams(); params.add("timeout", 20); s.setParameters(params); @@ -59,44 +88,29 @@ public CSGSupportEnumerationZ3() { payoffs = new ArrayList(); players = new BitSet(); strat = new ArrayList(); - } - - public void init() { - s.reset(); - s.setParameters(params); - players.clear(); - players.set(0, numPlayers); - strategies.clear(); - payoffs.clear(); + players.set(0, numCoalitions); zero = ctx.mkInt(0); - one = ctx.mkInt(1); - ArithExpr cnstr1; - for(int p = 0; p < numPlayers; p++) { - cnstr1 = zero; - strategies.add(p, new ArrayList()); - payoffs.add(p, ctx.mkRealConst("v_" + p)); - for(int a = 0; a < indexes.get(p).size(); a++) { - strategies.get(p).add(a, ctx.mkRealConst("p_" + p + "_" + a)); - s.add(ctx.mkGe(strategies.get(p).get(a), zero)); - s.add(ctx.mkLe(strategies.get(p).get(a), one)); - cnstr1 = ctx.mkAdd(cnstr1, strategies.get(p).get(a)); + one = ctx.mkInt(1); + for (int c = 0; c < numCoalitions; c++) { + strategies.add(c, new ArrayList()); + payoffs.add(c, ctx.mkRealConst("v_" + c)); + for(int a = 0; a < maxActions[c]; a++) { + strategies.get(c).add(a, ctx.mkRealConst("p_" + c + "_" + a)); + s.add(ctx.mkGe(strategies.get(c).get(a), zero)); + s.add(ctx.mkLe(strategies.get(c).get(a), one)); } - s.add(ctx.mkEq(cnstr1, one)); - } - //System.out.println(numPlayers); - //System.out.println(indexes); - //System.out.println(strategies); + } } - + public void computeConstraints(BitSet supp) { - for(int p = 0; p < indexes.size(); p++) { - for(int a = 0; a < indexes.get(p).size(); a++) { - if(supp.get(indexes.get(p).get(a))) { - s.add(ctx.mkEq(assertions.get(p).get(a), payoffs.get(p))); + for(int c = 0; c < indexes.size(); c++) { + for(int a = 0; a < indexes.get(c).size(); a++) { + if(supp.get(indexes.get(c).get(a))) { + s.add(ctx.mkEq(assertions.get(c).get(a), payoffs.get(c))); } else { - s.add(ctx.mkLe(assertions.get(p).get(a), payoffs.get(p))); + s.add(ctx.mkLe(assertions.get(c).get(a), payoffs.get(c))); } } } @@ -104,43 +118,57 @@ public void computeConstraints(BitSet supp) { public void computeSupport(BitSet supp, HashMap map) { support = ctx.mkTrue(); - for(int p = 0; p < indexes.size(); p++) { - for(int a = 0; a < indexes.get(p).size(); a++) { - if(supp.get(indexes.get(p).get(a))) { - support = ctx.mkAnd(support, ctx.mkGt(strategies.get(p).get(a), zero)); + for(int c = 0; c < indexes.size(); c++) { + for(int a = 0; a < indexes.get(c).size(); a++) { + if(supp.get(indexes.get(c).get(a))) { + support = ctx.mkAnd(support, ctx.mkGt(strategies.get(c).get(a), zero)); } else { - support = ctx.mkAnd(support, ctx.mkEq(strategies.get(p).get(a), zero)); + support = ctx.mkAnd(support, ctx.mkEq(strategies.get(c).get(a), zero)); } } } s.add(support); } - - public Pair> computeEquilibria(BitSet supp, HashMap map, int st) { + + public EquilibriumResult computeEquilibria(BitSet supp, HashMap map) { + Model model; + EquilibriumResult result = new EquilibriumResult(); + ArithExpr cnstr1; + Distribution d; + ArrayList eq = new ArrayList<>(); + double v; + int a, c; + s.push(); computeConstraints(supp); computeSupport(supp, map); + // Sum variables in the supports to one (for each player) + for(c = 0; c < numCoalitions; c++) { + cnstr1 = zero; + for(a = 0; a < indexes.get(c).size(); a++) { + cnstr1 = ctx.mkAdd(cnstr1, strategies.get(c).get(a)); + } + s.add(ctx.mkEq(cnstr1, one)); + } /* System.out.println("-- to prove"); for(int i = 0; i < s.getNumAssertions(); i++) { System.out.println(s.getAssertions()[i]); } */ - Model model; - ArrayList eq = new ArrayList<>(); - Distribution d; - double v; - - Status result = s.check(); - if(result == Status.SATISFIABLE) { + //System.out.println("\n%% " + supp); + Status status = s.check(); + strat.clear(); + if(status == Status.SATISFIABLE) { model = s.getModel(); - strat.clear(); - for(int p = 0; p < numPlayers; p++) { + for(c = 0; c < numCoalitions; c++) { d = new Distribution(); - eq.add(p, getDoubleValue(model, payoffs.get(p))); - for (int a = 0; a < strategies.get(p).size(); a++) { - v = getDoubleValue(model, strategies.get(p).get(a)); + eq.add(c, getDoubleValue(model, payoffs.get(c))); + //System.out.println("p" + p + ": " + getDoubleValue(model, payoffs.get(p))); + for (a = 0; a < strategies.get(c).size(); a++) { + v = getDoubleValue(model, strategies.get(c).get(a)); + //System.out.println("p" + p + " -> " + a + " " + getDoubleValue(model, strategies.get(p).get(a))); if (v > 0) d.add(a, v); } @@ -148,11 +176,32 @@ public Pair> computeEquilibria(BitSet supp, H } } s.pop(); - return new Pair>((result == Status.SATISFIABLE)? CSGResultStatus.SAT : - (result == Status.UNKNOWN)? CSGResultStatus.UNKNOWN : - CSGResultStatus.UNSAT, new ArrayList(eq)); + result.setStatus((status == Status.SATISFIABLE)? CSGResultStatus.SAT : (status == Status.UNKNOWN)? CSGResultStatus.UNKNOWN : CSGResultStatus.UNSAT); + result.setPayoffVector(new ArrayList(eq)); + result.setStrategy(new ArrayList(strat)); + return result; } - + + public void translateAssertions(HashMap>>> assertionsIdx, HashMap map) { + assertions.clear(); + ArithExpr sum, prod; + int a, c; + for(c = 0; c < assertionsIdx.keySet().size(); c++) { + assertions.put(c, new HashMap()); + for(a = 0; a < assertionsIdx.get(c).keySet().size(); a++) { + sum = zero; + for(Pair product : assertionsIdx.get(c).get(a)) { + prod = getRealValue(product.second); + for(int id = product.first.nextSetBit(0); id >= 0; id = product.first.nextSetBit(id + 1)) { + prod = ctx.mkMul(prod, strategies.get(map.get(id)[0]).get(map.get(id)[1])); + } + sum = ctx.mkAdd(sum, prod); + } + assertions.get(c).put(a, sum); + } + } + } + public double getDoubleValue(Model model, Expr expr) { RatNum v1; AlgebraicNum v2; @@ -168,55 +217,53 @@ else if (model.getConstInterp(expr) instanceof AlgebraicNum) { else return Double.NaN; } - - public void translateAssertions(HashMap>>> assertionsIdx, HashMap map) { - assertions.clear(); - ArithExpr sum, prod; - int a, p; - for(p = 0; p < assertionsIdx.keySet().size(); p++) { - assertions.put(p, new HashMap()); - for(a = 0; a < assertionsIdx.get(p).keySet().size(); a++) { - sum = zero; - for(Pair product : assertionsIdx.get(p).get(a)) { - prod = getRealValue(product.second); - for(int id = product.first.nextSetBit(0); id >= 0; id = product.first.nextSetBit(id + 1)) { - prod = ctx.mkMul(prod, strategies.get(map.get(id)[0]).get(map.get(id)[1])); - } - sum = ctx.mkAdd(sum, prod); - } - assertions.get(p).put(a, sum); - } - } - } public ArithExpr getRealValue(double v) { - ArithExpr result; - result = ctx.mkReal((long) (Math.pow(10, ndigits) * v)); - result = ctx.mkDiv(result, ctx.mkReal((long) (Math.pow(10, ndigits)))); + ArithExpr result = null; + try { + result = ctx.mkReal(String.valueOf(v)); + } + catch (Exception e) { + System.out.println("Error converting value " + v + " to a real."); + System.out.println("assertions: " + assertions); + e.printStackTrace(); + } return result; } + + public ArrayList getStrat() { + return new ArrayList(this.strat); + } public void setNumPlayers(int n) { - this.numPlayers = n; + this.numCoalitions = n; } - + public void setIndexes(ArrayList> a) { this.indexes = a; } - public ArrayList getStrat() { - return new ArrayList(this.strat); - } - @Override public void setGradient(HashMap>>> gradient) { // TODO Auto-generated method stub - + } @Override public void setAssertions(HashMap>>> assertions) { // TODO Auto-generated method stub + + } + + @Override + public void setMap(HashMap map) { + // TODO Auto-generated method stub + + } + + @Override + public void init() { + // TODO Auto-generated method stub } diff --git a/prism/src/explicit/EquilibriumResult.java b/prism/src/explicit/EquilibriumResult.java new file mode 100644 index 000000000..6d81d5915 --- /dev/null +++ b/prism/src/explicit/EquilibriumResult.java @@ -0,0 +1,63 @@ +//============================================================================== +// +// Copyright (c) 2002- +// Authors: +// * Dave Parker (University of Oxford) +// * Gabriel Santos (University of Oxford) +// +//------------------------------------------------------------------------------ +// +// This file is part of PRISM. +// +// PRISM 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. +// +// PRISM 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 PRISM; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +//============================================================================== + +package explicit; + +import java.util.ArrayList; +import explicit.CSGModelCheckerEquilibria.CSGResultStatus; + +public class EquilibriumResult { + + private CSGResultStatus status; + private ArrayList payoffVector; + private ArrayList strategy; + + public CSGResultStatus getStatus() { + return status; + } + + public void setStatus(CSGResultStatus status) { + this.status = status; + } + + public ArrayList getPayoffVector() { + return payoffVector; + } + + public void setPayoffVector(ArrayList payoffVector) { + this.payoffVector = payoffVector; + } + + public ArrayList getStrategy() { + return strategy; + } + + public void setStrategy(ArrayList strategy) { + this.strategy = strategy; + } + +} \ No newline at end of file diff --git a/prism/src/explicit/ModelCheckerResultMulti.java b/prism/src/explicit/ModelCheckerResultMulti.java new file mode 100644 index 000000000..96a3d11aa --- /dev/null +++ b/prism/src/explicit/ModelCheckerResultMulti.java @@ -0,0 +1,19 @@ +package explicit; + +import java.util.BitSet; +import java.util.Map; + +public class ModelCheckerResultMulti extends ModelCheckerResult +{ + // Constructor + public ModelCheckerResultMulti() + { + super(); + } + + public Map subGames = null; + public double[][] solnMulti = null; + public BitSet D = null; + public BitSet E = null; + +} diff --git a/prism/src/explicit/ProbModelChecker.java b/prism/src/explicit/ProbModelChecker.java index 137bcdf07..c8b77f715 100644 --- a/prism/src/explicit/ProbModelChecker.java +++ b/prism/src/explicit/ProbModelChecker.java @@ -625,13 +625,16 @@ protected StateValues checkExpressionMultiNash(Model model, ExpressionMultiNash int[] bounds = new int[coalitions.size()]; Expression expr1; IntegerBound bound; - Arrays.fill(remain, null); - Arrays.fill(targets, null); - Arrays.fill(bounds, -1); int e, p, r; boolean type = true; boolean rew = false; boolean min = expr.getRelOp().isMin(); + int eqType = expr.getEqType(); + int crit = expr.getCrit(); + + Arrays.fill(remain, null); + Arrays.fill(targets, null); + Arrays.fill(bounds, -1); /* System.out.println("-- RelOp"); @@ -713,10 +716,8 @@ else if (expr1 instanceof ExpressionMultiNashReward) { case ExpressionTemporal.R_I: bounded.set(p); bounds[p] = exprTemp.getUpperBound().evaluateInt(constantValues); - //cumul = false; break; case ExpressionTemporal.R_C: - //insta = false; if (exprTemp.hasBounds()) { bounded.set(p); bound = IntegerBound.fromExpressionTemporal((ExpressionTemporal) expr1, constantValues, true); @@ -741,34 +742,49 @@ else if (expr1 instanceof ExpressionMultiNashReward) { else if (coalitions.size() == 2) { if (unbounded.cardinality() == formulae.size()) { if (rew) { - res = ((CSGModelChecker) this).computeRewReachEquilibria((CSG) model, coalitions, rewards, targets, min); + res = ((CSGModelChecker) this).computeRewReachEquilibria((CSG) model, coalitions, rewards, targets, eqType, crit, min); } else { - res = ((CSGModelChecker) this).computeProbReachEquilibria((CSG) model, coalitions, targets, remain, min); + res = ((CSGModelChecker) this).computeProbReachEquilibria((CSG) model, coalitions, targets, remain, eqType, crit, min); } } else if (bounded.cardinality() == formulae.size()) { if (rew) { - res = ((CSGModelChecker) this).computeRewBoundedEquilibria((CSG) model, coalitions, rewards, exprs, bounds, min); + res = ((CSGModelChecker) this).computeRewBoundedEquilibria((CSG) model, coalitions, rewards, exprs, bounds, eqType, crit, min); } else { - res = ((CSGModelChecker) this).computeProbBoundedEquilibria((CSG) model, coalitions, exprs, targets, remain, bounds, min); + res = ((CSGModelChecker) this).computeProbBoundedEquilibria((CSG) model, coalitions, exprs, targets, remain, bounds, eqType, crit, min); } } else { - res = ((CSGModelChecker) this).computeMixedEquilibria((CSG) model, coalitions, rewards, exprs, bounded, targets, remain, bounds, min); + res = ((CSGModelChecker) this).computeMixedEquilibria((CSG) model, coalitions, rewards, exprs, bounded, targets, remain, bounds, eqType, crit, min); } } else if (coalitions.size() > 2) { - throw new PrismNotSupportedException("Equilibria-based properties with more than two coalitions are not yet supported"); - /* - if (rew) { - res = ((CSGModelChecker) this).computeMultiRewReachEquilibria((CSG) model, coalitions, rewards, targets, min); + if (unbounded.cardinality() == formulae.size()) { + if (rew) { + res = ((CSGModelChecker) this).computeMultiRewReachEquilibria((CSG) model, coalitions, rewards, targets, eqType, crit, min); + } + else { + res = ((CSGModelChecker) this).computeMultiProbReachEquilibria((CSG) model, coalitions, targets, remain, eqType, crit, min); + } + } + else if (bounded.cardinality() == formulae.size()) { + int first_bound = bounds[0]; + for (int i = 1; i < bounds.length; i++) { + if (first_bound != bounds[i]) + throw new PrismNotSupportedException("Multi-coalitional properties with different bounds are not yet supported"); + } + if (rew) { + res = ((CSGModelChecker) this).computeMultiRewBoundedEquilibria((CSG) model, coalitions, rewards, exprs, bounds, eqType, crit, min); + } + else { + res = ((CSGModelChecker) this).computeMultiProbBoundedEquilibria((CSG) model, coalitions, targets, remain, bounds, eqType, crit, min); + } } else { - res = ((CSGModelChecker) this).computeMultiProbReachEquilibria((CSG) model, coalitions, targets, remain, min); + throw new PrismNotSupportedException("Multi-coalitional mixed properties are not yet supported"); } - */ } result.setStrategy(res.strat); @@ -1402,7 +1418,7 @@ protected StateValues checkRewardTotal(Model model, Rewards modelRewards, Expres res = ((MDPModelChecker) this).computeTotalRewards((MDP) model, (MDPRewards) modelRewards, minMax.isMin()); break; case CSG: - res = ((CSGModelChecker) this).computeTotalRewards((CSG) model, (CSGRewards) modelRewards, minMax.isMin1(), minMax.isMin2(), minMax.getCoalition()); + res = ((CSGModelChecker) this).computeTotalRewards((CSG) model, (CSGRewards) modelRewards, minMax.getCoalition(), minMax.isMin1(), minMax.isMin2()); break; default: throw new PrismNotSupportedException("Explicit engine does not yet handle the " + expr.getOperatorSymbol() + " reward operator for " + model.getModelType() diff --git a/prism/src/parser/ParseException.java b/prism/src/parser/ParseException.java index 839bcc293..0f7f16284 100644 --- a/prism/src/parser/ParseException.java +++ b/prism/src/parser/ParseException.java @@ -1,5 +1,5 @@ -/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 7.0 */ -/* JavaCCOptions:KEEP_LINE_COLUMN=true */ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 6.0 */ +/* JavaCCOptions:KEEP_LINE_COL=null */ package parser; /** @@ -20,11 +20,6 @@ public class ParseException extends Exception { */ private static final long serialVersionUID = 1L; - /** - * The end of line string for this machine. - */ - protected static String EOL = System.getProperty("line.separator", "\n"); - /** * This constructor is used by the method "generateParseException" * in the generated parser. Calling this constructor generates @@ -65,7 +60,7 @@ public ParseException(String message) { /** * This is the last token that has been consumed successfully. If * this object has been created due to a parse error, the token - * following this token will (therefore) be the first error token. + * followng this token will (therefore) be the first error token. */ public Token currentToken; @@ -93,8 +88,8 @@ public ParseException(String message) { private static String initialise(Token currentToken, int[][] expectedTokenSequences, String[] tokenImage) { - - StringBuilder expected = new StringBuilder(); + String eol = System.getProperty("line.separator", "\n"); + StringBuffer expected = new StringBuffer(); int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { @@ -106,7 +101,7 @@ private static String initialise(Token currentToken, if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { expected.append("..."); } - expected.append(EOL).append(" "); + expected.append(eol).append(" "); } String retval = "Encountered \""; Token tok = currentToken.next; @@ -122,26 +117,21 @@ private static String initialise(Token currentToken, retval += " \""; tok = tok.next; } - if (currentToken.next != null) { - retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; - } - retval += "." + EOL; - - - if (expectedTokenSequences.length == 0) { - // Nothing to add here + retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; + retval += "." + eol; + if (expectedTokenSequences.length == 1) { + retval += "Was expecting:" + eol + " "; } else { - if (expectedTokenSequences.length == 1) { - retval += "Was expecting:" + EOL + " "; - } else { - retval += "Was expecting one of:" + EOL + " "; - } - retval += expected.toString(); + retval += "Was expecting one of:" + eol + " "; } - + retval += expected.toString(); return retval; } + /** + * The end of line string for this machine. + */ + protected String eol = System.getProperty("line.separator", "\n"); /** * Used to convert raw characters to their escaped version @@ -149,11 +139,13 @@ private static String initialise(Token currentToken, * string literal. */ static String add_escapes(String str) { - StringBuilder retval = new StringBuilder(); + StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { + case 0 : + continue; case '\b': retval.append("\\b"); continue; @@ -192,4 +184,4 @@ static String add_escapes(String str) { } } -/* JavaCC - OriginalChecksum=8dbcceed9d408427f9932dcf43e59aaa (do not edit this line) */ +/* JavaCC - OriginalChecksum=83512206aea6c09dd76f640dc4cc775b (do not edit this line) */ diff --git a/prism/src/parser/PrismParser.java b/prism/src/parser/PrismParser.java index e8b6885fa..739a47f58 100644 --- a/prism/src/parser/PrismParser.java +++ b/prism/src/parser/PrismParser.java @@ -27,7 +27,7 @@ public class PrismParser implements PrismParserConstants { static { keywordList.clear(); for (int i = PrismParserConstants.COMMENT+1; i < PrismParserConstants.NOT; i++) { - keywordList.add(PrismParserConstants.tokenImage[i].replaceAll("\"", "")); + keywordList.add(PrismParserConstants.tokenImage[i].replaceAll("\u005c"", "")); } } @@ -54,26 +54,26 @@ public static void main(String[] args) p = new PrismParser(); str = (args.length > 1) ? new FileInputStream(args[1]) : System.in; src = (args.length > 1) ? "file "+args[1] : "stdin"; - System.out.println("Reading from "+src+"...\n"); + System.out.println("Reading from "+src+"...\u005cn"); if (args[0].equals("-modulesfile") || args[0].equals("-mf")) { ModulesFile mf = p.parseModulesFile(str); - System.out.print("Modules file:\n=============\n\n" + mf); - System.out.print("\nTree:\n=====\n" + mf.toTreeString()); + System.out.print("Modules file:\u005cn=============\u005cn\u005cn" + mf); + System.out.print("\u005cnTree:\u005cn=====\u005cn" + mf.toTreeString()); mf.tidyUp(); - System.out.print("\nAnd after expansion:\n====================\n\n" +mf); + System.out.print("\u005cnAnd after expansion:\u005cn====================\u005cn\u005cn" +mf); } else if (args[0].equals("-propertiesfile") || args[0].equals("-pf")) { PropertiesFile pf = p.parsePropertiesFile(new ModulesFile(), str); - System.out.print("Properties file:\n================\n\n" + pf); - System.out.print("\nTree:\n=====\n" + pf.toTreeString()); + System.out.print("Properties file:\u005cn================\u005cn\u005cn" + pf); + System.out.print("\u005cnTree:\u005cn=====\u005cn" + pf.toTreeString()); pf.tidyUp(); - System.out.print("\nAnd after expansion:\n====================\n\n" + pf); + System.out.print("\u005cnAnd after expansion:\u005cn====================\u005cn\u005cn" + pf); } else if (args[0].equals("-expression") || args[0].equals("-e")) { Expression expr = p.parseSingleExpression(str); System.out.println("Expression: " + expr.toString()); - System.out.print("Tree:\n=====\n" + expr.toTreeString()); + System.out.print("Tree:\u005cn=====\u005cn" + expr.toTreeString()); expr.typeCheck(); expr.semanticCheck(); System.out.println("Type: " + expr.getType().getTypeString()); @@ -88,7 +88,7 @@ public Object visit(ExpressionIdent e) throws PrismLangException } }); System.out.println("LTL formula: " + expr.toString()); - System.out.print("Tree:\n=====\n" + expr.toTreeString()); + System.out.print("Tree:\u005cn=====\u005cn" + expr.toTreeString()); expr.typeCheck(); //expr.semanticCheck(); System.out.println("Type: " + expr.getType().getTypeString()); @@ -250,29 +250,29 @@ public static String getPrecedingCommentBlock(Token firstToken) Token t = firstToken; // extract any comment from the previous lines of the file - if (t.specialToken != null && !(t.specialToken.kind == PrismParserConstants.WHITESPACE && t.specialToken.image.matches("[\\n\\r]*"))) { + if (t.specialToken != null && !(t.specialToken.kind == PrismParserConstants.WHITESPACE && t.specialToken.image.matches("[\u005c\u005cn\u005c\u005cr]*"))) { // trace back thru special tokens that are comments t = t.specialToken; - while (t.specialToken != null && !(t.specialToken.kind == PrismParserConstants.WHITESPACE && t.specialToken.image.matches("[\\n\\r]*"))) + while (t.specialToken != null && !(t.specialToken.kind == PrismParserConstants.WHITESPACE && t.specialToken.image.matches("[\u005c\u005cn\u005c\u005cr]*"))) t = t.specialToken; // concatenate comment special tokens while (t != null) { s = t.image; // strip any nasty carriage returns - s = s.replaceAll("\r", ""); + s = s.replaceAll("\u005cr", ""); // remove "//" and preceding/subsequent spaces/tabs from comments if (t.kind == PrismParserConstants.COMMENT) { - while (comment.length() > 0 && (""+comment.charAt(comment.length()-1)).matches("[ \t]")) + while (comment.length() > 0 && (""+comment.charAt(comment.length()-1)).matches("[ \u005ct]")) comment = comment.substring(0,comment.length()-1); s = s.substring(2); - s = s.replaceFirst("[ \t]*", ""); + s = s.replaceFirst("[ \u005ct]*", ""); } comment += s; t = t.next; } } // remove final new line (if present) - if (comment.length() > 0 && (comment.charAt(comment.length()-1) == '\n')) + if (comment.length() > 0 && (comment.charAt(comment.length()-1) == '\u005cn')) comment = comment.substring(0,comment.length()-1); return comment; @@ -285,15 +285,15 @@ public static String slashCommentBlock(String comment) int i; String s, res = ""; // break into lines - while ((i = comment.indexOf("\n")) != -1) { + while ((i = comment.indexOf("\u005cn")) != -1) { s = comment.substring(0, i); comment = comment.substring(i+1); // add "//" to non-empty lines if (s.trim().length()>0) res += "// " + s; - res += "\n"; + res += "\u005cn"; } // deal with any trailing characters (with no new line ending them) - if (comment.trim().length()>0) res += "// " + comment + "\n"; + if (comment.trim().length()>0) res += "// " + comment + "\u005cn"; return res; } @@ -538,7 +538,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression mf.setPosition(begin != null? begin: getToken(0), getToken(0)); {if ("" != null) return mf;} throw new Error("Missing return statement in function"); -} + } // Properties file static final public @@ -663,7 +663,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(0); pf.setPosition(begin, getToken(0)); {if ("" != null) return pf;} throw new Error("Missing return statement in function"); -} + } // Properties file with optional semicolons - beware of potential ambiguities static final public @@ -788,7 +788,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(0); pf.setPosition(begin, getToken(0)); {if ("" != null) return pf;} throw new Error("Missing return statement in function"); -} + } // Property - expression, with optional name/comment static final public @@ -809,7 +809,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression prop = new Property(expr, name, getPrecedingCommentBlock(begin)); prop.setPosition(begin, getToken(0)); {if ("" != null) return prop;} throw new Error("Missing return statement in function"); -} + } // A single expression static final public @@ -818,7 +818,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(0); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // A single LTL formula static final public @@ -827,7 +827,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(0); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } //----------------------------------------------------------------------------------- // Modules file stuff (a few bits of which are reused for property files) @@ -941,7 +941,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return modelType;} throw new Error("Missing return statement in function"); -} + } // Formula definition static final public @@ -953,7 +953,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression expr = Expression(false, false); jj_consume_token(SEMICOLON); formulaList.addFormula(name, expr); -} + } // Label definition static final public @@ -976,7 +976,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(-1); throw new ParseException(); } -} + } // Constant definition static final public @@ -1057,7 +1057,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } jj_consume_token(SEMICOLON); constantList.addConstant(name, expr, type); -} + } // Global variable declaration static final public @@ -1066,7 +1066,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression decl = Declaration(); {if ("" != null) return decl;} throw new Error("Missing return statement in function"); -} + } // Variable declaration static final public @@ -1094,7 +1094,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(SEMICOLON); decl.setPosition(begin, getToken(0)); {if ("" != null) return decl;} throw new Error("Missing return statement in function"); -} + } // Type part of a declaration static final public @@ -1134,7 +1134,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } declType.setPosition(begin, getToken(0)); {if ("" != null) return declType;} throw new Error("Missing return statement in function"); -} + } // Module static final public @@ -1190,7 +1190,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(ENDMODULE); module.setPosition(begin, getToken(0)); module.setNameASTElement(name); {if ("" != null) return module;} throw new Error("Missing return statement in function"); -} + } // Command static final public @@ -1213,7 +1213,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(SEMICOLON); comm.setPosition(begin, getToken(0)); {if ("" != null) return comm;} throw new Error("Missing return statement in function"); -} + } // Updates static final public @@ -1294,7 +1294,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } updates.setPosition(begin, getToken(0)); {if ("" != null) return updates;} throw new Error("Missing return statement in function"); -} + } static final public Update Update() throws ParseException {Update update = new Update(); Token begin = null; @@ -1329,7 +1329,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } update.setPosition(begin, getToken(0)); {if ("" != null) return update;} throw new Error("Missing return statement in function"); -} + } static final public void UpdateElement(Update update) throws ParseException {ExpressionIdent var = null; Expression expr = null; @@ -1340,7 +1340,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression expr = Expression(false, false); jj_consume_token(RPARENTH); UpdateElement ue = new UpdateElement(var, expr); ue.setPosition(begin, getToken(0)); update.addElement(ue); -} + } // Module renaming static final public @@ -1372,7 +1372,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(ENDMODULE); rm.setPosition(begin, getToken(0)); rm.setNameASTElement(name); rm.setBaseModuleASTElement(base); {if ("" != null) return rm;} throw new Error("Missing return statement in function"); -} + } static final public void Rename(RenamedModule rm) throws ParseException {ExpressionIdent id1 = null, id2 = null; // NB: have to explicitly include keywords for functions because they can be renamed @@ -1380,7 +1380,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(EQ); id2 = IdentifierExpressionMinMax(); rm.addRename(id1.getName(), id2.getName(), id1, id2); -} + } // Reward structure static final public @@ -1467,7 +1467,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(ENDREWARDS); rs.setPosition(begin, getToken(0)); {if ("" != null) return rs;} throw new Error("Missing return statement in function"); -} + } // Action list (0 or more comma-separated identifiers) static final public @@ -1500,7 +1500,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return list;} throw new Error("Missing return statement in function"); -} + } // Initial states ("init...endinit" construct) static final public @@ -1510,7 +1510,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(ENDINIT); {if ("" != null) return expr;} throw new Error("Missing return statement in function"); -} + } // Observable variables list (for partially observable models) static final public @@ -1540,7 +1540,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(ENDOBSERVABLES); obsVars.setPosition(begin, getToken(0)); {if ("" != null) return obsVars;} throw new Error("Missing return statement in function"); -} + } // Individual observable (for partially observable models) static final public @@ -1557,7 +1557,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(SEMICOLON); Observable obs = new Observable(name, defn); obs.setPosition(begin, getToken(0)); {if ("" != null) return obs;} throw new Error("Missing return statement in function"); -} + } // System definition ("system...endsystem" construct) static final public @@ -1574,7 +1574,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression sysdef = SystemDefn(); jj_consume_token(ENDSYSTEM); mf.addSystemDefn(sysdef, name); -} + } // System definition component static final public @@ -1582,7 +1582,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression ret = SystemFullParallel(); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // System definition component (full parallel) static final public @@ -1612,7 +1612,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression {if ("" != null) return par;} } throw new Error("Missing return statement in function"); -} + } // System definition component (interleaved parallel) static final public @@ -1643,7 +1643,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression {if ("" != null) return par;} } throw new Error("Missing return statement in function"); -} + } // System definition component (parallel over set of actions) static final public @@ -1689,7 +1689,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression {if ("" != null) return par;} } throw new Error("Missing return statement in function"); -} + } // System definition component (hiding and renaming) static final public @@ -1774,7 +1774,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } sys.setPosition(begin, getToken(0)); {if ("" != null) return sys;} throw new Error("Missing return statement in function"); -} + } // System definition component (bottom level) static final public @@ -1809,7 +1809,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } sys.setPosition(begin, getToken(0)); {if ("" != null) return sys;} throw new Error("Missing return statement in function"); -} + } // Player definition static final public @@ -1847,7 +1847,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(ENDPLAYER); player.setPosition(begin, getToken(0)); {if ("" != null) return player;} throw new Error("Missing return statement in function"); -} + } // Player definition item (module or [action]) static final public @@ -1870,7 +1870,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(-1); throw new ParseException(); } -} + } //----------------------------------------------------------------------------------- // Expressions. @@ -1886,7 +1886,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression ret = ExpressionTemporalBinary(prop, pathprop); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: temporal operators, binary (U, W, R) and unary (X, F, G) @@ -1963,7 +1963,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } static final public Expression ExpressionTemporalUnary(boolean prop, boolean pathprop) throws ParseException {Expression ret, expr; ExpressionTemporal exprTemp; @@ -2056,7 +2056,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Time bound for temporal operators // (see ExpressionTemporal production for lookahead explanation) @@ -2299,7 +2299,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(-1); throw new ParseException(); } -} + } // Expression: if-then-else, i.e. "cond ? then : else" static final public @@ -2322,7 +2322,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: implies static final public @@ -2347,7 +2347,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: if-and-only-iff static final public @@ -2372,7 +2372,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: or static final public @@ -2397,7 +2397,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: and static final public @@ -2422,7 +2422,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: not static final public @@ -2477,7 +2477,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: equality operators: =, != static final public @@ -2504,7 +2504,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: relational operators: >, <, >=, <= static final public @@ -2533,7 +2533,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: plus/minus @@ -2582,7 +2582,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: times/divide static final public @@ -2624,7 +2624,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: unary minus static final public @@ -2678,7 +2678,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Basic expression (top of operator precedence ordering) static final public @@ -2762,7 +2762,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: function or identifier @@ -2807,7 +2807,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } ret.setPosition(begin, getToken(0)); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: min/max function (treated differently because min/max are keywords) static final public @@ -2836,7 +2836,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(RPARENTH); func.setPosition(begin, getToken(0)); {if ("" != null) return func;} throw new Error("Missing return statement in function"); -} + } // Expression: old-style function, i.e. "func(name, ...)" static final public @@ -2871,7 +2871,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(RPARENTH); func.setPosition(begin, getToken(0)); {if ("" != null) return func;} throw new Error("Missing return statement in function"); -} + } // Arguments for a function in an expression static final public @@ -2893,7 +2893,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression expr = Expression(prop, pathprop); func.addOperand(expr); } -} + } // Expression: literal static final public @@ -2944,7 +2944,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } ret.setPosition(getToken(0)); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Expression: parentheses static final public @@ -2955,7 +2955,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression jj_consume_token(RPARENTH); ret = new ExpressionUnaryOp(ExpressionUnaryOp.PARENTH, expr); ret.setPosition(begin, getToken(0)); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } //----------------------------------------------------------------------------------- // Property stuff @@ -3173,7 +3173,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } else {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Filter for a P/S/R operator static final public @@ -3216,7 +3216,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } filter.setPosition(begin, getToken(0)); {if ("" != null) return filter;} throw new Error("Missing return statement in function"); -} + } // (Property) expression: steady-state operator S static final public @@ -3293,7 +3293,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } else {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // (Property) expression: expected reward operator R static final public @@ -3516,7 +3516,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } else {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Reward struct index for R operator static final public @@ -3663,7 +3663,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression if (discount != null) { exprRew.setDiscount(discount); } -} + } // Contents of an R operator @@ -3769,7 +3769,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } ret.setPosition(begin, getToken(0)); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // (Property) expression: n-player Nash operator static final public @@ -3780,8 +3780,23 @@ static class ExpressionPair { public Expression expr1 = null; public Expression String relOp = null; boolean isBool; int r; + int eq = 1; // default NE + int crit = 3; // default SW int n = 0; if (!prop) {if (true) throw generateParseException();} + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LBRACE:{ + jj_consume_token(LBRACE); + eq = EqType(); + jj_consume_token(COMMA); + crit = EqType(); + jj_consume_token(RBRACE); + break; + } + default: + jj_la1[97] = jj_gen; + ; + } switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case MIN:{ jj_consume_token(MIN); @@ -3802,7 +3817,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[97] = jj_gen; + jj_la1[98] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -3827,14 +3842,14 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[98] = jj_gen; + jj_la1[99] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; } default: - jj_la1[99] = jj_gen; + jj_la1[100] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -3849,7 +3864,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[100] = jj_gen; + jj_la1[101] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -3867,7 +3882,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[101] = jj_gen; + jj_la1[102] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -3878,16 +3893,50 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[102] = jj_gen; + jj_la1[103] = jj_gen; break label_31; } } jj_consume_token(RPARENTH); ret.setBound(bound); ret.setRelOp(relOp); + ret.setEqType(eq); + ret.setCrit(crit); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } + +// Types of Equilibria + static final public +int EqType() throws ParseException { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case NASH:{ + jj_consume_token(NASH); +{if ("" != null) return ExpressionMultiNash.NASH;} + break; + } + case CORR:{ + jj_consume_token(CORR); +{if ("" != null) return ExpressionMultiNash.CORR;} + break; + } + case SWEQ:{ + jj_consume_token(SWEQ); +{if ("" != null) return ExpressionMultiNash.SWEQ;} + break; + } + case FAIR:{ + jj_consume_token(FAIR); +{if ("" != null) return ExpressionMultiNash.FAIR;} + break; + } + default: + jj_la1[104] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } // (Property) expression: probabilistic operator (n-player Nash) static final public @@ -3903,7 +3952,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression ret.setPosition(begin, getToken(0)); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // (Property) expression: reward operator (n-player Nash) static final public @@ -3920,7 +3969,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression ret.setPosition(begin, getToken(0)); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // (Reward) structure index for equilibria static final public @@ -3972,14 +4021,14 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[103] = jj_gen; + jj_la1[105] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } jj_consume_token(RBRACE); exprMultiNash.setRewardStructIndex(index); -} + } // (Property) expression: CTL existential operator E static final public @@ -3995,7 +4044,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression ret.setPosition(begin, getToken(0)); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // (Property) expression: CTL universal operator A static final public @@ -4011,7 +4060,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression ret.setPosition(begin, getToken(0)); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // (Property) expression: ATL strategy operators <<>> and [[]] static final public @@ -4036,7 +4085,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[104] = jj_gen; + jj_la1[106] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -4057,7 +4106,8 @@ static class ExpressionPair { public Expression expr1 = null; public Expression case RMINMAX: case RMINMIN: case RMIN: - case R:{ + case R: + case LBRACE:{ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case PMAXMAX: case PMAXMIN: @@ -4080,12 +4130,13 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } case MAX: - case MIN:{ + case MIN: + case LBRACE:{ expr = ExpressionMultiNash(prop,pathprop); break; } default: - jj_la1[105] = jj_gen; + jj_la1[107] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -4098,14 +4149,14 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[106] = jj_gen; + jj_la1[108] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ret.setPosition(begin, getToken(0)); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // List of coalitions (player lists) for a strategy (<<>> or [[]]) operator static final public @@ -4121,7 +4172,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[107] = jj_gen; + jj_la1[109] = jj_gen; break label_32; } jj_consume_token(COLON); @@ -4130,7 +4181,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression } {if ("" != null) return coalitions;} throw new Error("Missing return statement in function"); -} + } // Coalition (player list) for a strategy (<<>> or [[]]) operator static final public @@ -4144,7 +4195,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[110] = jj_gen; + jj_la1[112] = jj_gen; switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case REG_INT: case REG_IDENT:{ @@ -4158,7 +4209,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[108] = jj_gen; + jj_la1[110] = jj_gen; break label_33; } jj_consume_token(COMMA); @@ -4169,13 +4220,13 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[109] = jj_gen; + jj_la1[111] = jj_gen; ; } } {if ("" != null) return coalition;} throw new Error("Missing return statement in function"); -} + } // Single player in a coalition for a strategy (<<>> or [[]]) operator static final public @@ -4190,14 +4241,14 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[111] = jj_gen; + jj_la1[113] = jj_gen; jj_consume_token(-1); throw new ParseException(); } s = getToken(0).image; {if ("" != null) return s;} throw new Error("Missing return statement in function"); -} + } // (Property) expression: label (including "init") static final public @@ -4217,14 +4268,14 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[112] = jj_gen; + jj_la1[114] = jj_gen; jj_consume_token(-1); throw new ParseException(); } jj_consume_token(DQUOTE); ret = new ExpressionLabel(s); ret.setPosition(begin, getToken(0)); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // (Property) expression: filter (using "filter" keyword) static final public @@ -4268,7 +4319,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[113] = jj_gen; + jj_la1[115] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -4281,13 +4332,13 @@ static class ExpressionPair { public Expression expr1 = null; public Expression break; } default: - jj_la1[114] = jj_gen; + jj_la1[116] = jj_gen; ; } jj_consume_token(RPARENTH); expr = new ExpressionFilter(op, expr2, filter); expr.setPosition(begin, getToken(0)); {if ("" != null) return expr;} throw new Error("Missing return statement in function"); -} + } //----------------------------------------------------------------------------------- // Miscellaneous stuff @@ -4299,7 +4350,7 @@ String Identifier() throws ParseException { jj_consume_token(REG_IDENT); {if ("" != null) return getToken(0).image;} throw new Error("Missing return statement in function"); -} + } // Identifier (returns ExpressionIdent, storing position info) static final public @@ -4308,7 +4359,7 @@ String Identifier() throws ParseException { ident = Identifier(); ret = new ExpressionIdent(ident); ret.setPosition(getToken(0)); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Identifier or min/max keyword (returns ExpressionIdent, storing position info) static final public @@ -4330,13 +4381,13 @@ String Identifier() throws ParseException { break; } default: - jj_la1[115] = jj_gen; + jj_la1[117] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ret = new ExpressionIdent(ident); ret.setPosition(getToken(0)); {if ("" != null) return ret;} throw new Error("Missing return statement in function"); -} + } // Primed identifier static final public @@ -4351,7 +4402,7 @@ ExpressionIdent IdentifierPrime() throws ParseException { expr.setPrime(true); {if ("" != null) return expr;} throw new Error("Missing return statement in function"); -} + } // Equality operators: =, != static final public @@ -4368,12 +4419,12 @@ int EqNeq() throws ParseException { break; } default: - jj_la1[116] = jj_gen; + jj_la1[118] = jj_gen; jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); -} + } // Relational operators: >, <, >=, <= static final public @@ -4400,12 +4451,12 @@ int LtGt() throws ParseException { break; } default: - jj_la1[117] = jj_gen; + jj_la1[119] = jj_gen; jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); -} + } // For loop static final public @@ -4426,7 +4477,7 @@ int LtGt() throws ParseException { break; } default: - jj_la1[118] = jj_gen; + jj_la1[120] = jj_gen; ; } jj_consume_token(0); @@ -4437,12 +4488,12 @@ int LtGt() throws ParseException { fl.setPosition(begin, getToken(0)); {if ("" != null) return fl;} throw new Error("Missing return statement in function"); -} + } static private boolean jj_2_1(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_1()); } + try { return !jj_3_1(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(0, xla); } } @@ -4450,7 +4501,7 @@ static private boolean jj_2_1(int xla) static private boolean jj_2_2(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_2()); } + try { return !jj_3_2(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(1, xla); } } @@ -4458,7 +4509,7 @@ static private boolean jj_2_2(int xla) static private boolean jj_2_3(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_3()); } + try { return !jj_3_3(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(2, xla); } } @@ -4466,7 +4517,7 @@ static private boolean jj_2_3(int xla) static private boolean jj_2_4(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_4()); } + try { return !jj_3_4(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(3, xla); } } @@ -4474,7 +4525,7 @@ static private boolean jj_2_4(int xla) static private boolean jj_2_5(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_5()); } + try { return !jj_3_5(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(4, xla); } } @@ -4482,7 +4533,7 @@ static private boolean jj_2_5(int xla) static private boolean jj_2_6(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_6()); } + try { return !jj_3_6(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(5, xla); } } @@ -4490,7 +4541,7 @@ static private boolean jj_2_6(int xla) static private boolean jj_2_7(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_7()); } + try { return !jj_3_7(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(6, xla); } } @@ -4498,7 +4549,7 @@ static private boolean jj_2_7(int xla) static private boolean jj_2_8(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_8()); } + try { return !jj_3_8(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(7, xla); } } @@ -4506,7 +4557,7 @@ static private boolean jj_2_8(int xla) static private boolean jj_2_9(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_9()); } + try { return !jj_3_9(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(8, xla); } } @@ -4514,7 +4565,7 @@ static private boolean jj_2_9(int xla) static private boolean jj_2_10(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_10()); } + try { return !jj_3_10(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(9, xla); } } @@ -4522,7 +4573,7 @@ static private boolean jj_2_10(int xla) static private boolean jj_2_11(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_11()); } + try { return !jj_3_11(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(10, xla); } } @@ -4530,7 +4581,7 @@ static private boolean jj_2_11(int xla) static private boolean jj_2_12(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_12()); } + try { return !jj_3_12(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(11, xla); } } @@ -4538,7 +4589,7 @@ static private boolean jj_2_12(int xla) static private boolean jj_2_13(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_13()); } + try { return !jj_3_13(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(12, xla); } } @@ -4546,7 +4597,7 @@ static private boolean jj_2_13(int xla) static private boolean jj_2_14(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_14()); } + try { return !jj_3_14(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(13, xla); } } @@ -4554,7 +4605,7 @@ static private boolean jj_2_14(int xla) static private boolean jj_2_15(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_15()); } + try { return !jj_3_15(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(14, xla); } } @@ -4562,7 +4613,7 @@ static private boolean jj_2_15(int xla) static private boolean jj_2_16(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_16()); } + try { return !jj_3_16(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(15, xla); } } @@ -4570,7 +4621,7 @@ static private boolean jj_2_16(int xla) static private boolean jj_2_17(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_17()); } + try { return !jj_3_17(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(16, xla); } } @@ -4578,7 +4629,7 @@ static private boolean jj_2_17(int xla) static private boolean jj_2_18(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_18()); } + try { return !jj_3_18(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(17, xla); } } @@ -4586,38 +4637,12 @@ static private boolean jj_2_18(int xla) static private boolean jj_2_19(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_19()); } + try { return !jj_3_19(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(18, xla); } } - static private boolean jj_3R_ExpressionBasic_1513_17_144() - { - if (jj_3R_ExpressionStrategy_2042_9_156()) return true; - return false; - } - - static private boolean jj_3R_ExpressionBasic_1511_17_143() - { - if (jj_3R_ExpressionForAll_2022_9_155()) return true; - return false; - } - - static private boolean jj_3R_SystemFullParallel_1073_71_48() - { - if (jj_scan_token(OR)) return true; - if (jj_scan_token(OR)) return true; - if (jj_3R_SystemParallel_1118_9_54()) return true; - return false; - } - - static private boolean jj_3R_ExpressionBasic_1509_17_142() - { - if (jj_3R_ExpressionExists_2003_9_154()) return true; - return false; - } - - static private boolean jj_3R_ExpressionTimesDivide_1461_64_132() + static private boolean jj_3R_132() { if (jj_scan_token(DIVIDE)) return true; return false; @@ -4630,27 +4655,27 @@ static private boolean jj_3_10() return false; } - static private boolean jj_3R_ExpressionBasic_1507_17_141() + static private boolean jj_3R_141() { - if (jj_3R_ExpressionReward_1781_9_153()) return true; + if (jj_3R_153()) return true; return false; } - static private boolean jj_3R_ExpressionBasic_1505_17_140() + static private boolean jj_3R_140() { - if (jj_3R_ExpressionSS_1737_9_38()) return true; + if (jj_3R_38()) return true; return false; } - static private boolean jj_3R_ExpressionBasic_1503_17_139() + static private boolean jj_3R_139() { - if (jj_3R_ExpressionProb_1658_9_152()) return true; + if (jj_3R_152()) return true; return false; } - static private boolean jj_3R_ExpressionBasic_1500_17_138() + static private boolean jj_3R_138() { - if (jj_3R_ExpressionParenth_1634_9_151()) return true; + if (jj_3R_151()) return true; return false; } @@ -4661,104 +4686,104 @@ static private boolean jj_3_18() return false; } - static private boolean jj_3R_ExpressionBasic_1498_17_137() + static private boolean jj_3R_137() { - if (jj_3R_ExpressionFuncOldStyle_1572_9_150()) return true; + if (jj_3R_150()) return true; return false; } - static private boolean jj_3R_ExpressionRewardContents_1886_11_229() + static private boolean jj_3R_229() { - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_SystemParallel_1120_11_64() + static private boolean jj_3R_64() { if (jj_scan_token(OR)) return true; if (jj_scan_token(LBRACKET)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_SystemParallel_1121_65_75()) { jj_scanpos = xsp; break; } + if (jj_3R_75()) { jj_scanpos = xsp; break; } } if (jj_scan_token(RBRACKET)) return true; if (jj_scan_token(OR)) return true; - if (jj_3R_SystemHideRename_1146_9_63()) return true; + if (jj_3R_63()) return true; return false; } - static private boolean jj_3R_ExpressionBasic_1496_17_136() + static private boolean jj_3R_136() { - if (jj_3R_ExpressionFuncMinMax_1558_9_149()) return true; + if (jj_3R_149()) return true; return false; } - static private boolean jj_3R_ExpressionRewardContents_1883_11_228() + static private boolean jj_3R_228() { if (jj_scan_token(F0)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionBasic_1494_17_135() + static private boolean jj_3R_135() { - if (jj_3R_ExpressionFuncOrIdent_1540_9_148()) return true; + if (jj_3R_148()) return true; return false; } static private boolean jj_3_17() { - if (jj_3R_ExpressionSS_1737_9_38()) return true; + if (jj_3R_38()) return true; return false; } - static private boolean jj_3R_ExpressionRewardContents_1882_11_227() + static private boolean jj_3R_227() { if (jj_scan_token(Fc)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_SystemParallel_1118_9_54() + static private boolean jj_3R_54() { - if (jj_3R_SystemHideRename_1146_9_63()) return true; + if (jj_3R_63()) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_SystemParallel_1120_11_64()) jj_scanpos = xsp; + if (jj_3R_64()) jj_scanpos = xsp; return false; } - static private boolean jj_3R_ExpressionRewardContents_1881_11_226() + static private boolean jj_3R_226() { if (jj_scan_token(I)) return true; if (jj_scan_token(EQ)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionBasic_1492_17_134() + static private boolean jj_3R_134() { - if (jj_3R_ExpressionLiteral_1594_9_147()) return true; + if (jj_3R_147()) return true; return false; } - static private boolean jj_3R_ExpressionRewardContents_1880_11_225() + static private boolean jj_3R_225() { if (jj_scan_token(C)) return true; return false; } - static private boolean jj_3R_ExpressionRewardContents_1879_11_224() + static private boolean jj_3R_224() { if (jj_scan_token(C)) return true; if (jj_scan_token(LE)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionPlusMinus_1444_62_128() + static private boolean jj_3R_128() { if (jj_scan_token(MINUS)) return true; return false; @@ -4770,47 +4795,47 @@ static private boolean jj_3_16() return false; } - static private boolean jj_3R_ExpressionRewardContents_1876_11_223() + static private boolean jj_3R_223() { if (jj_scan_token(S)) return true; return false; } - static private boolean jj_3R_ExpressionRewardContents_1875_9_222() + static private boolean jj_3R_222() { - if (jj_3R_ExpressionSS_1737_9_38()) return true; + if (jj_3R_38()) return true; return false; } - static private boolean jj_3R_ExpressionBasic_1491_9_133() + static private boolean jj_3R_133() { Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionBasic_1492_17_134()) { + if (jj_3R_134()) { jj_scanpos = xsp; - if (jj_3R_ExpressionBasic_1494_17_135()) { + if (jj_3R_135()) { jj_scanpos = xsp; - if (jj_3R_ExpressionBasic_1496_17_136()) { + if (jj_3R_136()) { jj_scanpos = xsp; - if (jj_3R_ExpressionBasic_1498_17_137()) { + if (jj_3R_137()) { jj_scanpos = xsp; - if (jj_3R_ExpressionBasic_1500_17_138()) { + if (jj_3R_138()) { jj_scanpos = xsp; - if (jj_3R_ExpressionBasic_1503_17_139()) { + if (jj_3R_139()) { jj_scanpos = xsp; - if (jj_3R_ExpressionBasic_1505_17_140()) { + if (jj_3R_140()) { jj_scanpos = xsp; - if (jj_3R_ExpressionBasic_1507_17_141()) { + if (jj_3R_141()) { jj_scanpos = xsp; - if (jj_3R_ExpressionBasic_1509_17_142()) { + if (jj_3R_142()) { jj_scanpos = xsp; - if (jj_3R_ExpressionBasic_1511_17_143()) { + if (jj_3R_143()) { jj_scanpos = xsp; - if (jj_3R_ExpressionBasic_1513_17_144()) { + if (jj_3R_144()) { jj_scanpos = xsp; - if (jj_3R_ExpressionBasic_1515_17_145()) { + if (jj_3R_145()) { jj_scanpos = xsp; - if (jj_3R_ExpressionBasic_1517_17_146()) return true; + if (jj_3R_146()) return true; } } } @@ -4826,25 +4851,25 @@ static private boolean jj_3R_ExpressionBasic_1491_9_133() return false; } - static private boolean jj_3R_ExpressionRewardContents_1872_9_187() + static private boolean jj_3R_187() { Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionRewardContents_1875_9_222()) { + if (jj_3R_222()) { jj_scanpos = xsp; - if (jj_3R_ExpressionRewardContents_1876_11_223()) { + if (jj_3R_223()) { jj_scanpos = xsp; - if (jj_3R_ExpressionRewardContents_1879_11_224()) { + if (jj_3R_224()) { jj_scanpos = xsp; - if (jj_3R_ExpressionRewardContents_1880_11_225()) { + if (jj_3R_225()) { jj_scanpos = xsp; - if (jj_3R_ExpressionRewardContents_1881_11_226()) { + if (jj_3R_226()) { jj_scanpos = xsp; - if (jj_3R_ExpressionRewardContents_1882_11_227()) { + if (jj_3R_227()) { jj_scanpos = xsp; - if (jj_3R_ExpressionRewardContents_1883_11_228()) { + if (jj_3R_228()) { jj_scanpos = xsp; - if (jj_3R_ExpressionRewardContents_1886_11_229()) return true; + if (jj_3R_229()) return true; } } } @@ -4855,270 +4880,282 @@ static private boolean jj_3R_ExpressionRewardContents_1872_9_187() return false; } - static private boolean jj_3R_RewardIndex_1846_33_262() + static private boolean jj_3R_263() { if (jj_scan_token(DQUOTE)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; if (jj_scan_token(DQUOTE)) return true; return false; } - static private boolean jj_3R_ExpressionUnaryMinus_1479_17_130() + static private boolean jj_3R_130() { - if (jj_3R_ExpressionBasic_1491_9_133()) return true; + if (jj_3R_133()) return true; return false; } - static private boolean jj_3R_ExpressionReward_1809_69_188() + static private boolean jj_3R_188() { - if (jj_3R_Filter_1713_9_52()) return true; + if (jj_3R_52()) return true; return false; } - static private boolean jj_3R_ExpressionUnaryMinus_1476_17_129() + static private boolean jj_3R_129() { if (jj_scan_token(MINUS)) return true; - if (jj_3R_ExpressionUnaryMinus_1475_9_125()) return true; + if (jj_3R_125()) return true; return false; } - static private boolean jj_3R_SystemInterleaved_1094_9_47() + static private boolean jj_3R_47() { - if (jj_3R_SystemParallel_1118_9_54()) return true; + if (jj_3R_54()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_SystemInterleaved_1096_70_55()) { jj_scanpos = xsp; break; } - } - return false; - } - - static private boolean jj_3R_ExpressionUnaryMinus_1475_9_125() - { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_ExpressionUnaryMinus_1476_17_129()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionUnaryMinus_1479_17_130()) return true; + if (jj_3R_55()) { jj_scanpos = xsp; break; } } return false; } - static private boolean jj_3R_ExpressionTimesDivide_1461_19_131() + static private boolean jj_3R_59() { - if (jj_scan_token(TIMES)) return true; + if (jj_scan_token(LE)) return true; return false; } - static private boolean jj_3R_ExpressionTimesDivide_1461_17_126() + static private boolean jj_3R_125() { Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionTimesDivide_1461_19_131()) { + if (jj_3R_129()) { jj_scanpos = xsp; - if (jj_3R_ExpressionTimesDivide_1461_64_132()) return true; + if (jj_3R_130()) return true; } - if (jj_3R_ExpressionUnaryMinus_1475_9_125()) return true; return false; } - static private boolean jj_3_15() + static private boolean jj_3R_58() { - if (jj_scan_token(DQUOTE)) return true; + if (jj_scan_token(GE)) return true; return false; } - static private boolean jj_3R_RewardIndex_1846_11_254() + static private boolean jj_3R_57() + { + if (jj_scan_token(LT)) return true; + return false; + } + + static private boolean jj_3R_56() + { + if (jj_scan_token(GT)) return true; + return false; + } + + static private boolean jj_3R_50() { - if (jj_scan_token(DIVIDE)) return true; - if (jj_scan_token(LBRACE)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_RewardIndex_1846_33_262()) { + if (jj_3R_56()) { + jj_scanpos = xsp; + if (jj_3R_57()) { + jj_scanpos = xsp; + if (jj_3R_58()) { jj_scanpos = xsp; - if (jj_3R_RewardIndex_1846_101_263()) return true; + if (jj_3R_59()) return true; + } + } } - if (jj_scan_token(RBRACE)) return true; return false; } - static private boolean jj_3R_RewardIndex_1843_10_253() + static private boolean jj_3R_131() { - if (jj_scan_token(COMMA)) return true; - if (jj_scan_token(DISCOUNT)) return true; - if (jj_scan_token(EQ)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_scan_token(TIMES)) return true; return false; } - static private boolean jj_3R_RewardIndex_1841_10_250() + static private boolean jj_3R_126() { - if (jj_scan_token(DQUOTE)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; - if (jj_scan_token(DQUOTE)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_131()) { + jj_scanpos = xsp; + if (jj_3R_132()) return true; + } + if (jj_3R_125()) return true; return false; } - static private boolean jj_3R_ExpressionTimesDivide_1459_9_121() + static private boolean jj_3_15() { - if (jj_3R_ExpressionUnaryMinus_1475_9_125()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_ExpressionTimesDivide_1461_17_126()) { jj_scanpos = xsp; break; } - } + if (jj_scan_token(DQUOTE)) return true; return false; } - static private boolean jj_3_2() + static private boolean jj_3R_254() { - if (jj_scan_token(DQUOTE)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; - if (jj_scan_token(DQUOTE)) return true; - if (jj_scan_token(COLON)) return true; + if (jj_scan_token(DIVIDE)) return true; + if (jj_scan_token(LBRACE)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_263()) { + jj_scanpos = xsp; + if (jj_3R_264()) return true; + } + if (jj_scan_token(RBRACE)) return true; return false; } - static private boolean jj_3R_LtGt_2223_9_59() + static private boolean jj_3R_124() { - if (jj_scan_token(LE)) return true; + if (jj_scan_token(NE)) return true; return false; } - static private boolean jj_3R_RewardIndex_1839_9_240() + static private boolean jj_3R_120() { - if (jj_scan_token(LBRACE)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_RewardIndex_1841_10_250()) { - jj_scanpos = xsp; - if (jj_3R_RewardIndex_1841_75_251()) { + if (jj_3R_123()) { jj_scanpos = xsp; - if (jj_3R_RewardIndex_1841_125_252()) return true; + if (jj_3R_124()) return true; } - } - xsp = jj_scanpos; - if (jj_3R_RewardIndex_1843_10_253()) jj_scanpos = xsp; - if (jj_scan_token(RBRACE)) return true; - xsp = jj_scanpos; - if (jj_3R_RewardIndex_1846_11_254()) jj_scanpos = xsp; return false; } - static private boolean jj_3R_LtGt_2222_9_58() + static private boolean jj_3R_123() { - if (jj_scan_token(GE)) return true; + if (jj_scan_token(EQ)) return true; return false; } - static private boolean jj_3R_LtGt_2221_9_57() + static private boolean jj_3R_253() { - if (jj_scan_token(LT)) return true; + if (jj_scan_token(COMMA)) return true; + if (jj_scan_token(DISCOUNT)) return true; + if (jj_scan_token(EQ)) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_SystemFullParallel_1071_9_40() + static private boolean jj_3R_250() { - if (jj_3R_SystemInterleaved_1094_9_47()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_SystemFullParallel_1073_71_48()) { jj_scanpos = xsp; break; } - } + if (jj_scan_token(DQUOTE)) return true; + if (jj_3R_34()) return true; + if (jj_scan_token(DQUOTE)) return true; return false; } - static private boolean jj_3R_ExpressionPlusMinus_1444_19_127() + static private boolean jj_3R_121() { - if (jj_scan_token(PLUS)) return true; + if (jj_3R_125()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_126()) { jj_scanpos = xsp; break; } + } return false; } - static private boolean jj_3R_LtGt_2220_9_56() + static private boolean jj_3_2() { - if (jj_scan_token(GT)) return true; + if (jj_scan_token(DQUOTE)) return true; + if (jj_3R_34()) return true; + if (jj_scan_token(DQUOTE)) return true; + if (jj_scan_token(COLON)) return true; return false; } - static private boolean jj_3R_LtGt_2220_9_50() + static private boolean jj_3R_240() { + if (jj_scan_token(LBRACE)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_LtGt_2220_9_56()) { - jj_scanpos = xsp; - if (jj_3R_LtGt_2221_9_57()) { + if (jj_3R_250()) { jj_scanpos = xsp; - if (jj_3R_LtGt_2222_9_58()) { + if (jj_3R_251()) { jj_scanpos = xsp; - if (jj_3R_LtGt_2223_9_59()) return true; - } + if (jj_3R_252()) return true; } } + xsp = jj_scanpos; + if (jj_3R_253()) jj_scanpos = xsp; + if (jj_scan_token(RBRACE)) return true; + xsp = jj_scanpos; + if (jj_3R_254()) jj_scanpos = xsp; return false; } - static private boolean jj_3R_ExpressionPlusMinus_1444_17_122() + static private boolean jj_3R_40() { + if (jj_3R_47()) return true; Token xsp; - xsp = jj_scanpos; - if (jj_3R_ExpressionPlusMinus_1444_19_127()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionPlusMinus_1444_62_128()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_48()) { jj_scanpos = xsp; break; } } - if (jj_3R_ExpressionTimesDivide_1459_9_121()) return true; return false; } - static private boolean jj_3R_EqNeq_2211_9_124() + static private boolean jj_3R_127() { - if (jj_scan_token(NE)) return true; + if (jj_scan_token(PLUS)) return true; return false; } - static private boolean jj_3R_EqNeq_2210_9_120() + static private boolean jj_3R_122() { Token xsp; xsp = jj_scanpos; - if (jj_3R_EqNeq_2210_9_123()) { + if (jj_3R_127()) { jj_scanpos = xsp; - if (jj_3R_EqNeq_2211_9_124()) return true; + if (jj_3R_128()) return true; } + if (jj_3R_121()) return true; return false; } - static private boolean jj_3R_EqNeq_2210_9_123() + static private boolean jj_3R_53() { - if (jj_scan_token(EQ)) return true; + if (jj_scan_token(REG_IDENTPRIME)) return true; return false; } - static private boolean jj_3R_ExpressionPlusMinus_1442_9_118() + static private boolean jj_3R_118() { - if (jj_3R_ExpressionTimesDivide_1459_9_121()) return true; + if (jj_3R_121()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_ExpressionPlusMinus_1444_17_122()) { jj_scanpos = xsp; break; } + if (jj_3R_122()) { jj_scanpos = xsp; break; } } return false; } - static private boolean jj_3R_SystemDefn_1058_9_36() + static private boolean jj_3R_36() + { + if (jj_3R_40()) return true; + return false; + } + + static private boolean jj_3R_199() { - if (jj_3R_SystemFullParallel_1071_9_40()) return true; + if (jj_scan_token(OR)) return true; return false; } static private boolean jj_3_7() { if (jj_scan_token(DQUOTE)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; if (jj_scan_token(DQUOTE)) return true; - if (jj_3R_SystemDefn_1058_9_36()) return true; + if (jj_3R_36()) return true; return false; } - static private boolean jj_3R_ExpressionReward_1794_26_246() + static private boolean jj_3R_246() { if (jj_scan_token(MAX)) return true; if (jj_scan_token(EQ)) return true; @@ -5126,7 +5163,7 @@ static private boolean jj_3R_ExpressionReward_1794_26_246() return false; } - static private boolean jj_3R_ExpressionReward_1793_26_245() + static private boolean jj_3R_245() { if (jj_scan_token(MIN)) return true; if (jj_scan_token(EQ)) return true; @@ -5134,14 +5171,14 @@ static private boolean jj_3R_ExpressionReward_1793_26_245() return false; } - static private boolean jj_3R_ExpressionReward_1792_26_244() + static private boolean jj_3R_244() { if (jj_scan_token(EQ)) return true; if (jj_scan_token(QMARK)) return true; return false; } - static private boolean jj_3R_ExpressionReward_1807_10_186() + static private boolean jj_3R_186() { if (jj_scan_token(RMAXMAX)) return true; if (jj_scan_token(EQ)) return true; @@ -5149,13 +5186,7 @@ static private boolean jj_3R_ExpressionReward_1807_10_186() return false; } - static private boolean jj_3R_IdentifierPrime_2191_9_53() - { - if (jj_scan_token(REG_IDENTPRIME)) return true; - return false; - } - - static private boolean jj_3R_ExpressionReward_1790_26_243() + static private boolean jj_3R_243() { if (jj_scan_token(MAX)) return true; if (jj_scan_token(EQ)) return true; @@ -5163,7 +5194,7 @@ static private boolean jj_3R_ExpressionReward_1790_26_243() return false; } - static private boolean jj_3R_ExpressionReward_1799_17_221() + static private boolean jj_3R_221() { if (jj_scan_token(MAXMAX)) return true; if (jj_scan_token(EQ)) return true; @@ -5171,7 +5202,7 @@ static private boolean jj_3R_ExpressionReward_1799_17_221() return false; } - static private boolean jj_3R_ExpressionReward_1806_10_185() + static private boolean jj_3R_185() { if (jj_scan_token(RMAXMIN)) return true; if (jj_scan_token(EQ)) return true; @@ -5179,14 +5210,14 @@ static private boolean jj_3R_ExpressionReward_1806_10_185() return false; } - static private boolean jj_3R_ExpressionRelop_1422_11_119() + static private boolean jj_3R_119() { - if (jj_3R_LtGt_2220_9_50()) return true; - if (jj_3R_ExpressionPlusMinus_1442_9_118()) return true; + if (jj_3R_50()) return true; + if (jj_3R_118()) return true; return false; } - static private boolean jj_3R_ExpressionReward_1789_26_242() + static private boolean jj_3R_242() { if (jj_scan_token(MIN)) return true; if (jj_scan_token(EQ)) return true; @@ -5194,7 +5225,7 @@ static private boolean jj_3R_ExpressionReward_1789_26_242() return false; } - static private boolean jj_3R_ExpressionReward_1798_17_220() + static private boolean jj_3R_220() { if (jj_scan_token(MAXMIN)) return true; if (jj_scan_token(EQ)) return true; @@ -5202,7 +5233,7 @@ static private boolean jj_3R_ExpressionReward_1798_17_220() return false; } - static private boolean jj_3R_ExpressionReward_1805_10_184() + static private boolean jj_3R_184() { if (jj_scan_token(RMINMAX)) return true; if (jj_scan_token(EQ)) return true; @@ -5210,14 +5241,14 @@ static private boolean jj_3R_ExpressionReward_1805_10_184() return false; } - static private boolean jj_3R_ExpressionReward_1788_26_241() + static private boolean jj_3R_241() { if (jj_scan_token(EQ)) return true; if (jj_scan_token(QMARK)) return true; return false; } - static private boolean jj_3R_ExpressionReward_1797_17_219() + static private boolean jj_3R_219() { if (jj_scan_token(MINMAX)) return true; if (jj_scan_token(EQ)) return true; @@ -5225,7 +5256,7 @@ static private boolean jj_3R_ExpressionReward_1797_17_219() return false; } - static private boolean jj_3R_ExpressionReward_1804_10_183() + static private boolean jj_3R_183() { if (jj_scan_token(RMINMIN)) return true; if (jj_scan_token(EQ)) return true; @@ -5233,7 +5264,13 @@ static private boolean jj_3R_ExpressionReward_1804_10_183() return false; } - static private boolean jj_3R_ExpressionReward_1796_17_218() + static private boolean jj_3R_37() + { + if (jj_3R_34()) return true; + return false; + } + + static private boolean jj_3R_218() { if (jj_scan_token(MINMIN)) return true; if (jj_scan_token(EQ)) return true; @@ -5241,7 +5278,7 @@ static private boolean jj_3R_ExpressionReward_1796_17_218() return false; } - static private boolean jj_3R_ExpressionReward_1803_10_182() + static private boolean jj_3R_182() { if (jj_scan_token(RMAX)) return true; if (jj_scan_token(EQ)) return true; @@ -5249,18 +5286,18 @@ static private boolean jj_3R_ExpressionReward_1803_10_182() return false; } - static private boolean jj_3R_ExpressionRelop_1421_9_116() + static private boolean jj_3R_116() { - if (jj_3R_ExpressionPlusMinus_1442_9_118()) return true; + if (jj_3R_118()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_ExpressionRelop_1422_11_119()) { jj_scanpos = xsp; break; } + if (jj_3R_119()) { jj_scanpos = xsp; break; } } return false; } - static private boolean jj_3R_ExpressionReward_1802_10_181() + static private boolean jj_3R_181() { if (jj_scan_token(RMIN)) return true; if (jj_scan_token(EQ)) return true; @@ -5268,124 +5305,136 @@ static private boolean jj_3R_ExpressionReward_1802_10_181() return false; } - static private boolean jj_3R_ExpressionFilter_2137_56_199() - { - if (jj_scan_token(OR)) return true; - return false; - } - - static private boolean jj_3R_ExpressionReward_1792_17_217() + static private boolean jj_3R_217() { if (jj_scan_token(MAX)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionReward_1792_26_244()) { + if (jj_3R_244()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1793_26_245()) { + if (jj_3R_245()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1794_26_246()) return true; + if (jj_3R_246()) return true; } } return false; } - static private boolean jj_3R_ExpressionReward_1788_17_216() + static private boolean jj_3R_198() + { + if (jj_scan_token(AND)) return true; + return false; + } + + static private boolean jj_3R_196() + { + if (jj_scan_token(MAX)) return true; + return false; + } + + static private boolean jj_3R_216() { if (jj_scan_token(MIN)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionReward_1788_26_241()) { + if (jj_3R_241()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1789_26_242()) { + if (jj_3R_242()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1790_26_243()) return true; + if (jj_3R_243()) return true; } } return false; } - static private boolean jj_3R_ExpressionReward_1787_17_215() + static private boolean jj_3R_215() { if (jj_scan_token(EQ)) return true; if (jj_scan_token(QMARK)) return true; return false; } - static private boolean jj_3R_ExpressionReward_1786_18_214() + static private boolean jj_3R_214() { - if (jj_3R_LtGt_2220_9_50()) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_50()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionReward_1785_18_213() + static private boolean jj_3R_213() { - if (jj_3R_RewardIndex_1839_9_240()) return true; + if (jj_3R_240()) return true; return false; } - static private boolean jj_3R_ExpressionReward_1784_19_212() + static private boolean jj_3R_212() { if (jj_scan_token(LPARENTH)) return true; - if (jj_3R_IdentifierExpression_2169_9_37()) return true; + if (jj_3R_37()) return true; if (jj_scan_token(RPARENTH)) return true; return false; } - static private boolean jj_3R_ExpressionEquality_1408_11_117() + static private boolean jj_3R_34() + { + if (jj_scan_token(REG_IDENT)) return true; + return false; + } + + static private boolean jj_3R_117() { - if (jj_3R_EqNeq_2210_9_120()) return true; - if (jj_3R_ExpressionRelop_1421_9_116()) return true; + if (jj_3R_120()) return true; + if (jj_3R_116()) return true; return false; } - static private boolean jj_3R_ExpressionSS_1745_55_44() + static private boolean jj_3R_44() { - if (jj_3R_Filter_1713_9_52()) return true; + if (jj_3R_52()) return true; return false; } - static private boolean jj_3R_ExpressionEquality_1407_9_115() + static private boolean jj_3R_115() { - if (jj_3R_ExpressionRelop_1421_9_116()) return true; + if (jj_3R_116()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_ExpressionEquality_1408_11_117()) { jj_scanpos = xsp; break; } + if (jj_3R_117()) { jj_scanpos = xsp; break; } } return false; } - static private boolean jj_3R_IdentifierExpression_2169_9_37() + static private boolean jj_3R_194() { - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_scan_token(INIT)) return true; return false; } - static private boolean jj_3R_ExpressionReward_1783_10_180() + static private boolean jj_3R_180() { if (jj_scan_token(R)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionReward_1784_19_212()) jj_scanpos = xsp; + if (jj_3R_212()) jj_scanpos = xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionReward_1785_18_213()) jj_scanpos = xsp; + if (jj_3R_213()) jj_scanpos = xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionReward_1786_18_214()) { + if (jj_3R_214()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1787_17_215()) { + if (jj_3R_215()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1788_17_216()) { + if (jj_3R_216()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1792_17_217()) { + if (jj_3R_217()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1796_17_218()) { + if (jj_3R_218()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1797_17_219()) { + if (jj_3R_219()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1798_17_220()) { + if (jj_3R_220()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1799_17_221()) return true; + if (jj_3R_221()) return true; } } } @@ -5396,42 +5445,42 @@ static private boolean jj_3R_ExpressionReward_1783_10_180() return false; } - static private boolean jj_3R_ExpressionNot_1393_17_114() + static private boolean jj_3R_114() { - if (jj_3R_ExpressionEquality_1407_9_115()) return true; + if (jj_3R_115()) return true; return false; } - static private boolean jj_3R_ExpressionNot_1391_17_113() + static private boolean jj_3R_113() { if (jj_scan_token(NOT)) return true; - if (jj_3R_ExpressionNot_1390_9_111()) return true; + if (jj_3R_111()) return true; return false; } - static private boolean jj_3R_TimeBound_1308_99_106() + static private boolean jj_3R_106() { - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionReward_1781_9_153() + static private boolean jj_3R_153() { Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionReward_1783_10_180()) { + if (jj_3R_180()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1802_10_181()) { + if (jj_3R_181()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1803_10_182()) { + if (jj_3R_182()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1804_10_183()) { + if (jj_3R_183()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1805_10_184()) { + if (jj_3R_184()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1806_10_185()) { + if (jj_3R_185()) { jj_scanpos = xsp; - if (jj_3R_ExpressionReward_1807_10_186()) return true; + if (jj_3R_186()) return true; } } } @@ -5439,198 +5488,187 @@ static private boolean jj_3R_ExpressionReward_1781_9_153() } } if (jj_scan_token(LBRACKET)) return true; - if (jj_3R_ExpressionRewardContents_1872_9_187()) return true; + if (jj_3R_187()) return true; xsp = jj_scanpos; - if (jj_3R_ExpressionReward_1809_69_188()) jj_scanpos = xsp; + if (jj_3R_188()) jj_scanpos = xsp; if (jj_scan_token(RBRACKET)) return true; return false; } - static private boolean jj_3R_TimeBound_1307_99_104() - { - if (jj_3R_Expression_1229_9_43()) return true; - return false; - } - - static private boolean jj_3R_ExpressionFilter_2137_34_198() - { - if (jj_scan_token(AND)) return true; - return false; - } - - static private boolean jj_3R_ExpressionFilter_2136_35_196() - { - if (jj_scan_token(MAX)) return true; - return false; - } - - static private boolean jj_3R_TimeBound_1306_99_102() + static private boolean jj_3R_201() { - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_scan_token(COMMA)) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_TimeBound_1305_99_100() + static private boolean jj_3R_104() { - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_Identifier_2158_9_34() + static private boolean jj_3R_102() { - if (jj_scan_token(REG_IDENT)) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionNot_1390_9_111() + static private boolean jj_3R_100() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_ExpressionNot_1391_17_113()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionNot_1393_17_114()) return true; - } + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionLabel_2115_47_194() + static private boolean jj_3R_200() { - if (jj_scan_token(INIT)) return true; + if (jj_3R_34()) return true; return false; } - static private boolean jj_3R_ExpressionAnd_1378_11_112() + static private boolean jj_3R_197() { - if (jj_scan_token(AND)) return true; - if (jj_3R_ExpressionNot_1390_9_111()) return true; + if (jj_scan_token(PLUS)) return true; return false; } - static private boolean jj_3R_ExpressionFilter_2142_11_201() + static private boolean jj_3R_195() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_scan_token(MIN)) return true; return false; } - static private boolean jj_3R_ExpressionAnd_1377_9_109() + static private boolean jj_3R_111() { - if (jj_3R_ExpressionNot_1390_9_111()) return true; Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_ExpressionAnd_1378_11_112()) { jj_scanpos = xsp; break; } + xsp = jj_scanpos; + if (jj_3R_113()) { + jj_scanpos = xsp; + if (jj_3R_114()) return true; } return false; } - static private boolean jj_3R_ExpressionFilter_2138_11_200() + static private boolean jj_3R_193() { - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; return false; } - static private boolean jj_3R_ExpressionFilter_2137_11_197() + static private boolean jj_3R_233() { - if (jj_scan_token(PLUS)) return true; + if (jj_3R_249()) return true; return false; } - static private boolean jj_3R_ExpressionFilter_2136_11_195() + static private boolean jj_3R_158() { - if (jj_scan_token(MIN)) return true; + if (jj_scan_token(FILTER)) return true; + if (jj_scan_token(LPARENTH)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_195()) { + jj_scanpos = xsp; + if (jj_3R_196()) { + jj_scanpos = xsp; + if (jj_3R_197()) { + jj_scanpos = xsp; + if (jj_3R_198()) { + jj_scanpos = xsp; + if (jj_3R_199()) { + jj_scanpos = xsp; + if (jj_3R_200()) return true; + } + } + } + } + } + if (jj_scan_token(COMMA)) return true; + if (jj_3R_43()) return true; + xsp = jj_scanpos; + if (jj_3R_201()) jj_scanpos = xsp; + if (jj_scan_token(RPARENTH)) return true; return false; } - static private boolean jj_3R_ExpressionLabel_2115_30_193() + static private boolean jj_3R_112() { - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_scan_token(AND)) return true; + if (jj_3R_111()) return true; return false; } - static private boolean jj_3R_ExpressionStrategy_2050_93_233() + static private boolean jj_3R_109() { - if (jj_3R_ExpressionMultiNash_1906_9_249()) return true; + if (jj_3R_111()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_112()) { jj_scanpos = xsp; break; } + } return false; } - static private boolean jj_3R_ExpressionOr_1365_11_110() + static private boolean jj_3R_110() { if (jj_scan_token(OR)) return true; - if (jj_3R_ExpressionAnd_1377_9_109()) return true; + if (jj_3R_109()) return true; return false; } - static private boolean jj_3R_ExpressionSS_1742_17_42() + static private boolean jj_3R_42() { if (jj_scan_token(EQ)) return true; if (jj_scan_token(QMARK)) return true; return false; } - static private boolean jj_3R_ExpressionSS_1740_19_49() + static private boolean jj_3R_49() { if (jj_scan_token(LPARENTH)) return true; - if (jj_3R_IdentifierExpression_2169_9_37()) return true; + if (jj_3R_37()) return true; if (jj_scan_token(RPARENTH)) return true; return false; } - static private boolean jj_3R_ExpressionFilter_2131_9_158() + static private boolean jj_3R_157() { - if (jj_scan_token(FILTER)) return true; - if (jj_scan_token(LPARENTH)) return true; + if (jj_scan_token(DQUOTE)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionFilter_2136_11_195()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionFilter_2136_35_196()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionFilter_2137_11_197()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionFilter_2137_34_198()) { + if (jj_3R_193()) { jj_scanpos = xsp; - if (jj_3R_ExpressionFilter_2137_56_199()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionFilter_2138_11_200()) return true; - } - } - } + if (jj_3R_194()) return true; } - } - if (jj_scan_token(COMMA)) return true; - if (jj_3R_Expression_1229_9_43()) return true; - xsp = jj_scanpos; - if (jj_3R_ExpressionFilter_2142_11_201()) jj_scanpos = xsp; - if (jj_scan_token(RPARENTH)) return true; + if (jj_scan_token(DQUOTE)) return true; return false; } static private boolean jj_3_1() { if (jj_scan_token(MODULE)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; if (jj_scan_token(EQ)) return true; return false; } - static private boolean jj_3R_ExpressionSS_1740_17_41() + static private boolean jj_3R_41() { Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionSS_1740_19_49()) jj_scanpos = xsp; - if (jj_3R_LtGt_2220_9_50()) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_49()) jj_scanpos = xsp; + if (jj_3R_50()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionOr_1364_9_107() + static private boolean jj_3R_107() { - if (jj_3R_ExpressionAnd_1377_9_109()) return true; + if (jj_3R_109()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_ExpressionOr_1365_11_110()) { jj_scanpos = xsp; break; } + if (jj_3R_110()) { jj_scanpos = xsp; break; } } return false; } @@ -5641,340 +5679,350 @@ static private boolean jj_3_6() return false; } - static private boolean jj_3R_ExpressionIff_1352_11_108() + static private boolean jj_3R_108() { if (jj_scan_token(IFF)) return true; - if (jj_3R_ExpressionOr_1364_9_107()) return true; + if (jj_3R_107()) return true; return false; } - static private boolean jj_3R_ExpressionSS_1737_9_38() + static private boolean jj_3R_38() { if (jj_scan_token(S)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionSS_1740_17_41()) { + if (jj_3R_41()) { jj_scanpos = xsp; - if (jj_3R_ExpressionSS_1742_17_42()) return true; + if (jj_3R_42()) return true; } if (jj_scan_token(LBRACKET)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; xsp = jj_scanpos; - if (jj_3R_ExpressionSS_1745_55_44()) jj_scanpos = xsp; + if (jj_3R_44()) jj_scanpos = xsp; if (jj_scan_token(RBRACKET)) return true; return false; } - static private boolean jj_3R_ExpressionIff_1351_9_97() + static private boolean jj_3R_275() { - if (jj_3R_ExpressionOr_1364_9_107()) return true; Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_ExpressionIff_1352_11_108()) { jj_scanpos = xsp; break; } + xsp = jj_scanpos; + if (jj_scan_token(117)) { + jj_scanpos = xsp; + if (jj_scan_token(120)) return true; } return false; } - static private boolean jj_3R_ExpressionLabel_2113_9_157() + static private boolean jj_3R_97() { - if (jj_scan_token(DQUOTE)) return true; + if (jj_3R_107()) return true; Token xsp; - xsp = jj_scanpos; - if (jj_3R_ExpressionLabel_2115_30_193()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionLabel_2115_47_194()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_108()) { jj_scanpos = xsp; break; } } - if (jj_scan_token(DQUOTE)) return true; return false; } - static private boolean jj_3R_ExpressionProb_1684_51_179() + static private boolean jj_3R_232() + { + if (jj_3R_153()) return true; + return false; + } + + static private boolean jj_3R_276() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_275()) return true; + return false; + } + + static private boolean jj_3R_179() { - if (jj_3R_Filter_1713_9_52()) return true; + if (jj_3R_52()) return true; return false; } - static private boolean jj_3R_Filter_1716_19_72() + static private boolean jj_3R_72() { if (jj_scan_token(MAX)) return true; return false; } - static private boolean jj_3R_Filter_1715_19_71() + static private boolean jj_3R_71() { if (jj_scan_token(MIN)) return true; return false; } - static private boolean jj_3R_ExpressionImplies_1339_11_98() + static private boolean jj_3R_98() { if (jj_scan_token(IMPLIES)) return true; - if (jj_3R_ExpressionIff_1351_9_97()) return true; + if (jj_3R_97()) return true; + return false; + } + + static private boolean jj_3R_265() + { + if (jj_3R_275()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_276()) { jj_scanpos = xsp; break; } + } + return false; + } + + static private boolean jj_3R_256() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_265()) jj_scanpos = xsp; + return false; + } + + static private boolean jj_3R_255() + { + if (jj_scan_token(TIMES)) return true; return false; } - static private boolean jj_3R_ExpressionImplies_1338_9_87() + static private boolean jj_3R_87() { - if (jj_3R_ExpressionIff_1351_9_97()) return true; + if (jj_3R_97()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_ExpressionImplies_1339_11_98()) { jj_scanpos = xsp; break; } + if (jj_3R_98()) { jj_scanpos = xsp; break; } } return false; } - static private boolean jj_3R_ExpressionStrategyCoalitionPlayer_2099_9_273() + static private boolean jj_3R_247() { Token xsp; xsp = jj_scanpos; - if (jj_scan_token(113)) { + if (jj_3R_255()) { jj_scanpos = xsp; - if (jj_scan_token(116)) return true; + if (jj_3R_256()) return true; } return false; } - static private boolean jj_3R_Filter_1714_11_62() + static private boolean jj_3R_62() { if (jj_scan_token(LBRACE)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_Filter_1715_19_71()) { + if (jj_3R_71()) { jj_scanpos = xsp; - if (jj_3R_Filter_1716_19_72()) return true; + if (jj_3R_72()) return true; } if (jj_scan_token(RBRACE)) return true; return false; } - static private boolean jj_3R_ExpressionITE_1324_17_88() + static private boolean jj_3R_88() { if (jj_scan_token(QMARK)) return true; - if (jj_3R_ExpressionImplies_1338_9_87()) return true; + if (jj_3R_87()) return true; if (jj_scan_token(COLON)) return true; - if (jj_3R_ExpressionITE_1322_9_80()) return true; + if (jj_3R_80()) return true; return false; } - static private boolean jj_3R_Filter_1713_9_52() + static private boolean jj_3R_52() { if (jj_scan_token(LBRACE)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; if (jj_scan_token(RBRACE)) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_Filter_1714_11_62()) { jj_scanpos = xsp; break; } + if (jj_3R_62()) { jj_scanpos = xsp; break; } } return false; } static private boolean jj_3_14() { - if (jj_3R_IdentifierExpression_2169_9_37()) return true; + if (jj_3R_37()) return true; if (jj_scan_token(LPARENTH)) return true; return false; } static private boolean jj_3_13() { - if (jj_3R_IdentifierExpression_2169_9_37()) return true; + if (jj_3R_37()) return true; if (jj_scan_token(LPARENTH)) return true; return false; } static private boolean jj_3_12() { - if (jj_3R_IdentifierExpression_2169_9_37()) return true; + if (jj_3R_37()) return true; if (jj_scan_token(LPARENTH)) return true; return false; } - static private boolean jj_3R_ExpressionStrategy_2050_51_232() - { - if (jj_3R_ExpressionReward_1781_9_153()) return true; - return false; - } - static private boolean jj_3_11() { - if (jj_3R_IdentifierExpression_2169_9_37()) return true; + if (jj_3R_37()) return true; if (jj_scan_token(LPARENTH)) return true; return false; } - static private boolean jj_3R_ExpressionStrategyCoalition_2086_13_274() - { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_ExpressionStrategyCoalitionPlayer_2099_9_273()) return true; - return false; - } - - static private boolean jj_3R_ExpressionITE_1322_9_80() + static private boolean jj_3R_248() { - if (jj_3R_ExpressionImplies_1338_9_87()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_ExpressionITE_1324_17_88()) jj_scanpos = xsp; + if (jj_scan_token(COLON)) return true; + if (jj_3R_247()) return true; return false; } - static private boolean jj_3R_ExpressionStrategyCoalition_2085_11_264() + static private boolean jj_3R_230() { - if (jj_3R_ExpressionStrategyCoalitionPlayer_2099_9_273()) return true; + if (jj_3R_247()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_ExpressionStrategyCoalition_2086_13_274()) { jj_scanpos = xsp; break; } + if (jj_3R_248()) { jj_scanpos = xsp; break; } } return false; } - static private boolean jj_3R_ExpressionStrategyCoalition_2085_9_256() + static private boolean jj_3R_80() { + if (jj_3R_87()) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionStrategyCoalition_2085_11_264()) jj_scanpos = xsp; - return false; - } - - static private boolean jj_3R_ExpressionStrategyCoalition_2083_11_255() - { - if (jj_scan_token(TIMES)) return true; + if (jj_3R_88()) jj_scanpos = xsp; return false; } - static private boolean jj_3R_TimeBound_1308_20_105() + static private boolean jj_3R_105() { - if (jj_3R_IdentifierExpression_2169_9_37()) return true; + if (jj_3R_37()) return true; return false; } - static private boolean jj_3R_TimeBound_1307_20_103() + static private boolean jj_3R_103() { - if (jj_3R_IdentifierExpression_2169_9_37()) return true; - return false; - } - - static private boolean jj_3R_ExpressionStrategyCoalition_2083_9_247() - { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_ExpressionStrategyCoalition_2083_11_255()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionStrategyCoalition_2085_9_256()) return true; - } + if (jj_3R_37()) return true; return false; } - static private boolean jj_3R_Update_907_36_46() + static private boolean jj_3R_46() { if (jj_scan_token(AND)) return true; - if (jj_3R_UpdateElement_920_9_45()) return true; + if (jj_3R_45()) return true; return false; } - static private boolean jj_3R_TimeBound_1306_20_101() + static private boolean jj_3R_101() { - if (jj_3R_IdentifierExpression_2169_9_37()) return true; + if (jj_3R_37()) return true; return false; } - static private boolean jj_3R_TimeBound_1305_20_99() + static private boolean jj_3R_99() { - if (jj_3R_IdentifierExpression_2169_9_37()) return true; + if (jj_3R_37()) return true; return false; } - static private boolean jj_3R_TimeBound_1310_11_94() + static private boolean jj_3R_94() { if (jj_scan_token(EQ)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_TimeBound_1309_11_93() + static private boolean jj_3R_93() { if (jj_scan_token(LBRACKET)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; if (jj_scan_token(COMMA)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; if (jj_scan_token(RBRACKET)) return true; return false; } - static private boolean jj_3R_TimeBound_1308_11_92() + static private boolean jj_3R_92() { if (jj_scan_token(GT)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_TimeBound_1308_20_105()) { + if (jj_3R_105()) { jj_scanpos = xsp; - if (jj_3R_TimeBound_1308_99_106()) return true; + if (jj_3R_106()) return true; } return false; } - static private boolean jj_3R_TimeBound_1307_11_91() + static private boolean jj_3R_91() { if (jj_scan_token(GE)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_TimeBound_1307_20_103()) { + if (jj_3R_103()) { jj_scanpos = xsp; - if (jj_3R_TimeBound_1307_99_104()) return true; + if (jj_3R_104()) return true; } return false; } - static private boolean jj_3R_TimeBound_1306_11_90() + static private boolean jj_3R_90() { if (jj_scan_token(LT)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_TimeBound_1306_20_101()) { + if (jj_3R_101()) { jj_scanpos = xsp; - if (jj_3R_TimeBound_1306_99_102()) return true; + if (jj_3R_102()) return true; } return false; } - static private boolean jj_3R_TimeBound_1305_11_89() + static private boolean jj_3R_192() + { + if (jj_3R_151()) return true; + return false; + } + + static private boolean jj_3R_89() { if (jj_scan_token(LE)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_TimeBound_1305_20_99()) { + if (jj_3R_99()) { jj_scanpos = xsp; - if (jj_3R_TimeBound_1305_99_100()) return true; + if (jj_3R_100()) return true; } return false; } - static private boolean jj_3R_ExpressionStrategyCoalitionList_2070_10_248() + static private boolean jj_3R_231() { - if (jj_scan_token(COLON)) return true; - if (jj_3R_ExpressionStrategyCoalition_2083_9_247()) return true; + if (jj_3R_152()) return true; return false; } - static private boolean jj_3R_TimeBound_1305_9_81() + static private boolean jj_3R_81() { Token xsp; xsp = jj_scanpos; - if (jj_3R_TimeBound_1305_11_89()) { + if (jj_3R_89()) { jj_scanpos = xsp; - if (jj_3R_TimeBound_1306_11_90()) { + if (jj_3R_90()) { jj_scanpos = xsp; - if (jj_3R_TimeBound_1307_11_91()) { + if (jj_3R_91()) { jj_scanpos = xsp; - if (jj_3R_TimeBound_1308_11_92()) { + if (jj_3R_92()) { jj_scanpos = xsp; - if (jj_3R_TimeBound_1309_11_93()) { + if (jj_3R_93()) { jj_scanpos = xsp; - if (jj_3R_TimeBound_1310_11_94()) return true; + if (jj_3R_94()) return true; } } } @@ -5983,7 +6031,13 @@ static private boolean jj_3R_TimeBound_1305_9_81() return false; } - static private boolean jj_3R_ExpressionProb_1669_26_239() + static private boolean jj_3R_283() + { + if (jj_3R_43()) return true; + return false; + } + + static private boolean jj_3R_239() { if (jj_scan_token(MAX)) return true; if (jj_scan_token(EQ)) return true; @@ -5991,28 +6045,31 @@ static private boolean jj_3R_ExpressionProb_1669_26_239() return false; } - static private boolean jj_3R_ExpressionStrategyCoalitionList_2069_9_230() + static private boolean jj_3R_191() { - if (jj_3R_ExpressionStrategyCoalition_2083_9_247()) return true; Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_ExpressionStrategyCoalitionList_2070_10_248()) { jj_scanpos = xsp; break; } + xsp = jj_scanpos; + if (jj_3R_231()) { + jj_scanpos = xsp; + if (jj_3R_232()) { + jj_scanpos = xsp; + if (jj_3R_233()) return true; + } } return false; } - static private boolean jj_3R_UpdateElement_920_9_45() + static private boolean jj_3R_45() { if (jj_scan_token(LPARENTH)) return true; - if (jj_3R_IdentifierPrime_2191_9_53()) return true; + if (jj_3R_53()) return true; if (jj_scan_token(EQ)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; if (jj_scan_token(RPARENTH)) return true; return false; } - static private boolean jj_3R_ExpressionProb_1668_26_238() + static private boolean jj_3R_238() { if (jj_scan_token(MIN)) return true; if (jj_scan_token(EQ)) return true; @@ -6020,14 +6077,22 @@ static private boolean jj_3R_ExpressionProb_1668_26_238() return false; } - static private boolean jj_3R_ExpressionProb_1667_26_237() + static private boolean jj_3R_237() { if (jj_scan_token(EQ)) return true; if (jj_scan_token(QMARK)) return true; return false; } - static private boolean jj_3R_ExpressionProb_1682_10_178() + static private boolean jj_3R_190() + { + if (jj_scan_token(DLBRACKET)) return true; + if (jj_3R_230()) return true; + if (jj_scan_token(DRBRACKET)) return true; + return false; + } + + static private boolean jj_3R_178() { if (jj_scan_token(PMAXMAX)) return true; if (jj_scan_token(EQ)) return true; @@ -6035,13 +6100,13 @@ static private boolean jj_3R_ExpressionProb_1682_10_178() return false; } - static private boolean jj_3R_ExpressionTemporalUnary_1292_17_66() + static private boolean jj_3R_66() { - if (jj_3R_ExpressionITE_1322_9_80()) return true; + if (jj_3R_80()) return true; return false; } - static private boolean jj_3R_ExpressionProb_1665_26_236() + static private boolean jj_3R_236() { if (jj_scan_token(MAX)) return true; if (jj_scan_token(EQ)) return true; @@ -6049,7 +6114,7 @@ static private boolean jj_3R_ExpressionProb_1665_26_236() return false; } - static private boolean jj_3R_ExpressionProb_1674_17_211() + static private boolean jj_3R_211() { if (jj_scan_token(MAXMAX)) return true; if (jj_scan_token(EQ)) return true; @@ -6057,7 +6122,15 @@ static private boolean jj_3R_ExpressionProb_1674_17_211() return false; } - static private boolean jj_3R_ExpressionProb_1681_10_177() + static private boolean jj_3R_189() + { + if (jj_scan_token(DLT)) return true; + if (jj_3R_230()) return true; + if (jj_scan_token(DGT)) return true; + return false; + } + + static private boolean jj_3R_177() { if (jj_scan_token(PMAXMIN)) return true; if (jj_scan_token(EQ)) return true; @@ -6065,7 +6138,7 @@ static private boolean jj_3R_ExpressionProb_1681_10_177() return false; } - static private boolean jj_3R_ExpressionProb_1664_26_235() + static private boolean jj_3R_235() { if (jj_scan_token(MIN)) return true; if (jj_scan_token(EQ)) return true; @@ -6073,7 +6146,7 @@ static private boolean jj_3R_ExpressionProb_1664_26_235() return false; } - static private boolean jj_3R_ExpressionProb_1673_17_210() + static private boolean jj_3R_210() { if (jj_scan_token(MAXMIN)) return true; if (jj_scan_token(EQ)) return true; @@ -6081,7 +6154,7 @@ static private boolean jj_3R_ExpressionProb_1673_17_210() return false; } - static private boolean jj_3R_ExpressionProb_1680_10_176() + static private boolean jj_3R_176() { if (jj_scan_token(PMINMAX)) return true; if (jj_scan_token(EQ)) return true; @@ -6089,20 +6162,20 @@ static private boolean jj_3R_ExpressionProb_1680_10_176() return false; } - static private boolean jj_3R_ExpressionTemporalUnary_1288_19_79() + static private boolean jj_3R_79() { - if (jj_3R_TimeBound_1305_9_81()) return true; + if (jj_3R_81()) return true; return false; } - static private boolean jj_3R_ExpressionProb_1663_26_234() + static private boolean jj_3R_234() { if (jj_scan_token(EQ)) return true; if (jj_scan_token(QMARK)) return true; return false; } - static private boolean jj_3R_ExpressionProb_1672_17_209() + static private boolean jj_3R_209() { if (jj_scan_token(MINMAX)) return true; if (jj_scan_token(EQ)) return true; @@ -6110,7 +6183,7 @@ static private boolean jj_3R_ExpressionProb_1672_17_209() return false; } - static private boolean jj_3R_ExpressionProb_1679_10_175() + static private boolean jj_3R_175() { if (jj_scan_token(PMINMIN)) return true; if (jj_scan_token(EQ)) return true; @@ -6118,13 +6191,13 @@ static private boolean jj_3R_ExpressionProb_1679_10_175() return false; } - static private boolean jj_3R_ExpressionTemporalUnary_1287_19_78() + static private boolean jj_3R_78() { if (jj_scan_token(G)) return true; return false; } - static private boolean jj_3R_ExpressionProb_1671_17_208() + static private boolean jj_3R_208() { if (jj_scan_token(MINMIN)) return true; if (jj_scan_token(EQ)) return true; @@ -6132,7 +6205,7 @@ static private boolean jj_3R_ExpressionProb_1671_17_208() return false; } - static private boolean jj_3R_ExpressionProb_1678_10_174() + static private boolean jj_3R_174() { if (jj_scan_token(PMAX)) return true; if (jj_scan_token(EQ)) return true; @@ -6140,13 +6213,13 @@ static private boolean jj_3R_ExpressionProb_1678_10_174() return false; } - static private boolean jj_3R_ExpressionTemporalUnary_1286_19_77() + static private boolean jj_3R_77() { if (jj_scan_token(F)) return true; return false; } - static private boolean jj_3R_ExpressionProb_1677_10_173() + static private boolean jj_3R_173() { if (jj_scan_token(PMIN)) return true; if (jj_scan_token(EQ)) return true; @@ -6154,190 +6227,158 @@ static private boolean jj_3R_ExpressionProb_1677_10_173() return false; } - static private boolean jj_3R_ExpressionTemporalUnary_1285_19_76() + static private boolean jj_3R_76() { if (jj_scan_token(X)) return true; return false; } - static private boolean jj_3R_ExpressionProb_1661_25_204() + static private boolean jj_3R_156() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_189()) { + jj_scanpos = xsp; + if (jj_3R_190()) return true; + } + xsp = jj_scanpos; + if (jj_3R_191()) { + jj_scanpos = xsp; + if (jj_3R_192()) return true; + } + return false; + } + + static private boolean jj_3R_204() { - if (jj_3R_LtGt_2220_9_50()) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_50()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionProb_1660_26_203() + static private boolean jj_3R_203() { if (jj_scan_token(LPARENTH)) return true; - if (jj_3R_IdentifierExpression_2169_9_37()) return true; + if (jj_3R_37()) return true; if (jj_scan_token(RPARENTH)) return true; return false; } - static private boolean jj_3R_ExpressionProb_1667_17_207() + static private boolean jj_3R_207() { if (jj_scan_token(MAX)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionProb_1667_26_237()) { + if (jj_3R_237()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1668_26_238()) { + if (jj_3R_238()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1669_26_239()) return true; + if (jj_3R_239()) return true; } } return false; } - static private boolean jj_3R_Update_907_10_39() + static private boolean jj_3R_39() { - if (jj_3R_UpdateElement_920_9_45()) return true; + if (jj_3R_45()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_Update_907_36_46()) { jj_scanpos = xsp; break; } + if (jj_3R_46()) { jj_scanpos = xsp; break; } } return false; } - static private boolean jj_3R_ExpressionTemporalUnary_1283_17_65() + static private boolean jj_3R_65() { Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionTemporalUnary_1285_19_76()) { + if (jj_3R_76()) { jj_scanpos = xsp; - if (jj_3R_ExpressionTemporalUnary_1286_19_77()) { + if (jj_3R_77()) { jj_scanpos = xsp; - if (jj_3R_ExpressionTemporalUnary_1287_19_78()) return true; + if (jj_3R_78()) return true; } } xsp = jj_scanpos; - if (jj_3R_ExpressionTemporalUnary_1288_19_79()) jj_scanpos = xsp; - if (jj_3R_ExpressionTemporalUnary_1281_9_60()) return true; + if (jj_3R_79()) jj_scanpos = xsp; + if (jj_3R_60()) return true; return false; } static private boolean jj_3_5() { - if (jj_3R_Update_905_9_35()) return true; + if (jj_3R_35()) return true; return false; } - static private boolean jj_3R_ExpressionProb_1663_17_206() + static private boolean jj_3R_206() { if (jj_scan_token(MIN)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionProb_1663_26_234()) { + if (jj_3R_234()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1664_26_235()) { + if (jj_3R_235()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1665_26_236()) return true; + if (jj_3R_236()) return true; } } return false; } - static private boolean jj_3R_ExpressionStrategy_2052_11_192() - { - if (jj_3R_ExpressionParenth_1634_9_151()) return true; - return false; - } - - static private boolean jj_3R_Update_905_9_35() + static private boolean jj_3R_35() { Token xsp; xsp = jj_scanpos; - if (jj_3R_Update_907_10_39()) { + if (jj_3R_39()) { jj_scanpos = xsp; - if (jj_scan_token(76)) return true; + if (jj_scan_token(80)) return true; } return false; } - static private boolean jj_3R_ExpressionProb_1662_17_205() + static private boolean jj_3R_205() { if (jj_scan_token(EQ)) return true; if (jj_scan_token(QMARK)) return true; return false; } - static private boolean jj_3R_ExpressionStrategy_2050_11_231() - { - if (jj_3R_ExpressionProb_1658_9_152()) return true; - return false; - } - - static private boolean jj_3R_MultiNashRewardIndexes_1986_73_277() - { - if (jj_3R_Expression_1229_9_43()) return true; - return false; - } - - static private boolean jj_3R_ExpressionStrategy_2050_9_191() + static private boolean jj_3R_60() { Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionStrategy_2050_11_231()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionStrategy_2050_51_232()) { + if (jj_3R_65()) { jj_scanpos = xsp; - if (jj_3R_ExpressionStrategy_2050_93_233()) return true; - } + if (jj_3R_66()) return true; } return false; } - static private boolean jj_3R_ExpressionStrategy_2046_11_190() - { - if (jj_scan_token(DLBRACKET)) return true; - if (jj_3R_ExpressionStrategyCoalitionList_2069_9_230()) return true; - if (jj_scan_token(DRBRACKET)) return true; - return false; - } - - static private boolean jj_3R_ExpressionTemporalUnary_1281_9_60() - { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_ExpressionTemporalUnary_1283_17_65()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionTemporalUnary_1292_17_66()) return true; - } - return false; - } - - static private boolean jj_3R_ExpressionStrategy_2045_10_189() - { - if (jj_scan_token(DLT)) return true; - if (jj_3R_ExpressionStrategyCoalitionList_2069_9_230()) return true; - if (jj_scan_token(DGT)) return true; - return false; - } - - static private boolean jj_3R_ExpressionProb_1660_10_172() + static private boolean jj_3R_172() { if (jj_scan_token(P)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionProb_1660_26_203()) jj_scanpos = xsp; + if (jj_3R_203()) jj_scanpos = xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionProb_1661_25_204()) { + if (jj_3R_204()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1662_17_205()) { + if (jj_3R_205()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1663_17_206()) { + if (jj_3R_206()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1667_17_207()) { + if (jj_3R_207()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1671_17_208()) { + if (jj_3R_208()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1672_17_209()) { + if (jj_3R_209()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1673_17_210()) { + if (jj_3R_210()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1674_17_211()) return true; + if (jj_3R_211()) return true; } } } @@ -6348,57 +6389,41 @@ static private boolean jj_3R_ExpressionProb_1660_10_172() return false; } - static private boolean jj_3R_ExpressionTemporalBinary_1267_19_70() + static private boolean jj_3R_70() { - if (jj_3R_TimeBound_1305_9_81()) return true; + if (jj_3R_81()) return true; return false; } - static private boolean jj_3R_ExpressionTemporalBinary_1266_19_69() + static private boolean jj_3R_69() { if (jj_scan_token(R)) return true; return false; } - static private boolean jj_3R_ExpressionStrategy_2042_9_156() - { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_ExpressionStrategy_2045_10_189()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionStrategy_2046_11_190()) return true; - } - xsp = jj_scanpos; - if (jj_3R_ExpressionStrategy_2050_9_191()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionStrategy_2052_11_192()) return true; - } - return false; - } - - static private boolean jj_3R_ExpressionTemporalBinary_1265_19_68() + static private boolean jj_3R_68() { if (jj_scan_token(W)) return true; return false; } - static private boolean jj_3R_ExpressionProb_1658_9_152() + static private boolean jj_3R_152() { Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionProb_1660_10_172()) { + if (jj_3R_172()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1677_10_173()) { + if (jj_3R_173()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1678_10_174()) { + if (jj_3R_174()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1679_10_175()) { + if (jj_3R_175()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1680_10_176()) { + if (jj_3R_176()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1681_10_177()) { + if (jj_3R_177()) { jj_scanpos = xsp; - if (jj_3R_ExpressionProb_1682_10_178()) return true; + if (jj_3R_178()) return true; } } } @@ -6406,339 +6431,380 @@ static private boolean jj_3R_ExpressionProb_1658_9_152() } } if (jj_scan_token(LBRACKET)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; xsp = jj_scanpos; - if (jj_3R_ExpressionProb_1684_51_179()) jj_scanpos = xsp; + if (jj_3R_179()) jj_scanpos = xsp; if (jj_scan_token(RBRACKET)) return true; return false; } - static private boolean jj_3R_ExpressionTemporalBinary_1264_19_67() + static private boolean jj_3R_155() + { + if (jj_scan_token(A)) return true; + if (jj_scan_token(LBRACKET)) return true; + if (jj_3R_43()) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + static private boolean jj_3R_67() { if (jj_scan_token(U)) return true; return false; } - static private boolean jj_3R_ExpressionTemporalBinary_1262_17_61() + static private boolean jj_3R_61() { Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionTemporalBinary_1264_19_67()) { + if (jj_3R_67()) { jj_scanpos = xsp; - if (jj_3R_ExpressionTemporalBinary_1265_19_68()) { + if (jj_3R_68()) { jj_scanpos = xsp; - if (jj_3R_ExpressionTemporalBinary_1266_19_69()) return true; + if (jj_3R_69()) return true; } } xsp = jj_scanpos; - if (jj_3R_ExpressionTemporalBinary_1267_19_70()) jj_scanpos = xsp; - if (jj_3R_ExpressionTemporalUnary_1281_9_60()) return true; + if (jj_3R_70()) jj_scanpos = xsp; + if (jj_3R_60()) return true; return false; } - static private boolean jj_3R_ExpressionFuncArgs_1584_72_202() + static private boolean jj_3R_202() { if (jj_scan_token(COMMA)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionFuncOldStyle_1572_83_171() + static private boolean jj_3R_171() { - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; return false; } - static private boolean jj_3R_ExpressionTemporalBinary_1259_9_51() + static private boolean jj_3R_270() { - if (jj_3R_ExpressionTemporalUnary_1281_9_60()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_ExpressionTemporalBinary_1262_17_61()) jj_scanpos = xsp; + if (jj_scan_token(EQ)) return true; + if (jj_scan_token(QMARK)) return true; return false; } - static private boolean jj_3R_ExpressionMultiNash_1910_122_268() + static private boolean jj_3R_268() { if (jj_scan_token(EQ)) return true; if (jj_scan_token(QMARK)) return true; return false; } - static private boolean jj_3R_ExpressionForAll_2022_9_155() + static private boolean jj_3R_51() { - if (jj_scan_token(A)) return true; - if (jj_scan_token(LBRACKET)) return true; - if (jj_3R_Expression_1229_9_43()) return true; - if (jj_scan_token(RBRACKET)) return true; + if (jj_3R_60()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_61()) jj_scanpos = xsp; return false; } - static private boolean jj_3R_ExpressionMultiNash_1908_122_266() + static private boolean jj_3R_154() { - if (jj_scan_token(EQ)) return true; - if (jj_scan_token(QMARK)) return true; + if (jj_scan_token(E)) return true; + if (jj_scan_token(LBRACKET)) return true; + if (jj_3R_43()) return true; + if (jj_scan_token(RBRACKET)) return true; return false; } - static private boolean jj_3R_ExpressionParenth_1634_9_151() + static private boolean jj_3R_151() { if (jj_scan_token(LPARENTH)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; if (jj_scan_token(RPARENTH)) return true; return false; } - static private boolean jj_3R_ExpressionFuncOldStyle_1572_60_170() + static private boolean jj_3_19() { - if (jj_scan_token(MAX)) return true; + if (jj_scan_token(DQUOTE)) return true; return false; } - static private boolean jj_3R_ExpressionLiteral_1621_9_162() + static private boolean jj_3R_282() { - if (jj_scan_token(FALSE)) return true; + if (jj_scan_token(DQUOTE)) return true; + if (jj_3R_34()) return true; + if (jj_scan_token(DQUOTE)) return true; return false; } - static private boolean jj_3R_ExpressionExists_2003_9_154() + static private boolean jj_3R_170() { - if (jj_scan_token(E)) return true; - if (jj_scan_token(LBRACKET)) return true; - if (jj_3R_Expression_1229_9_43()) return true; - if (jj_scan_token(RBRACKET)) return true; + if (jj_scan_token(MAX)) return true; return false; } - static private boolean jj_3R_ExpressionLiteral_1619_9_161() + static private boolean jj_3R_281() { - if (jj_scan_token(TRUE)) return true; + if (jj_scan_token(LBRACE)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_282()) { + jj_scanpos = xsp; + if (jj_3R_283()) return true; + } + if (jj_scan_token(RBRACE)) return true; return false; } - static private boolean jj_3_19() + static private boolean jj_3R_162() { - if (jj_scan_token(DQUOTE)) return true; + if (jj_scan_token(FALSE)) return true; return false; } - static private boolean jj_3R_Expression_1229_9_43() + static private boolean jj_3R_161() { - if (jj_3R_ExpressionTemporalBinary_1259_9_51()) return true; + if (jj_scan_token(TRUE)) return true; return false; } - static private boolean jj_3R_ExpressionLiteral_1608_9_160() + static private boolean jj_3R_43() { - if (jj_scan_token(REG_DOUBLE)) return true; + if (jj_3R_51()) return true; return false; } - static private boolean jj_3R_SystemHideRename_1151_81_95() + static private boolean jj_3R_160() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_scan_token(REG_DOUBLE)) return true; return false; } - static private boolean jj_3R_MultiNashRewardIndexes_1986_10_276() + static private boolean jj_3R_95() { - if (jj_scan_token(DQUOTE)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; - if (jj_scan_token(DQUOTE)) return true; + if (jj_scan_token(COMMA)) return true; + if (jj_3R_34()) return true; return false; } - static private boolean jj_3R_MultiNashRewardIndexes_1985_9_275() + static private boolean jj_3R_272() { - if (jj_scan_token(LBRACE)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_MultiNashRewardIndexes_1986_10_276()) { - jj_scanpos = xsp; - if (jj_3R_MultiNashRewardIndexes_1986_73_277()) return true; - } - if (jj_scan_token(RBRACE)) return true; + if (jj_scan_token(R)) return true; + if (jj_3R_281()) return true; + if (jj_scan_token(LBRACKET)) return true; + if (jj_3R_187()) return true; + if (jj_scan_token(RBRACKET)) return true; return false; } - static private boolean jj_3R_ExpressionFuncOldStyle_1572_37_169() + static private boolean jj_3R_169() { if (jj_scan_token(MIN)) return true; return false; } - static private boolean jj_3R_ExpressionLiteral_1595_9_159() + static private boolean jj_3R_159() { if (jj_scan_token(REG_INT)) return true; return false; } - static private boolean jj_3R_ExpressionLiteral_1594_9_147() + static private boolean jj_3R_147() { Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionLiteral_1595_9_159()) { + if (jj_3R_159()) { jj_scanpos = xsp; - if (jj_3R_ExpressionLiteral_1608_9_160()) { + if (jj_3R_160()) { jj_scanpos = xsp; - if (jj_3R_ExpressionLiteral_1619_9_161()) { + if (jj_3R_161()) { jj_scanpos = xsp; - if (jj_3R_ExpressionLiteral_1621_9_162()) return true; + if (jj_3R_162()) return true; } } } return false; } - static private boolean jj_3R_ExpressionFuncMinMax_1558_42_167() + static private boolean jj_3R_167() { if (jj_scan_token(MAX)) return true; return false; } - static private boolean jj_3R_ExpressionFuncArgs_1584_9_168() + static private boolean jj_3R_168() { - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_ExpressionFuncArgs_1584_72_202()) { jj_scanpos = xsp; break; } + if (jj_3R_202()) { jj_scanpos = xsp; break; } } return false; } - static private boolean jj_3R_ExpressionMultiNashReward_1965_9_270() + static private boolean jj_3R_271() { - if (jj_scan_token(R)) return true; - if (jj_3R_MultiNashRewardIndexes_1985_9_275()) return true; + if (jj_scan_token(P)) return true; if (jj_scan_token(LBRACKET)) return true; - if (jj_3R_ExpressionRewardContents_1872_9_187()) return true; + if (jj_3R_43()) return true; if (jj_scan_token(RBRACKET)) return true; return false; } - static private boolean jj_3R_RewardIndex_1841_125_252() + static private boolean jj_3R_252() { - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionFuncOldStyle_1572_9_150() + static private boolean jj_3R_150() { if (jj_scan_token(FUNC)) return true; if (jj_scan_token(LPARENTH)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionFuncOldStyle_1572_37_169()) { + if (jj_3R_169()) { jj_scanpos = xsp; - if (jj_3R_ExpressionFuncOldStyle_1572_60_170()) { + if (jj_3R_170()) { jj_scanpos = xsp; - if (jj_3R_ExpressionFuncOldStyle_1572_83_171()) return true; + if (jj_3R_171()) return true; } } if (jj_scan_token(COMMA)) return true; - if (jj_3R_ExpressionFuncArgs_1584_9_168()) return true; + if (jj_3R_168()) return true; if (jj_scan_token(RPARENTH)) return true; return false; } - static private boolean jj_3R_SystemAtomic_1181_10_84() + static private boolean jj_3R_280() + { + if (jj_scan_token(FAIR)) return true; + return false; + } + + static private boolean jj_3R_279() + { + if (jj_scan_token(SWEQ)) return true; + return false; + } + + static private boolean jj_3R_84() { if (jj_scan_token(LPARENTH)) return true; - if (jj_3R_SystemDefn_1058_9_36()) return true; + if (jj_3R_36()) return true; if (jj_scan_token(RPARENTH)) return true; return false; } - static private boolean jj_3R_SystemAtomic_1179_10_83() + static private boolean jj_3R_278() { - if (jj_scan_token(DQUOTE)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; - if (jj_scan_token(DQUOTE)) return true; + if (jj_scan_token(CORR)) return true; return false; } - static private boolean jj_3R_ExpressionMultiNashProb_1943_9_269() + static private boolean jj_3R_277() { - if (jj_scan_token(P)) return true; - if (jj_scan_token(LBRACKET)) return true; - if (jj_3R_Expression_1229_9_43()) return true; - if (jj_scan_token(RBRACKET)) return true; + if (jj_scan_token(NASH)) return true; return false; } - static private boolean jj_3R_ExpressionFuncMinMax_1558_11_166() + static private boolean jj_3R_266() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_277()) { + jj_scanpos = xsp; + if (jj_3R_278()) { + jj_scanpos = xsp; + if (jj_3R_279()) { + jj_scanpos = xsp; + if (jj_3R_280()) return true; + } + } + } + return false; + } + + static private boolean jj_3R_83() + { + if (jj_scan_token(DQUOTE)) return true; + if (jj_3R_34()) return true; + if (jj_scan_token(DQUOTE)) return true; + return false; + } + + static private boolean jj_3R_166() { if (jj_scan_token(MIN)) return true; return false; } - static private boolean jj_3R_SystemAtomic_1177_9_82() + static private boolean jj_3R_82() { - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; return false; } - static private boolean jj_3R_SystemParallel_1121_65_75() + static private boolean jj_3R_75() { if (jj_scan_token(COMMA)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; + return false; + } + + static private boolean jj_3R_274() + { + if (jj_3R_272()) return true; return false; } - static private boolean jj_3R_ExpressionFuncMinMax_1558_9_149() + static private boolean jj_3R_273() + { + if (jj_3R_271()) return true; + return false; + } + + static private boolean jj_3R_149() { Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionFuncMinMax_1558_11_166()) { + if (jj_3R_166()) { jj_scanpos = xsp; - if (jj_3R_ExpressionFuncMinMax_1558_42_167()) return true; + if (jj_3R_167()) return true; } if (jj_scan_token(LPARENTH)) return true; - if (jj_3R_ExpressionFuncArgs_1584_9_168()) return true; + if (jj_3R_168()) return true; if (jj_scan_token(RPARENTH)) return true; return false; } - static private boolean jj_3R_SystemAtomic_1174_9_73() + static private boolean jj_3R_73() { Token xsp; xsp = jj_scanpos; - if (jj_3R_SystemAtomic_1177_9_82()) { + if (jj_3R_82()) { jj_scanpos = xsp; - if (jj_3R_SystemAtomic_1179_10_83()) { + if (jj_3R_83()) { jj_scanpos = xsp; - if (jj_3R_SystemAtomic_1181_10_84()) return true; + if (jj_3R_84()) return true; } } return false; } - static private boolean jj_3R_RewardIndex_1846_101_263() - { - if (jj_3R_Expression_1229_9_43()) return true; - return false; - } - - static private boolean jj_3R_ExpressionMultiNash_1921_25_272() - { - if (jj_3R_ExpressionMultiNashReward_1965_9_270()) return true; - return false; - } - - static private boolean jj_3R_ExpressionMultiNash_1919_26_271() + static private boolean jj_3R_264() { - if (jj_3R_ExpressionMultiNashProb_1943_9_269()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_SystemHideRename_1158_19_96() + static private boolean jj_3R_96() { if (jj_scan_token(COMMA)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; if (jj_scan_token(RENAME)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; return false; } @@ -6750,91 +6816,98 @@ static private boolean jj_3_9() return false; } - static private boolean jj_3R_ExpressionFuncOrIdent_1545_11_165() - { - if (jj_scan_token(LPARENTH)) return true; - if (jj_3R_ExpressionFuncArgs_1584_9_168()) return true; - if (jj_scan_token(RPARENTH)) return true; - return false; - } - - static private boolean jj_3R_ExpressionMultiNash_1918_18_261() + static private boolean jj_3R_262() { if (jj_scan_token(PLUS)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionMultiNash_1919_26_271()) { + if (jj_3R_273()) { jj_scanpos = xsp; - if (jj_3R_ExpressionMultiNash_1921_25_272()) return true; + if (jj_3R_274()) return true; } return false; } - static private boolean jj_3R_ExpressionFuncOrIdent_1542_11_164() + static private boolean jj_3R_165() { - if (jj_3R_IdentifierPrime_2191_9_53()) return true; + if (jj_scan_token(LPARENTH)) return true; + if (jj_3R_168()) return true; + if (jj_scan_token(RPARENTH)) return true; + return false; + } + + static private boolean jj_3R_261() + { + if (jj_3R_272()) return true; return false; } - static private boolean jj_3R_ExpressionFuncOrIdent_1541_11_163() + static private boolean jj_3R_260() { - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_271()) return true; return false; } - static private boolean jj_3R_ExpressionMultiNash_1916_17_260() + static private boolean jj_3R_164() { - if (jj_3R_ExpressionMultiNashReward_1965_9_270()) return true; + if (jj_3R_53()) return true; return false; } - static private boolean jj_3R_ExpressionMultiNash_1914_18_259() + static private boolean jj_3R_163() { - if (jj_3R_ExpressionMultiNashProb_1943_9_269()) return true; + if (jj_3R_34()) return true; return false; } - static private boolean jj_3R_SystemInterleaved_1096_70_55() + static private boolean jj_3R_55() { if (jj_scan_token(OR)) return true; if (jj_scan_token(OR)) return true; if (jj_scan_token(OR)) return true; - if (jj_3R_SystemFullParallel_1071_9_40()) return true; + if (jj_3R_40()) return true; return false; } - static private boolean jj_3R_SystemHideRename_1155_11_86() + static private boolean jj_3R_86() { if (jj_scan_token(LBRACE)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; if (jj_scan_token(RENAME)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_SystemHideRename_1158_19_96()) { jj_scanpos = xsp; break; } + if (jj_3R_96()) { jj_scanpos = xsp; break; } } if (jj_scan_token(RBRACE)) return true; return false; } - static private boolean jj_3R_ExpressionFuncOrIdent_1540_9_148() + static private boolean jj_3R_148() { Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionFuncOrIdent_1541_11_163()) { + if (jj_3R_163()) { jj_scanpos = xsp; - if (jj_3R_ExpressionFuncOrIdent_1542_11_164()) return true; + if (jj_3R_164()) return true; } xsp = jj_scanpos; - if (jj_3R_ExpressionFuncOrIdent_1545_11_165()) jj_scanpos = xsp; + if (jj_3R_165()) jj_scanpos = xsp; + return false; + } + + static private boolean jj_3R_269() + { + if (jj_3R_50()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionMultiNash_1910_16_267() + static private boolean jj_3R_267() { - if (jj_3R_LtGt_2220_9_50()) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_50()) return true; + if (jj_3R_43()) return true; return false; } @@ -6844,34 +6917,51 @@ static private boolean jj_3_4() return false; } - static private boolean jj_3R_ExpressionMultiNash_1908_16_265() + static private boolean jj_3R_259() { - if (jj_3R_LtGt_2220_9_50()) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_scan_token(MAX)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_269()) { + jj_scanpos = xsp; + if (jj_3R_270()) return true; + } return false; } - static private boolean jj_3R_SystemHideRename_1149_9_85() + static private boolean jj_3R_85() { if (jj_scan_token(DIVIDE)) return true; if (jj_scan_token(LBRACE)) return true; - if (jj_3R_Identifier_2158_9_34()) return true; + if (jj_3R_34()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_SystemHideRename_1151_81_95()) { jj_scanpos = xsp; break; } + if (jj_3R_95()) { jj_scanpos = xsp; break; } } if (jj_scan_token(RBRACE)) return true; return false; } - static private boolean jj_3R_SystemHideRename_1149_9_74() + static private boolean jj_3R_74() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_85()) { + jj_scanpos = xsp; + if (jj_3R_86()) return true; + } + return false; + } + + static private boolean jj_3R_258() { + if (jj_scan_token(MIN)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_SystemHideRename_1149_9_85()) { + if (jj_3R_267()) { jj_scanpos = xsp; - if (jj_3R_SystemHideRename_1155_11_86()) return true; + if (jj_3R_268()) return true; } return false; } @@ -6883,13 +6973,13 @@ static private boolean jj_3_3() return false; } - static private boolean jj_3R_SystemHideRename_1146_9_63() + static private boolean jj_3R_63() { - if (jj_3R_SystemAtomic_1174_9_73()) return true; + if (jj_3R_73()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_SystemHideRename_1149_9_74()) { jj_scanpos = xsp; break; } + if (jj_3R_74()) { jj_scanpos = xsp; break; } } return false; } @@ -6901,70 +6991,84 @@ static private boolean jj_3_8() return false; } - static private boolean jj_3R_ExpressionMultiNash_1910_9_258() + static private boolean jj_3R_257() { - if (jj_scan_token(MAX)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_ExpressionMultiNash_1910_16_267()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionMultiNash_1910_122_268()) return true; - } + if (jj_scan_token(LBRACE)) return true; + if (jj_3R_266()) return true; + if (jj_scan_token(COMMA)) return true; + if (jj_3R_266()) return true; + if (jj_scan_token(RBRACE)) return true; return false; } - static private boolean jj_3R_ExpressionMultiNash_1908_9_257() + static private boolean jj_3R_249() { - if (jj_scan_token(MIN)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_ExpressionMultiNash_1908_16_265()) { + if (jj_3R_257()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_258()) { + jj_scanpos = xsp; + if (jj_3R_259()) return true; + } + if (jj_scan_token(LPARENTH)) return true; + xsp = jj_scanpos; + if (jj_3R_260()) { jj_scanpos = xsp; - if (jj_3R_ExpressionMultiNash_1908_122_266()) return true; + if (jj_3R_261()) return true; } + if (jj_3R_262()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_262()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(RPARENTH)) return true; return false; } - static private boolean jj_3R_ExpressionBasic_1517_17_146() + static private boolean jj_3R_146() { - if (jj_3R_ExpressionFilter_2131_9_158()) return true; + if (jj_3R_158()) return true; return false; } - static private boolean jj_3R_RewardIndex_1841_75_251() + static private boolean jj_3R_251() { if (jj_scan_token(DISCOUNT)) return true; if (jj_scan_token(EQ)) return true; - if (jj_3R_Expression_1229_9_43()) return true; + if (jj_3R_43()) return true; return false; } - static private boolean jj_3R_ExpressionMultiNash_1906_9_249() + static private boolean jj_3R_145() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_ExpressionMultiNash_1908_9_257()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionMultiNash_1910_9_258()) return true; - } - if (jj_scan_token(LPARENTH)) return true; - xsp = jj_scanpos; - if (jj_3R_ExpressionMultiNash_1914_18_259()) { - jj_scanpos = xsp; - if (jj_3R_ExpressionMultiNash_1916_17_260()) return true; - } - if (jj_3R_ExpressionMultiNash_1918_18_261()) return true; - while (true) { - xsp = jj_scanpos; - if (jj_3R_ExpressionMultiNash_1918_18_261()) { jj_scanpos = xsp; break; } - } - if (jj_scan_token(RPARENTH)) return true; + if (jj_3R_157()) return true; + return false; + } + + static private boolean jj_3R_144() + { + if (jj_3R_156()) return true; + return false; + } + + static private boolean jj_3R_143() + { + if (jj_3R_155()) return true; + return false; + } + + static private boolean jj_3R_48() + { + if (jj_scan_token(OR)) return true; + if (jj_scan_token(OR)) return true; + if (jj_3R_54()) return true; return false; } - static private boolean jj_3R_ExpressionBasic_1515_17_145() + static private boolean jj_3R_142() { - if (jj_3R_ExpressionLabel_2113_9_157()) return true; + if (jj_3R_154()) return true; return false; } @@ -6980,212 +7084,199 @@ static private boolean jj_3R_ExpressionBasic_1515_17_145() static private Token jj_scanpos, jj_lastpos; static private int jj_la; static private int jj_gen; - static final private int[] jj_la1 = new int[119]; + static final private int[] jj_la1 = new int[121]; static private int[] jj_la1_0; static private int[] jj_la1_1; static private int[] jj_la1_2; static private int[] jj_la1_3; static { - jj_la1_init_0(); - jj_la1_init_1(); - jj_la1_init_2(); - jj_la1_init_3(); - } - private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0xa08023c0,0x208023c0,0x80000000,0x3404048,0x0,0x3404048,0x3404048,0x0,0x3404048,0x2000,0x0,0x100,0x2380,0x1010,0x1010,0x0,0x40,0x0,0x80000000,0x30,0x0,0x0,0x0,0x0,0x47404008,0x0,0x0,0x0,0x47404008,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x44000000,0x0,0x47404008,0x47404008,0x47404008,0x47404008,0x47404008,0x0,0x0,0x0,0x0,0x0,0x0,0x3404008,0x0,0x0,0x0,0x0,0x0,0x0,0x3404008,0x3404008,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x47404808,0x0,0x47404008,0x0,0x0,0x5f404408,0x0,0x0,0x0,0x0,0x0,0x0,0x47404008,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,}; - } - private static void jj_la1_init_1() { - jj_la1_1 = new int[] {0x7f80e888,0x3f002088,0x4080c800,0xa87f0448,0x0,0xa87f0448,0xa87f0448,0x0,0xa87f0448,0x4000000,0x2080,0x0,0x17002080,0x4,0x4,0x28000000,0x28000000,0x0,0x0,0x4,0x0,0x1,0x0,0x0,0x807f1440,0x0,0x0,0x0,0x807f1440,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x807f1440,0x807f1440,0x807f1440,0x807f1440,0x807f1440,0x0,0x0,0x0,0x0,0x0,0x0,0x807f0440,0x0,0x0,0x0,0x0,0x0,0x0,0x807f0440,0x807f0440,0x0,0x0,0x440,0x440,0x0,0x0,0x0,0x440,0x440,0x770,0x7f0000,0x0,0x0,0x440,0x0,0x0,0x0,0x0,0x0,0x440,0x440,0x770,0x80000000,0x0,0x807f1440,0x0,0x807f1440,0x0,0x0,0x807f1442,0x0,0x0,0x440,0x400000,0x400000,0x0,0x807f1440,0x0,0x807f0440,0x807f0440,0x0,0x0,0x0,0x0,0x0,0x0,0x440,0x0,0x440,0x0,0x0,0x0,}; - } - private static void jj_la1_init_2() { - jj_la1_2 = new int[] {0xf80,0xb80,0x400,0x2200907f,0x400000,0x2200907f,0x2200907f,0x400000,0x2200907f,0x0,0x0,0x80,0xb80,0x0,0x0,0x0,0x0,0x0,0x0,0x8000000,0x0,0x0,0x8000000,0x0,0x2200907f,0x10000,0x2001000,0x800000,0x2a00907f,0x8000000,0x800000,0x0,0x800000,0x800000,0x80000000,0x800000,0x800000,0x80000000,0x2000000,0x800000,0x8000000,0x8000000,0x6020,0x8000000,0x6020,0x0,0x8000000,0x2200907f,0x2200907f,0x2200907f,0x2200907f,0x2200907f,0x8000000,0x0,0x40000,0x80000,0x20000,0x10000,0x2200907f,0x0,0x0,0x0,0x0,0x0,0x0,0x2200107f,0x2200107f,0x0,0x2000000,0x0,0x0,0x800000,0x1000,0x2000000,0x0,0x0,0x0,0x0,0x80000000,0x80000000,0x0,0x2000000,0x2000000,0x80000000,0x2000000,0x80000000,0x0,0x0,0x0,0x3f,0x80000000,0x2200907f,0x800000,0x2200907f,0x0,0x40,0x2200907f,0x0,0x0,0x0,0x20,0x20,0x0,0x2200907f,0x20000000,0x3f,0x200003f,0x200000,0x800000,0x0,0x0,0x0,0x0,0x30000,0x800000,0x0,0x0,0x0,0x200000,}; - } - private static void jj_la1_init_3() { - jj_la1_3 = new int[] {0x0,0x0,0x0,0x1f0420,0x0,0x1f0420,0x1f0420,0x0,0x1f0420,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x100000,0x0,0x0,0x200,0x1f0420,0x0,0x0,0x0,0x1f0420,0x0,0x0,0x100000,0x0,0x0,0x1000,0x0,0x0,0x1000,0x110000,0x0,0x100000,0x100000,0x0,0x19a,0x0,0x0,0x19a,0x1f0420,0x1f0420,0x1f0420,0x1f0420,0x1f0420,0x19a,0x8000,0x0,0x0,0x0,0x0,0x1f0420,0x6,0x198,0x600,0x600,0x1800,0x1800,0x1f0420,0x1f0020,0x180000,0x0,0x0,0x100000,0x0,0x60000,0x0,0x2,0x2,0x19a,0x0,0x0,0x0,0x0,0x0,0x19a,0x0,0x0,0x0,0x2,0x2,0x19a,0x0,0x0,0x1f0420,0x0,0x1f0420,0x1000,0x0,0x1f0420,0x19a,0x19a,0x0,0x0,0x0,0x200,0x1f0420,0x20,0x0,0x0,0x0,0x0,0x120000,0x800,0x120000,0x100000,0x100200,0x0,0x100000,0x6,0x198,0x0,}; - } + jj_la1_init_0(); + jj_la1_init_1(); + jj_la1_init_2(); + jj_la1_init_3(); + } + private static void jj_la1_init_0() { + jj_la1_0 = new int[] {0x8023c00,0x8023c00,0x0,0x34040480,0x0,0x34040480,0x34040480,0x0,0x34040480,0x20000,0x0,0x1000,0x23800,0x10100,0x10100,0x0,0x400,0x0,0x0,0x300,0x0,0x0,0x0,0x0,0x74040080,0x0,0x0,0x0,0x74040080,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40000000,0x0,0x74040080,0x74040080,0x74040080,0x74040080,0x74040080,0x0,0x0,0x0,0x0,0x0,0x0,0x34040080,0x0,0x0,0x0,0x0,0x0,0x0,0x34040080,0x34040080,0x0,0x0,0x0,0x0,0x0,0x4000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x74048080,0x0,0x74040080,0x0,0x0,0xf4044080,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78,0x74040080,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; + } + private static void jj_la1_init_1() { + jj_la1_1 = new int[] {0xf80e888a,0xf0020882,0x80c8008,0x87f04480,0x0,0x87f04480,0x87f04480,0x0,0x87f04480,0x40000000,0x20800,0x0,0x70020800,0x40,0x40,0x80000000,0x80000000,0x0,0x8,0x40,0x0,0x10,0x0,0x0,0x7f14404,0x0,0x0,0x0,0x7f14404,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10004,0x0,0x7f14404,0x7f14404,0x7f14404,0x7f14404,0x7f14404,0x0,0x0,0x0,0x0,0x0,0x0,0x7f04400,0x0,0x0,0x0,0x0,0x0,0x0,0x7f04400,0x7f04400,0x0,0x0,0x4400,0x4400,0x0,0x0,0x0,0x4400,0x4400,0x7700,0x7f00000,0x0,0x0,0x4400,0x0,0x0,0x0,0x0,0x0,0x4400,0x4400,0x7700,0x0,0x0,0x7f14404,0x0,0x7f14404,0x0,0x0,0x7f14425,0x0,0x0,0x0,0x4400,0x4000000,0x4000000,0x0,0x0,0x7f14404,0x0,0x7f04400,0x7f04400,0x0,0x0,0x0,0x0,0x0,0x8,0x4400,0x0,0x4400,0x0,0x0,0x0,}; + } + private static void jj_la1_init_2() { + jj_la1_2 = new int[] {0xf807,0xb803,0x4004,0x200907fa,0x4000000,0x200907fa,0x200907fa,0x4000000,0x200907fa,0x0,0x0,0x800,0xb801,0x0,0x0,0x2,0x2,0x0,0x0,0x80000000,0x0,0x0,0x80000000,0x0,0x200907f8,0x100000,0x20010000,0x8000000,0xa00907f8,0x80000000,0x8000000,0x0,0x8000000,0x8000000,0x0,0x8000000,0x8000000,0x0,0x20000000,0x8000000,0x80000000,0x80000000,0x60200,0x80000000,0x60200,0x0,0x80000000,0x200907f8,0x200907f8,0x200907f8,0x200907f8,0x200907f8,0x80000000,0x0,0x400000,0x800000,0x200000,0x100000,0x200907f8,0x0,0x0,0x0,0x0,0x0,0x0,0x200107f8,0x200107f8,0x0,0x20000000,0x0,0x0,0x8000000,0x10000,0x20000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000000,0x20000000,0x0,0x20000000,0x0,0x0,0x0,0x0,0x3f8,0x0,0x200907f8,0x8000000,0x200907f8,0x0,0x400,0x200907f8,0x0,0x0,0x0,0x0,0x200,0x200,0x0,0x0,0x200907f8,0x0,0x3f8,0x200003f8,0x2000000,0x8000000,0x0,0x0,0x0,0x0,0x300000,0x8000000,0x0,0x0,0x0,0x2000000,}; + } + private static void jj_la1_init_3() { + jj_la1_3 = new int[] {0x0,0x0,0x0,0x1f04202,0x0,0x1f04202,0x1f04202,0x0,0x1f04202,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20,0x0,0x0,0x1000000,0x0,0x0,0x2000,0x1f04202,0x0,0x0,0x0,0x1f04202,0x0,0x0,0x1000000,0x0,0x0,0x10008,0x0,0x0,0x10008,0x1100000,0x0,0x1000000,0x1000000,0x0,0x19a0,0x0,0x0,0x19a0,0x1f04202,0x1f04202,0x1f04202,0x1f04202,0x1f04202,0x19a0,0x80000,0x0,0x0,0x0,0x0,0x1f04202,0x60,0x1980,0x6000,0x6000,0x18000,0x18000,0x1f04202,0x1f00202,0x1800000,0x0,0x0,0x1000000,0x0,0x600000,0x0,0x20,0x20,0x19a0,0x0,0x8,0x8,0x0,0x0,0x19a0,0x8,0x0,0x8,0x20,0x20,0x19a0,0x0,0x8,0x1f04202,0x0,0x1f04202,0x10000,0x0,0x1f04202,0x8,0x19a0,0x19a0,0x0,0x0,0x0,0x2000,0x0,0x1f04202,0x202,0x8,0x8,0x0,0x0,0x1200000,0x8000,0x1200000,0x1000000,0x1002000,0x0,0x1000000,0x60,0x1980,0x0,}; + } static final private JJCalls[] jj_2_rtns = new JJCalls[19]; static private boolean jj_rescan = false; static private int jj_gc = 0; /** Constructor with InputStream. */ public PrismParser(java.io.InputStream stream) { - this(stream, null); + this(stream, null); } /** Constructor with InputStream and supplied encoding */ public PrismParser(java.io.InputStream stream, String encoding) { - if (jj_initialized_once) { - System.out.println("ERROR: Second call to constructor of static parser. "); - System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false"); - System.out.println(" during parser generation."); - throw new Error(); - } - jj_initialized_once = true; - try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } - token_source = new PrismParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 119; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + if (jj_initialized_once) { + System.out.println("ERROR: Second call to constructor of static parser. "); + System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false"); + System.out.println(" during parser generation."); + throw new Error(); + } + jj_initialized_once = true; + try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } + token_source = new PrismParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 121; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Reinitialise. */ static public void ReInit(java.io.InputStream stream) { - ReInit(stream, null); + ReInit(stream, null); } /** Reinitialise. */ static public void ReInit(java.io.InputStream stream, String encoding) { - try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 119; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 121; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Constructor. */ public PrismParser(java.io.Reader stream) { - if (jj_initialized_once) { - System.out.println("ERROR: Second call to constructor of static parser. "); - System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false"); - System.out.println(" during parser generation."); - throw new Error(); - } - jj_initialized_once = true; - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new PrismParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 119; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + if (jj_initialized_once) { + System.out.println("ERROR: Second call to constructor of static parser. "); + System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false"); + System.out.println(" during parser generation."); + throw new Error(); + } + jj_initialized_once = true; + jj_input_stream = new SimpleCharStream(stream, 1, 1); + token_source = new PrismParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 121; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Reinitialise. */ static public void ReInit(java.io.Reader stream) { - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - } else { - jj_input_stream.ReInit(stream, 1, 1); - } - if (token_source == null) { - token_source = new PrismParserTokenManager(jj_input_stream); - } - - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 119; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + jj_input_stream.ReInit(stream, 1, 1); + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 121; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Constructor with generated Token Manager. */ public PrismParser(PrismParserTokenManager tm) { - if (jj_initialized_once) { - System.out.println("ERROR: Second call to constructor of static parser. "); - System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false"); - System.out.println(" during parser generation."); - throw new Error(); - } - jj_initialized_once = true; - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 119; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + if (jj_initialized_once) { + System.out.println("ERROR: Second call to constructor of static parser. "); + System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false"); + System.out.println(" during parser generation."); + throw new Error(); + } + jj_initialized_once = true; + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 121; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Reinitialise. */ public void ReInit(PrismParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 119; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 121; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } static private Token jj_consume_token(int kind) throws ParseException { - Token oldToken; - if ((oldToken = token).next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - if (token.kind == kind) { - jj_gen++; - if (++jj_gc > 100) { - jj_gc = 0; - for (int i = 0; i < jj_2_rtns.length; i++) { - JJCalls c = jj_2_rtns[i]; - while (c != null) { - if (c.gen < jj_gen) c.first = null; - c = c.next; - } - } - } - return token; - } - token = oldToken; - jj_kind = kind; - throw generateParseException(); + Token oldToken; + if ((oldToken = token).next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + if (token.kind == kind) { + jj_gen++; + if (++jj_gc > 100) { + jj_gc = 0; + for (int i = 0; i < jj_2_rtns.length; i++) { + JJCalls c = jj_2_rtns[i]; + while (c != null) { + if (c.gen < jj_gen) c.first = null; + c = c.next; + } + } + } + return token; + } + token = oldToken; + jj_kind = kind; + throw generateParseException(); } @SuppressWarnings("serial") - static private final class LookaheadSuccess extends java.lang.Error { - @Override - public Throwable fillInStackTrace() { - return this; - } - } - static private final LookaheadSuccess jj_ls = new LookaheadSuccess(); + static private final class LookaheadSuccess extends java.lang.Error { } + static final private LookaheadSuccess jj_ls = new LookaheadSuccess(); static private boolean jj_scan_token(int kind) { - if (jj_scanpos == jj_lastpos) { - jj_la--; - if (jj_scanpos.next == null) { - jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); - } else { - jj_lastpos = jj_scanpos = jj_scanpos.next; - } - } else { - jj_scanpos = jj_scanpos.next; - } - if (jj_rescan) { - int i = 0; Token tok = token; - while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } - if (tok != null) jj_add_error_token(kind, i); - } - if (jj_scanpos.kind != kind) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; - return false; + if (jj_scanpos == jj_lastpos) { + jj_la--; + if (jj_scanpos.next == null) { + jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); + } else { + jj_lastpos = jj_scanpos = jj_scanpos.next; + } + } else { + jj_scanpos = jj_scanpos.next; + } + if (jj_rescan) { + int i = 0; Token tok = token; + while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } + if (tok != null) jj_add_error_token(kind, i); + } + if (jj_scanpos.kind != kind) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; + return false; } /** Get the next Token. */ static final public Token getNextToken() { - if (token.next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - jj_gen++; - return token; + if (token.next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + jj_gen++; + return token; } /** Get the specific Token. */ static final public Token getToken(int index) { - Token t = token; - for (int i = 0; i < index; i++) { - if (t.next != null) t = t.next; - else t = t.next = token_source.getNextToken(); - } - return t; + Token t = token; + for (int i = 0; i < index; i++) { + if (t.next != null) t = t.next; + else t = t.next = token_source.getNextToken(); + } + return t; } static private int jj_ntk_f() { - if ((jj_nt=token.next) == null) - return (jj_ntk = (token.next=token_source.getNextToken()).kind); - else - return (jj_ntk = jj_nt.kind); + if ((jj_nt=token.next) == null) + return (jj_ntk = (token.next=token_source.getNextToken()).kind); + else + return (jj_ntk = jj_nt.kind); } static private java.util.List jj_expentries = new java.util.ArrayList(); @@ -7195,91 +7286,71 @@ static private int jj_ntk_f() { static private int jj_endpos; static private void jj_add_error_token(int kind, int pos) { - if (pos >= 100) { - return; - } - - if (pos == jj_endpos + 1) { - jj_lasttokens[jj_endpos++] = kind; - } else if (jj_endpos != 0) { - jj_expentry = new int[jj_endpos]; - - for (int i = 0; i < jj_endpos; i++) { - jj_expentry[i] = jj_lasttokens[i]; - } - - for (int[] oldentry : jj_expentries) { - if (oldentry.length == jj_expentry.length) { - boolean isMatched = true; - - for (int i = 0; i < jj_expentry.length; i++) { - if (oldentry[i] != jj_expentry[i]) { - isMatched = false; - break; - } - - } - if (isMatched) { - jj_expentries.add(jj_expentry); - break; - } - } - } - - if (pos != 0) { - jj_lasttokens[(jj_endpos = pos) - 1] = kind; - } - } + if (pos >= 100) return; + if (pos == jj_endpos + 1) { + jj_lasttokens[jj_endpos++] = kind; + } else if (jj_endpos != 0) { + jj_expentry = new int[jj_endpos]; + for (int i = 0; i < jj_endpos; i++) { + jj_expentry[i] = jj_lasttokens[i]; + } + jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { + int[] oldentry = (int[])(it.next()); + if (oldentry.length == jj_expentry.length) { + for (int i = 0; i < jj_expentry.length; i++) { + if (oldentry[i] != jj_expentry[i]) { + continue jj_entries_loop; + } + } + jj_expentries.add(jj_expentry); + break jj_entries_loop; + } + } + if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; + } } /** Generate ParseException. */ static public ParseException generateParseException() { - jj_expentries.clear(); - boolean[] la1tokens = new boolean[119]; - if (jj_kind >= 0) { - la1tokens[jj_kind] = true; - jj_kind = -1; - } - for (int i = 0; i < 119; i++) { - if (jj_la1[i] == jj_gen) { - for (int j = 0; j < 32; j++) { - if ((jj_la1_0[i] & (1<= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 121; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1< jj_gen) { - jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; - switch (i) { - case 0: jj_3_1(); break; - case 1: jj_3_2(); break; - case 2: jj_3_3(); break; - case 3: jj_3_4(); break; - case 4: jj_3_5(); break; - case 5: jj_3_6(); break; - case 6: jj_3_7(); break; - case 7: jj_3_8(); break; - case 8: jj_3_9(); break; - case 9: jj_3_10(); break; - case 10: jj_3_11(); break; - case 11: jj_3_12(); break; - case 12: jj_3_13(); break; - case 13: jj_3_14(); break; - case 14: jj_3_15(); break; - case 15: jj_3_16(); break; - case 16: jj_3_17(); break; - case 17: jj_3_18(); break; - case 18: jj_3_19(); break; - } - } - p = p.next; - } while (p != null); - - } catch(LookaheadSuccess ls) { } - } - jj_rescan = false; + jj_rescan = true; + for (int i = 0; i < 19; i++) { + try { + JJCalls p = jj_2_rtns[i]; + do { + if (p.gen > jj_gen) { + jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; + switch (i) { + case 0: jj_3_1(); break; + case 1: jj_3_2(); break; + case 2: jj_3_3(); break; + case 3: jj_3_4(); break; + case 4: jj_3_5(); break; + case 5: jj_3_6(); break; + case 6: jj_3_7(); break; + case 7: jj_3_8(); break; + case 8: jj_3_9(); break; + case 9: jj_3_10(); break; + case 10: jj_3_11(); break; + case 11: jj_3_12(); break; + case 12: jj_3_13(); break; + case 13: jj_3_14(); break; + case 14: jj_3_15(); break; + case 15: jj_3_16(); break; + case 16: jj_3_17(); break; + case 17: jj_3_18(); break; + case 18: jj_3_19(); break; + } + } + p = p.next; + } while (p != null); + } catch(LookaheadSuccess ls) { } + } + jj_rescan = false; } static private void jj_save(int index, int xla) { - JJCalls p = jj_2_rtns[index]; - while (p.gen > jj_gen) { - if (p.next == null) { p = p.next = new JJCalls(); break; } - p = p.next; - } - - p.gen = jj_gen + xla - jj_la; - p.first = token; - p.arg = xla; + JJCalls p = jj_2_rtns[index]; + while (p.gen > jj_gen) { + if (p.next == null) { p = p.next = new JJCalls(); break; } + p = p.next; + } + p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; } static final class JJCalls { - int gen; - Token first; - int arg; - JJCalls next; + int gen; + Token first; + int arg; + JJCalls next; } } diff --git a/prism/src/parser/PrismParser.jj b/prism/src/parser/PrismParser.jj index 591b929e0..91a13b894 100644 --- a/prism/src/parser/PrismParser.jj +++ b/prism/src/parser/PrismParser.jj @@ -427,7 +427,13 @@ SPECIAL_TOKEN : TOKEN : { // Keywords - < A: "A" > + // + < NASH: "NE"> +| < CORR: "CE"> +| < SWEQ: "SW"> +| < FAIR: "FR"> + // +| < A: "A" > //| < ARRAY: "array" > | < BOOL: "bool" > | < CLOCK: "clock" > @@ -1899,12 +1905,17 @@ Expression ExpressionMultiNash(boolean prop, boolean pathprop) : String relOp = null; boolean isBool; int r; + int eq = 1; // default NE + int crit = 3; // default SW int n = 0; } { // This production is only allowed in expressions if the "prop" parameter is true { if (!prop) throw generateParseException(); } ( + eq = EqType() crit = EqType() + )? + ( (r = LtGt() bound = Expression(false, false) { relOp = ExpressionBinaryOp.opSymbols[r]; isBool = true; } | { relOp = "min="; isBool = false; } ) | (r = LtGt() bound = Expression(false, false) { relOp = ExpressionBinaryOp.opSymbols[r]; isBool = true; } | { relOp = "max="; isBool = false; } ) @@ -1926,10 +1937,24 @@ Expression ExpressionMultiNash(boolean prop, boolean pathprop) : { ret.setBound(bound); ret.setRelOp(relOp); + ret.setEqType(eq); + ret.setCrit(crit); return ret; } } +// Types of Equilibria + +int EqType() : +{ +} +{ + {return ExpressionMultiNash.NASH; } | + {return ExpressionMultiNash.CORR; } | + {return ExpressionMultiNash.SWEQ; }| + {return ExpressionMultiNash.FAIR; } +} + // (Property) expression: probabilistic operator (n-player Nash) ExpressionQuant ExpressionMultiNashProb(boolean prop, boolean pathprop) : diff --git a/prism/src/parser/PrismParserConstants.java b/prism/src/parser/PrismParserConstants.java index e92c0edd5..2ae81ed93 100644 --- a/prism/src/parser/PrismParserConstants.java +++ b/prism/src/parser/PrismParserConstants.java @@ -15,237 +15,245 @@ public interface PrismParserConstants { /** RegularExpression Id. */ int COMMENT = 2; /** RegularExpression Id. */ - int A = 3; + int NASH = 3; /** RegularExpression Id. */ - int BOOL = 4; + int CORR = 4; /** RegularExpression Id. */ - int CLOCK = 5; + int SWEQ = 5; /** RegularExpression Id. */ - int CONST = 6; + int FAIR = 6; /** RegularExpression Id. */ - int CSG = 7; + int A = 7; /** RegularExpression Id. */ - int CTMC = 8; + int BOOL = 8; /** RegularExpression Id. */ - int CTMDP = 9; + int CLOCK = 9; /** RegularExpression Id. */ - int C = 10; + int CONST = 10; /** RegularExpression Id. */ - int DISCOUNT = 11; + int CSG = 11; /** RegularExpression Id. */ - int DOUBLE = 12; + int CTMC = 12; /** RegularExpression Id. */ - int DTMC = 13; + int CTMDP = 13; /** RegularExpression Id. */ - int E = 14; + int C = 14; /** RegularExpression Id. */ - int ENDINIT = 15; + int DISCOUNT = 15; /** RegularExpression Id. */ - int ENDINVARIANT = 16; + int DOUBLE = 16; /** RegularExpression Id. */ - int ENDMODULE = 17; + int DTMC = 17; /** RegularExpression Id. */ - int ENDOBSERVABLES = 18; + int E = 18; /** RegularExpression Id. */ - int ENDPLAYER = 19; + int ENDINIT = 19; /** RegularExpression Id. */ - int ENDREWARDS = 20; + int ENDINVARIANT = 20; /** RegularExpression Id. */ - int ENDSYSTEM = 21; + int ENDMODULE = 21; /** RegularExpression Id. */ - int FALSE = 22; + int ENDOBSERVABLES = 22; /** RegularExpression Id. */ - int FORMULA = 23; + int ENDPLAYER = 23; /** RegularExpression Id. */ - int FILTER = 24; + int ENDREWARDS = 24; /** RegularExpression Id. */ - int FUNC = 25; + int ENDSYSTEM = 25; /** RegularExpression Id. */ - int F = 26; + int FALSE = 26; /** RegularExpression Id. */ - int Fc = 27; + int FORMULA = 27; /** RegularExpression Id. */ - int F0 = 28; + int FILTER = 28; /** RegularExpression Id. */ - int GLOBAL = 29; + int FUNC = 29; /** RegularExpression Id. */ - int G = 30; + int F = 30; /** RegularExpression Id. */ - int INIT = 31; + int Fc = 31; /** RegularExpression Id. */ - int INVARIANT = 32; + int F0 = 32; /** RegularExpression Id. */ - int I = 33; + int GLOBAL = 33; /** RegularExpression Id. */ - int INT = 34; + int G = 34; /** RegularExpression Id. */ - int LABEL = 35; + int INIT = 35; /** RegularExpression Id. */ - int MAXMAX = 36; + int INVARIANT = 36; /** RegularExpression Id. */ - int MAXMIN = 37; + int I = 37; /** RegularExpression Id. */ - int MAX = 38; + int INT = 38; /** RegularExpression Id. */ - int MDP = 39; + int LABEL = 39; /** RegularExpression Id. */ - int MINMAX = 40; + int MAXMAX = 40; /** RegularExpression Id. */ - int MINMIN = 41; + int MAXMIN = 41; /** RegularExpression Id. */ - int MIN = 42; + int MAX = 42; /** RegularExpression Id. */ - int MODULE = 43; + int MDP = 43; /** RegularExpression Id. */ - int X = 44; + int MINMAX = 44; /** RegularExpression Id. */ - int NONDETERMINISTIC = 45; + int MINMIN = 45; /** RegularExpression Id. */ - int OBSERVABLE = 46; + int MIN = 46; /** RegularExpression Id. */ - int OBSERVABLES = 47; + int MODULE = 47; /** RegularExpression Id. */ - int PMAXMAX = 48; + int X = 48; /** RegularExpression Id. */ - int PMAXMIN = 49; + int NONDETERMINISTIC = 49; /** RegularExpression Id. */ - int PMAX = 50; + int OBSERVABLE = 50; /** RegularExpression Id. */ - int PMINMAX = 51; + int OBSERVABLES = 51; /** RegularExpression Id. */ - int PMINMIN = 52; + int PMAXMAX = 52; /** RegularExpression Id. */ - int PMIN = 53; + int PMAXMIN = 53; /** RegularExpression Id. */ - int P = 54; + int PMAX = 54; /** RegularExpression Id. */ - int PLAYER = 55; + int PMINMAX = 55; /** RegularExpression Id. */ - int POMDP = 56; + int PMINMIN = 56; /** RegularExpression Id. */ - int POPTA = 57; + int PMIN = 57; /** RegularExpression Id. */ - int PROBABILISTIC = 58; + int P = 58; /** RegularExpression Id. */ - int PROB = 59; + int PLAYER = 59; /** RegularExpression Id. */ - int PTA = 60; + int POMDP = 60; /** RegularExpression Id. */ - int RATE = 61; + int POPTA = 61; /** RegularExpression Id. */ - int REWARDS = 62; + int PROBABILISTIC = 62; /** RegularExpression Id. */ - int RMAXMAX = 63; + int PROB = 63; /** RegularExpression Id. */ - int RMAXMIN = 64; + int PTA = 64; /** RegularExpression Id. */ - int RMAX = 65; + int RATE = 65; /** RegularExpression Id. */ - int RMINMAX = 66; + int REWARDS = 66; /** RegularExpression Id. */ - int RMINMIN = 67; + int RMAXMAX = 67; /** RegularExpression Id. */ - int RMIN = 68; + int RMAXMIN = 68; /** RegularExpression Id. */ - int R = 69; + int RMAX = 69; /** RegularExpression Id. */ - int S = 70; + int RMINMAX = 70; /** RegularExpression Id. */ - int STOCHASTIC = 71; + int RMINMIN = 71; /** RegularExpression Id. */ - int STPG = 72; + int RMIN = 72; /** RegularExpression Id. */ - int SMG = 73; + int R = 73; /** RegularExpression Id. */ - int SYSTEM = 74; + int S = 74; /** RegularExpression Id. */ - int TPTG = 75; + int STOCHASTIC = 75; /** RegularExpression Id. */ - int TRUE = 76; + int STPG = 76; /** RegularExpression Id. */ - int U = 77; + int SMG = 77; /** RegularExpression Id. */ - int W = 78; + int SYSTEM = 78; /** RegularExpression Id. */ - int NOT = 79; + int TPTG = 79; /** RegularExpression Id. */ - int AND = 80; + int TRUE = 80; /** RegularExpression Id. */ - int OR = 81; + int U = 81; /** RegularExpression Id. */ - int IMPLIES = 82; + int W = 82; /** RegularExpression Id. */ - int IFF = 83; + int NOT = 83; /** RegularExpression Id. */ - int RARROW = 84; + int AND = 84; /** RegularExpression Id. */ - int COLON = 85; + int OR = 85; /** RegularExpression Id. */ - int SEMICOLON = 86; + int IMPLIES = 86; /** RegularExpression Id. */ - int COMMA = 87; + int IFF = 87; /** RegularExpression Id. */ - int DOTS = 88; + int RARROW = 88; /** RegularExpression Id. */ - int LPARENTH = 89; + int COLON = 89; /** RegularExpression Id. */ - int RPARENTH = 90; + int SEMICOLON = 90; /** RegularExpression Id. */ - int LBRACKET = 91; + int COMMA = 91; /** RegularExpression Id. */ - int RBRACKET = 92; + int DOTS = 92; /** RegularExpression Id. */ - int DLBRACKET = 93; + int LPARENTH = 93; /** RegularExpression Id. */ - int DRBRACKET = 94; + int RPARENTH = 94; /** RegularExpression Id. */ - int LBRACE = 95; + int LBRACKET = 95; /** RegularExpression Id. */ - int RBRACE = 96; + int RBRACKET = 96; /** RegularExpression Id. */ - int EQ = 97; + int DLBRACKET = 97; /** RegularExpression Id. */ - int NE = 98; + int DRBRACKET = 98; /** RegularExpression Id. */ - int LT = 99; + int LBRACE = 99; /** RegularExpression Id. */ - int GT = 100; + int RBRACE = 100; /** RegularExpression Id. */ - int DLT = 101; + int EQ = 101; /** RegularExpression Id. */ - int DGT = 102; + int NE = 102; /** RegularExpression Id. */ - int LE = 103; + int LT = 103; /** RegularExpression Id. */ - int GE = 104; + int GT = 104; /** RegularExpression Id. */ - int PLUS = 105; + int DLT = 105; /** RegularExpression Id. */ - int MINUS = 106; + int DGT = 106; /** RegularExpression Id. */ - int TIMES = 107; + int LE = 107; /** RegularExpression Id. */ - int DIVIDE = 108; + int GE = 108; /** RegularExpression Id. */ - int PRIME = 109; + int PLUS = 109; /** RegularExpression Id. */ - int RENAME = 110; + int MINUS = 110; /** RegularExpression Id. */ - int QMARK = 111; + int TIMES = 111; /** RegularExpression Id. */ - int DQUOTE = 112; + int DIVIDE = 112; /** RegularExpression Id. */ - int REG_INT = 113; + int PRIME = 113; /** RegularExpression Id. */ - int REG_DOUBLE = 114; + int RENAME = 114; /** RegularExpression Id. */ - int REG_IDENTPRIME = 115; + int QMARK = 115; /** RegularExpression Id. */ - int REG_IDENT = 116; + int DQUOTE = 116; /** RegularExpression Id. */ - int PREPROC = 117; + int REG_INT = 117; /** RegularExpression Id. */ - int LEXICAL_ERROR = 118; + int REG_DOUBLE = 118; + /** RegularExpression Id. */ + int REG_IDENTPRIME = 119; + /** RegularExpression Id. */ + int REG_IDENT = 120; + /** RegularExpression Id. */ + int PREPROC = 121; + /** RegularExpression Id. */ + int LEXICAL_ERROR = 122; /** Lexical state. */ int DEFAULT = 0; @@ -255,6 +263,10 @@ public interface PrismParserConstants { "", "", "", + "\"NE\"", + "\"CE\"", + "\"SW\"", + "\"FR\"", "\"A\"", "\"bool\"", "\"clock\"", diff --git a/prism/src/parser/PrismParserTokenManager.java b/prism/src/parser/PrismParserTokenManager.java index 0603e9e1b..b1d9e2bb1 100644 --- a/prism/src/parser/PrismParserTokenManager.java +++ b/prism/src/parser/PrismParserTokenManager.java @@ -16,8 +16,7 @@ import prism.PrismLangException; /** Token Manager. */ -@SuppressWarnings ("unused") -public class PrismParserTokenManager implements PrismParserConstants { +@SuppressWarnings("unused")public class PrismParserTokenManager implements PrismParserConstants { /** Debug output. */ public static java.io.PrintStream debugStream = System.out; @@ -27,162 +26,162 @@ private static final int jjStopStringLiteralDfa_0(int pos, long active0, long ac switch (pos) { case 0: - if ((active0 & 0x807f10025c004408L) != 0L || (active1 & 0x607fL) != 0L) + if ((active0 & 0x7f10025c00440f0L) != 0L || (active1 & 0x607f8L) != 0L) return 23; - if ((active1 & 0x100000000000L) != 0L) + if ((active1 & 0x1000000000000L) != 0L) return 1; - if ((active1 & 0x1000000L) != 0L) + if ((active1 & 0x10000000L) != 0L) return 11; - if ((active0 & 0x7f80effda3ffbbf0L) != 0L || (active1 & 0x1f80L) != 0L) + if ((active0 & 0xf80effda3ffbbf08L) != 0L || (active1 & 0x1f807L) != 0L) { - jjmatchedKind = 116; + jjmatchedKind = 120; return 23; } return -1; case 1: - if ((active0 & 0x18000000L) != 0L) + if ((active0 & 0x180000078L) != 0L) return 23; - if ((active0 & 0xffbfeffda3ffbbf0L) != 0L || (active1 & 0x1f9fL) != 0L) + if ((active0 & 0xfbfeffda3ffbbf00L) != 0L || (active1 & 0x1f9ffL) != 0L) { if (jjmatchedPos != 1) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 1; } return 23; } return -1; case 2: - if ((active0 & 0x100007f400000080L) != 0L || (active1 & 0x200L) != 0L) + if ((active0 & 0x7f4000000800L) != 0L || (active1 & 0x2001L) != 0L) return 23; - if ((active0 & 0xefbfe809a3ffbb70L) != 0L || (active1 & 0x1d9fL) != 0L) + if ((active0 & 0xfbfe809a3ffbb700L) != 0L || (active1 & 0x1d9feL) != 0L) { if (jjmatchedPos != 2) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 2; } return 23; } return -1; case 3: - if ((active0 & 0xac3f000082002910L) != 0L || (active1 & 0x191fL) != 0L) + if ((active0 & 0xc3f0000820029100L) != 0L || (active1 & 0x191faL) != 0L) return 23; - if ((active0 & 0x4380eb3921ff9260L) != 0L || (active1 & 0x480L) != 0L) + if ((active0 & 0x380eb3921ff92600L) != 0L || (active1 & 0x4804L) != 0L) { if (jjmatchedPos != 3) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 3; } return 23; } return -1; case 4: - if ((active0 & 0x300000800400260L) != 0L) + if ((active0 & 0x3000008004002600L) != 0L) return 23; - if ((active0 & 0xc49beb3121bf9000L) != 0L || (active1 & 0x48dL) != 0L) + if ((active0 & 0x49beb3121bf90000L) != 0L || (active1 & 0x48dcL) != 0L) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 4; return 23; } return -1; case 5: - if ((active0 & 0x800b3021001000L) != 0L || (active1 & 0x400L) != 0L) + if ((active0 & 0x800b30210010000L) != 0L || (active1 & 0x4000L) != 0L) return 23; - if ((active0 & 0xc41be00100bf8000L) != 0L || (active1 & 0x8dL) != 0L) + if ((active0 & 0x41be00100bf80000L) != 0L || (active1 & 0x8dcL) != 0L) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 5; return 23; } return -1; case 6: - if ((active0 & 0xc01b000000808000L) != 0L || (active1 & 0xdL) != 0L) + if ((active0 & 0x1b0000008080000L) != 0L || (active1 & 0xdcL) != 0L) return 23; - if ((active0 & 0x400e001003f0000L) != 0L || (active1 & 0x80L) != 0L) + if ((active0 & 0x400e001003f00000L) != 0L || (active1 & 0x800L) != 0L) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 6; return 23; } return -1; case 7: - if ((active0 & 0x400e001003f0000L) != 0L || (active1 & 0x80L) != 0L) + if ((active0 & 0x400e001003f00000L) != 0L || (active1 & 0x800L) != 0L) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 7; return 23; } return -1; case 8: - if ((active0 & 0x1002a0000L) != 0L) + if ((active0 & 0x1002a00000L) != 0L) return 23; - if ((active0 & 0x400e00000150000L) != 0L || (active1 & 0x80L) != 0L) + if ((active0 & 0x400e000001500000L) != 0L || (active1 & 0x800L) != 0L) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 8; return 23; } return -1; case 9: - if ((active0 & 0xc00000100000L) != 0L || (active1 & 0x80L) != 0L) - return 23; - if ((active0 & 0x400200000050000L) != 0L) + if ((active0 & 0x4002000000500000L) != 0L) { if (jjmatchedPos != 9) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 9; } return 23; } + if ((active0 & 0xc000001000000L) != 0L || (active1 & 0x800L) != 0L) + return 23; return -1; case 10: - if ((active0 & 0x800000000000L) != 0L) + if ((active0 & 0x8000000000000L) != 0L) return 23; - if ((active0 & 0x400200000050000L) != 0L) + if ((active0 & 0x4002000000500000L) != 0L) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 10; return 23; } return -1; case 11: - if ((active0 & 0x10000L) != 0L) + if ((active0 & 0x100000L) != 0L) return 23; - if ((active0 & 0x400200000040000L) != 0L) + if ((active0 & 0x4002000000400000L) != 0L) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 11; return 23; } return -1; case 12: - if ((active0 & 0x400000000000000L) != 0L) + if ((active0 & 0x4000000000000000L) != 0L) return 23; - if ((active0 & 0x200000040000L) != 0L) + if ((active0 & 0x2000000400000L) != 0L) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 12; return 23; } return -1; case 13: - if ((active0 & 0x40000L) != 0L) - return 23; - if ((active0 & 0x200000000000L) != 0L) + if ((active0 & 0x2000000000000L) != 0L) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 13; return 23; } + if ((active0 & 0x400000L) != 0L) + return 23; return -1; case 14: - if ((active0 & 0x200000000000L) != 0L) + if ((active0 & 0x2000000000000L) != 0L) { - jjmatchedKind = 116; + jjmatchedKind = 120; jjmatchedPos = 14; return 23; } @@ -204,115 +203,119 @@ static private int jjMoveStringLiteralDfa0_0(){ switch(curChar) { case 33: - jjmatchedKind = 79; - return jjMoveStringLiteralDfa1_0(0x0L, 0x400000000L); + jjmatchedKind = 83; + return jjMoveStringLiteralDfa1_0(0x0L, 0x4000000000L); case 34: - return jjStopAtPos(0, 112); + return jjStopAtPos(0, 116); case 38: - return jjStopAtPos(0, 80); + return jjStopAtPos(0, 84); case 39: - return jjStopAtPos(0, 109); + return jjStopAtPos(0, 113); case 40: - return jjStopAtPos(0, 89); + return jjStopAtPos(0, 93); case 41: - return jjStopAtPos(0, 90); + return jjStopAtPos(0, 94); case 42: - return jjStopAtPos(0, 107); + return jjStopAtPos(0, 111); case 43: - return jjStopAtPos(0, 105); + return jjStopAtPos(0, 109); case 44: - return jjStopAtPos(0, 87); + return jjStopAtPos(0, 91); case 45: - jjmatchedKind = 106; - return jjMoveStringLiteralDfa1_0(0x0L, 0x100000L); - case 46: + jjmatchedKind = 110; return jjMoveStringLiteralDfa1_0(0x0L, 0x1000000L); + case 46: + return jjMoveStringLiteralDfa1_0(0x0L, 0x10000000L); case 47: - return jjStartNfaWithStates_0(0, 108, 1); + return jjStartNfaWithStates_0(0, 112, 1); case 58: - return jjStopAtPos(0, 85); + return jjStopAtPos(0, 89); case 59: - return jjStopAtPos(0, 86); + return jjStopAtPos(0, 90); case 60: - jjmatchedKind = 99; - return jjMoveStringLiteralDfa1_0(0x0L, 0x40a000080000L); + jjmatchedKind = 103; + return jjMoveStringLiteralDfa1_0(0x0L, 0x40a0000800000L); case 61: - jjmatchedKind = 97; - return jjMoveStringLiteralDfa1_0(0x0L, 0x40000L); + jjmatchedKind = 101; + return jjMoveStringLiteralDfa1_0(0x0L, 0x400000L); case 62: - jjmatchedKind = 100; - return jjMoveStringLiteralDfa1_0(0x0L, 0x14000000000L); + jjmatchedKind = 104; + return jjMoveStringLiteralDfa1_0(0x0L, 0x140000000000L); case 63: - return jjStopAtPos(0, 111); + return jjStopAtPos(0, 115); case 65: - return jjStartNfaWithStates_0(0, 3, 23); + return jjStartNfaWithStates_0(0, 7, 23); case 67: - return jjStartNfaWithStates_0(0, 10, 23); + jjmatchedKind = 14; + return jjMoveStringLiteralDfa1_0(0x10L, 0x0L); case 69: - return jjStartNfaWithStates_0(0, 14, 23); + return jjStartNfaWithStates_0(0, 18, 23); case 70: - jjmatchedKind = 26; - return jjMoveStringLiteralDfa1_0(0x18000000L, 0x0L); + jjmatchedKind = 30; + return jjMoveStringLiteralDfa1_0(0x180000040L, 0x0L); case 71: - return jjStartNfaWithStates_0(0, 30, 23); + return jjStartNfaWithStates_0(0, 34, 23); case 73: - return jjStartNfaWithStates_0(0, 33, 23); + return jjStartNfaWithStates_0(0, 37, 23); + case 78: + return jjMoveStringLiteralDfa1_0(0x8L, 0x0L); case 80: - jjmatchedKind = 54; - return jjMoveStringLiteralDfa1_0(0x3f000000000000L, 0x0L); + jjmatchedKind = 58; + return jjMoveStringLiteralDfa1_0(0x3f0000000000000L, 0x0L); case 82: - jjmatchedKind = 69; - return jjMoveStringLiteralDfa1_0(0x8000000000000000L, 0x1fL); + jjmatchedKind = 73; + return jjMoveStringLiteralDfa1_0(0x0L, 0x1f8L); case 83: - return jjStartNfaWithStates_0(0, 70, 23); + jjmatchedKind = 74; + return jjMoveStringLiteralDfa1_0(0x20L, 0x0L); case 85: - return jjStartNfaWithStates_0(0, 77, 23); + return jjStartNfaWithStates_0(0, 81, 23); case 87: - return jjStartNfaWithStates_0(0, 78, 23); + return jjStartNfaWithStates_0(0, 82, 23); case 88: - return jjStartNfaWithStates_0(0, 44, 23); + return jjStartNfaWithStates_0(0, 48, 23); case 91: - jjmatchedKind = 91; - return jjMoveStringLiteralDfa1_0(0x0L, 0x20000000L); + jjmatchedKind = 95; + return jjMoveStringLiteralDfa1_0(0x0L, 0x200000000L); case 93: - jjmatchedKind = 92; - return jjMoveStringLiteralDfa1_0(0x0L, 0x40000000L); + jjmatchedKind = 96; + return jjMoveStringLiteralDfa1_0(0x0L, 0x400000000L); case 98: - return jjMoveStringLiteralDfa1_0(0x10L, 0x0L); + return jjMoveStringLiteralDfa1_0(0x100L, 0x0L); case 99: - return jjMoveStringLiteralDfa1_0(0x3e0L, 0x0L); + return jjMoveStringLiteralDfa1_0(0x3e00L, 0x0L); case 100: - return jjMoveStringLiteralDfa1_0(0x3800L, 0x0L); + return jjMoveStringLiteralDfa1_0(0x38000L, 0x0L); case 101: - return jjMoveStringLiteralDfa1_0(0x3f8000L, 0x0L); + return jjMoveStringLiteralDfa1_0(0x3f80000L, 0x0L); case 102: - return jjMoveStringLiteralDfa1_0(0x3c00000L, 0x0L); + return jjMoveStringLiteralDfa1_0(0x3c000000L, 0x0L); case 103: - return jjMoveStringLiteralDfa1_0(0x20000000L, 0x0L); + return jjMoveStringLiteralDfa1_0(0x200000000L, 0x0L); case 105: - return jjMoveStringLiteralDfa1_0(0x580000000L, 0x0L); + return jjMoveStringLiteralDfa1_0(0x5800000000L, 0x0L); case 108: - return jjMoveStringLiteralDfa1_0(0x800000000L, 0x0L); + return jjMoveStringLiteralDfa1_0(0x8000000000L, 0x0L); case 109: - return jjMoveStringLiteralDfa1_0(0xff000000000L, 0x0L); + return jjMoveStringLiteralDfa1_0(0xff0000000000L, 0x0L); case 110: - return jjMoveStringLiteralDfa1_0(0x200000000000L, 0x0L); + return jjMoveStringLiteralDfa1_0(0x2000000000000L, 0x0L); case 111: - return jjMoveStringLiteralDfa1_0(0xc00000000000L, 0x0L); + return jjMoveStringLiteralDfa1_0(0xc000000000000L, 0x0L); case 112: - return jjMoveStringLiteralDfa1_0(0x1f80000000000000L, 0x0L); + return jjMoveStringLiteralDfa1_0(0xf800000000000000L, 0x1L); case 114: - return jjMoveStringLiteralDfa1_0(0x6000000000000000L, 0x0L); + return jjMoveStringLiteralDfa1_0(0x0L, 0x6L); case 115: - return jjMoveStringLiteralDfa1_0(0x0L, 0x780L); + return jjMoveStringLiteralDfa1_0(0x0L, 0x7800L); case 116: - return jjMoveStringLiteralDfa1_0(0x0L, 0x1800L); + return jjMoveStringLiteralDfa1_0(0x0L, 0x18000L); case 123: - return jjStopAtPos(0, 95); + return jjStopAtPos(0, 99); case 124: - return jjStopAtPos(0, 81); + return jjStopAtPos(0, 85); case 125: - return jjStopAtPos(0, 96); + return jjStopAtPos(0, 100); default : return jjMoveNfa_0(0, 0); } @@ -326,82 +329,96 @@ static private int jjMoveStringLiteralDfa1_0(long active0, long active1){ switch(curChar) { case 45: - if ((active1 & 0x400000000000L) != 0L) - return jjStopAtPos(1, 110); + if ((active1 & 0x4000000000000L) != 0L) + return jjStopAtPos(1, 114); break; case 46: - if ((active1 & 0x1000000L) != 0L) - return jjStopAtPos(1, 88); + if ((active1 & 0x10000000L) != 0L) + return jjStopAtPos(1, 92); break; case 48: - if ((active0 & 0x10000000L) != 0L) - return jjStartNfaWithStates_0(1, 28, 23); + if ((active0 & 0x100000000L) != 0L) + return jjStartNfaWithStates_0(1, 32, 23); break; case 60: - if ((active1 & 0x2000000000L) != 0L) - return jjStopAtPos(1, 101); + if ((active1 & 0x20000000000L) != 0L) + return jjStopAtPos(1, 105); break; case 61: - if ((active1 & 0x400000000L) != 0L) - return jjStopAtPos(1, 98); - else if ((active1 & 0x8000000000L) != 0L) + if ((active1 & 0x4000000000L) != 0L) + return jjStopAtPos(1, 102); + else if ((active1 & 0x80000000000L) != 0L) { - jjmatchedKind = 103; + jjmatchedKind = 107; jjmatchedPos = 1; } - else if ((active1 & 0x10000000000L) != 0L) - return jjStopAtPos(1, 104); - return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x80000L); + else if ((active1 & 0x100000000000L) != 0L) + return jjStopAtPos(1, 108); + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x800000L); case 62: - if ((active1 & 0x40000L) != 0L) - return jjStopAtPos(1, 82); - else if ((active1 & 0x100000L) != 0L) - return jjStopAtPos(1, 84); - else if ((active1 & 0x4000000000L) != 0L) - return jjStopAtPos(1, 102); + if ((active1 & 0x400000L) != 0L) + return jjStopAtPos(1, 86); + else if ((active1 & 0x1000000L) != 0L) + return jjStopAtPos(1, 88); + else if ((active1 & 0x40000000000L) != 0L) + return jjStopAtPos(1, 106); + break; + case 69: + if ((active0 & 0x8L) != 0L) + return jjStartNfaWithStates_0(1, 3, 23); + else if ((active0 & 0x10L) != 0L) + return jjStartNfaWithStates_0(1, 4, 23); + break; + case 82: + if ((active0 & 0x40L) != 0L) + return jjStartNfaWithStates_0(1, 6, 23); + break; + case 87: + if ((active0 & 0x20L) != 0L) + return jjStartNfaWithStates_0(1, 5, 23); break; case 91: - if ((active1 & 0x20000000L) != 0L) - return jjStopAtPos(1, 93); + if ((active1 & 0x200000000L) != 0L) + return jjStopAtPos(1, 97); break; case 93: - if ((active1 & 0x40000000L) != 0L) - return jjStopAtPos(1, 94); + if ((active1 & 0x400000000L) != 0L) + return jjStopAtPos(1, 98); break; case 97: - return jjMoveStringLiteralDfa2_0(active0, 0x2000007800400000L, active1, 0L); + return jjMoveStringLiteralDfa2_0(active0, 0x78004000000L, active1, 0x2L); case 98: - return jjMoveStringLiteralDfa2_0(active0, 0xc00000000000L, active1, 0L); + return jjMoveStringLiteralDfa2_0(active0, 0xc000000000000L, active1, 0L); case 99: - if ((active0 & 0x8000000L) != 0L) - return jjStartNfaWithStates_0(1, 27, 23); + if ((active0 & 0x80000000L) != 0L) + return jjStartNfaWithStates_0(1, 31, 23); break; case 100: - return jjMoveStringLiteralDfa2_0(active0, 0x8000000000L, active1, 0L); + return jjMoveStringLiteralDfa2_0(active0, 0x80000000000L, active1, 0L); case 101: - return jjMoveStringLiteralDfa2_0(active0, 0x4000000000000000L, active1, 0L); + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x4L); case 105: - return jjMoveStringLiteralDfa2_0(active0, 0x70001000800L, active1, 0L); + return jjMoveStringLiteralDfa2_0(active0, 0x700010008000L, active1, 0L); case 108: - return jjMoveStringLiteralDfa2_0(active0, 0x80000020000020L, active1, 0L); + return jjMoveStringLiteralDfa2_0(active0, 0x800000200000200L, active1, 0L); case 109: - return jjMoveStringLiteralDfa2_0(active0, 0x803f000000000000L, active1, 0x21fL); + return jjMoveStringLiteralDfa2_0(active0, 0x3f0000000000000L, active1, 0x21f8L); case 110: - return jjMoveStringLiteralDfa2_0(active0, 0x5803f8000L, active1, 0L); + return jjMoveStringLiteralDfa2_0(active0, 0x5803f80000L, active1, 0L); case 111: - return jjMoveStringLiteralDfa2_0(active0, 0x300280000801050L, active1, 0L); + return jjMoveStringLiteralDfa2_0(active0, 0x3002800008010500L, active1, 0L); case 112: - return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x800L); + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x8000L); case 114: - return jjMoveStringLiteralDfa2_0(active0, 0xc00000000000000L, active1, 0x1000L); + return jjMoveStringLiteralDfa2_0(active0, 0xc000000000000000L, active1, 0x10000L); case 115: - return jjMoveStringLiteralDfa2_0(active0, 0x80L, active1, 0L); + return jjMoveStringLiteralDfa2_0(active0, 0x800L, active1, 0L); case 116: - return jjMoveStringLiteralDfa2_0(active0, 0x1000000000002300L, active1, 0x180L); + return jjMoveStringLiteralDfa2_0(active0, 0x23000L, active1, 0x1801L); case 117: - return jjMoveStringLiteralDfa2_0(active0, 0x2000000L, active1, 0L); + return jjMoveStringLiteralDfa2_0(active0, 0x20000000L, active1, 0L); case 121: - return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x400L); + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x4000L); default : break; } @@ -418,63 +435,63 @@ static private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, switch(curChar) { case 62: - if ((active1 & 0x80000L) != 0L) - return jjStopAtPos(2, 83); + if ((active1 & 0x800000L) != 0L) + return jjStopAtPos(2, 87); break; case 97: - if ((active0 & 0x1000000000000000L) != 0L) - return jjStartNfaWithStates_0(2, 60, 23); - return jjMoveStringLiteralDfa3_0(active0, 0x8087000000000000L, active1, 0x3L); + if ((active1 & 0x1L) != 0L) + return jjStartNfaWithStates_0(2, 64, 23); + return jjMoveStringLiteralDfa3_0(active0, 0x870000000000000L, active1, 0x38L); case 98: - return jjMoveStringLiteralDfa3_0(active0, 0x800000000L, active1, 0L); + return jjMoveStringLiteralDfa3_0(active0, 0x8000000000L, active1, 0L); case 100: - return jjMoveStringLiteralDfa3_0(active0, 0x800003f8000L, active1, 0L); + return jjMoveStringLiteralDfa3_0(active0, 0x800003f80000L, active1, 0L); case 103: - if ((active0 & 0x80L) != 0L) - return jjStartNfaWithStates_0(2, 7, 23); - else if ((active1 & 0x200L) != 0L) - return jjStartNfaWithStates_0(2, 73, 23); + if ((active0 & 0x800L) != 0L) + return jjStartNfaWithStates_0(2, 11, 23); + else if ((active1 & 0x2000L) != 0L) + return jjStartNfaWithStates_0(2, 77, 23); break; case 105: - return jjMoveStringLiteralDfa3_0(active0, 0x38000080000000L, active1, 0x1cL); + return jjMoveStringLiteralDfa3_0(active0, 0x380000800000000L, active1, 0x1c0L); case 108: - return jjMoveStringLiteralDfa3_0(active0, 0x1400000L, active1, 0L); + return jjMoveStringLiteralDfa3_0(active0, 0x14000000L, active1, 0L); case 109: - return jjMoveStringLiteralDfa3_0(active0, 0x100000000002300L, active1, 0L); + return jjMoveStringLiteralDfa3_0(active0, 0x1000000000023000L, active1, 0L); case 110: - if ((active0 & 0x40000000000L) != 0L) + if ((active0 & 0x400000000000L) != 0L) { - jjmatchedKind = 42; + jjmatchedKind = 46; jjmatchedPos = 2; } - return jjMoveStringLiteralDfa3_0(active0, 0x230002000040L, active1, 0L); + return jjMoveStringLiteralDfa3_0(active0, 0x2300020000400L, active1, 0L); case 111: - return jjMoveStringLiteralDfa3_0(active0, 0xc00000020000030L, active1, 0x80L); + return jjMoveStringLiteralDfa3_0(active0, 0xc000000200000300L, active1, 0x800L); case 112: - if ((active0 & 0x8000000000L) != 0L) - return jjStartNfaWithStates_0(2, 39, 23); - return jjMoveStringLiteralDfa3_0(active0, 0x200000000000000L, active1, 0x100L); + if ((active0 & 0x80000000000L) != 0L) + return jjStartNfaWithStates_0(2, 43, 23); + return jjMoveStringLiteralDfa3_0(active0, 0x2000000000000000L, active1, 0x1000L); case 114: - return jjMoveStringLiteralDfa3_0(active0, 0x800000L, active1, 0L); + return jjMoveStringLiteralDfa3_0(active0, 0x8000000L, active1, 0L); case 115: - return jjMoveStringLiteralDfa3_0(active0, 0xc00000000800L, active1, 0x400L); + return jjMoveStringLiteralDfa3_0(active0, 0xc000000008000L, active1, 0x4000L); case 116: - if ((active0 & 0x400000000L) != 0L) - return jjStartNfaWithStates_0(2, 34, 23); - return jjMoveStringLiteralDfa3_0(active0, 0x2000000000000000L, active1, 0x800L); + if ((active0 & 0x4000000000L) != 0L) + return jjStartNfaWithStates_0(2, 38, 23); + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x8002L); case 117: - return jjMoveStringLiteralDfa3_0(active0, 0x1000L, active1, 0x1000L); + return jjMoveStringLiteralDfa3_0(active0, 0x10000L, active1, 0x10000L); case 118: - return jjMoveStringLiteralDfa3_0(active0, 0x100000000L, active1, 0L); + return jjMoveStringLiteralDfa3_0(active0, 0x1000000000L, active1, 0L); case 119: - return jjMoveStringLiteralDfa3_0(active0, 0x4000000000000000L, active1, 0L); + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x4L); case 120: - if ((active0 & 0x4000000000L) != 0L) + if ((active0 & 0x40000000000L) != 0L) { - jjmatchedKind = 38; + jjmatchedKind = 42; jjmatchedPos = 2; } - return jjMoveStringLiteralDfa3_0(active0, 0x3000000000L, active1, 0L); + return jjMoveStringLiteralDfa3_0(active0, 0x30000000000L, active1, 0L); default : break; } @@ -491,86 +508,86 @@ static private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, switch(curChar) { case 97: - return jjMoveStringLiteralDfa4_0(active0, 0x4000000100000000L, active1, 0L); + return jjMoveStringLiteralDfa4_0(active0, 0x1000000000L, active1, 0x4L); case 98: - if ((active0 & 0x800000000000000L) != 0L) + if ((active0 & 0x8000000000000000L) != 0L) { - jjmatchedKind = 59; + jjmatchedKind = 63; jjmatchedPos = 3; } - return jjMoveStringLiteralDfa4_0(active0, 0x400000020001000L, active1, 0L); + return jjMoveStringLiteralDfa4_0(active0, 0x4000000200010000L, active1, 0L); case 99: - if ((active0 & 0x100L) != 0L) - return jjStartNfaWithStates_0(3, 8, 23); - else if ((active0 & 0x800L) != 0L) - return jjStartNfaWithStates_0(3, 11, 23); - else if ((active0 & 0x2000L) != 0L) - return jjStartNfaWithStates_0(3, 13, 23); - else if ((active0 & 0x2000000L) != 0L) - return jjStartNfaWithStates_0(3, 25, 23); - return jjMoveStringLiteralDfa4_0(active0, 0x20L, active1, 0x80L); + if ((active0 & 0x1000L) != 0L) + return jjStartNfaWithStates_0(3, 12, 23); + else if ((active0 & 0x8000L) != 0L) + return jjStartNfaWithStates_0(3, 15, 23); + else if ((active0 & 0x20000L) != 0L) + return jjStartNfaWithStates_0(3, 17, 23); + else if ((active0 & 0x20000000L) != 0L) + return jjStartNfaWithStates_0(3, 29, 23); + return jjMoveStringLiteralDfa4_0(active0, 0x200L, active1, 0x800L); case 100: - return jjMoveStringLiteralDfa4_0(active0, 0x100200000000200L, active1, 0L); + return jjMoveStringLiteralDfa4_0(active0, 0x1002000000002000L, active1, 0L); case 101: - if ((active0 & 0x2000000000000000L) != 0L) - return jjStartNfaWithStates_0(3, 61, 23); - else if ((active1 & 0x1000L) != 0L) - return jjStartNfaWithStates_0(3, 76, 23); - return jjMoveStringLiteralDfa4_0(active0, 0xc00800000000L, active1, 0L); + if ((active1 & 0x2L) != 0L) + return jjStartNfaWithStates_0(3, 65, 23); + else if ((active1 & 0x10000L) != 0L) + return jjStartNfaWithStates_0(3, 80, 23); + return jjMoveStringLiteralDfa4_0(active0, 0xc008000000000L, active1, 0L); case 103: - if ((active1 & 0x100L) != 0L) - return jjStartNfaWithStates_0(3, 72, 23); - else if ((active1 & 0x800L) != 0L) - return jjStartNfaWithStates_0(3, 75, 23); + if ((active1 & 0x1000L) != 0L) + return jjStartNfaWithStates_0(3, 76, 23); + else if ((active1 & 0x8000L) != 0L) + return jjStartNfaWithStates_0(3, 79, 23); break; case 105: - return jjMoveStringLiteralDfa4_0(active0, 0x18000L, active1, 0L); + return jjMoveStringLiteralDfa4_0(active0, 0x180000L, active1, 0L); case 108: - if ((active0 & 0x10L) != 0L) - return jjStartNfaWithStates_0(3, 4, 23); + if ((active0 & 0x100L) != 0L) + return jjStartNfaWithStates_0(3, 8, 23); break; case 109: - return jjMoveStringLiteralDfa4_0(active0, 0x33000820000L, active1, 0L); + return jjMoveStringLiteralDfa4_0(active0, 0x330008200000L, active1, 0L); case 110: - if ((active0 & 0x20000000000000L) != 0L) + if ((active0 & 0x200000000000000L) != 0L) { - jjmatchedKind = 53; + jjmatchedKind = 57; jjmatchedPos = 3; } - else if ((active1 & 0x10L) != 0L) + else if ((active1 & 0x100L) != 0L) { - jjmatchedKind = 68; + jjmatchedKind = 72; jjmatchedPos = 3; } - return jjMoveStringLiteralDfa4_0(active0, 0x18000000000000L, active1, 0xcL); + return jjMoveStringLiteralDfa4_0(active0, 0x180000000000000L, active1, 0xc0L); case 111: - return jjMoveStringLiteralDfa4_0(active0, 0x40000L, active1, 0L); + return jjMoveStringLiteralDfa4_0(active0, 0x400000L, active1, 0L); case 112: - return jjMoveStringLiteralDfa4_0(active0, 0x80000L, active1, 0L); + return jjMoveStringLiteralDfa4_0(active0, 0x800000L, active1, 0L); case 114: - return jjMoveStringLiteralDfa4_0(active0, 0x100000L, active1, 0L); + return jjMoveStringLiteralDfa4_0(active0, 0x1000000L, active1, 0L); case 115: - return jjMoveStringLiteralDfa4_0(active0, 0x600040L, active1, 0L); + return jjMoveStringLiteralDfa4_0(active0, 0x6000400L, active1, 0L); case 116: - if ((active0 & 0x80000000L) != 0L) - return jjStartNfaWithStates_0(3, 31, 23); - return jjMoveStringLiteralDfa4_0(active0, 0x200000001000000L, active1, 0x400L); + if ((active0 & 0x800000000L) != 0L) + return jjStartNfaWithStates_0(3, 35, 23); + return jjMoveStringLiteralDfa4_0(active0, 0x2000000010000000L, active1, 0x4000L); case 117: - return jjMoveStringLiteralDfa4_0(active0, 0x80000000000L, active1, 0L); + return jjMoveStringLiteralDfa4_0(active0, 0x800000000000L, active1, 0L); case 120: - if ((active0 & 0x4000000000000L) != 0L) + if ((active0 & 0x40000000000000L) != 0L) { - jjmatchedKind = 50; + jjmatchedKind = 54; jjmatchedPos = 3; } - else if ((active1 & 0x2L) != 0L) + else if ((active1 & 0x20L) != 0L) { - jjmatchedKind = 65; + jjmatchedKind = 69; jjmatchedPos = 3; } - return jjMoveStringLiteralDfa4_0(active0, 0x8003000000000000L, active1, 0x1L); + return jjMoveStringLiteralDfa4_0(active0, 0x30000000000000L, active1, 0x18L); case 121: - return jjMoveStringLiteralDfa4_0(active0, 0x80000000000000L, active1, 0L); + return jjMoveStringLiteralDfa4_0(active0, 0x800000000000000L, active1, 0L); default : break; } @@ -587,49 +604,49 @@ static private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, switch(curChar) { case 97: - if ((active0 & 0x200000000000000L) != 0L) - return jjStartNfaWithStates_0(4, 57, 23); - return jjMoveStringLiteralDfa5_0(active0, 0x400011020000000L, active1, 0L); + if ((active0 & 0x2000000000000000L) != 0L) + return jjStartNfaWithStates_0(4, 61, 23); + return jjMoveStringLiteralDfa5_0(active0, 0x4000110200000000L, active1, 0L); case 98: - return jjMoveStringLiteralDfa5_0(active0, 0x40000L, active1, 0L); + return jjMoveStringLiteralDfa5_0(active0, 0x400000L, active1, 0L); case 101: - if ((active0 & 0x400000L) != 0L) - return jjStartNfaWithStates_0(4, 22, 23); - return jjMoveStringLiteralDfa5_0(active0, 0x80200001100000L, active1, 0x400L); + if ((active0 & 0x4000000L) != 0L) + return jjStartNfaWithStates_0(4, 26, 23); + return jjMoveStringLiteralDfa5_0(active0, 0x802000011000000L, active1, 0x4000L); case 104: - return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x80L); + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x800L); case 105: - return jjMoveStringLiteralDfa5_0(active0, 0x22000000000L, active1, 0L); + return jjMoveStringLiteralDfa5_0(active0, 0x220000000000L, active1, 0L); case 107: - if ((active0 & 0x20L) != 0L) - return jjStartNfaWithStates_0(4, 5, 23); + if ((active0 & 0x200L) != 0L) + return jjStartNfaWithStates_0(4, 9, 23); break; case 108: - if ((active0 & 0x800000000L) != 0L) - return jjStartNfaWithStates_0(4, 35, 23); - return jjMoveStringLiteralDfa5_0(active0, 0x80000081000L, active1, 0L); + if ((active0 & 0x8000000000L) != 0L) + return jjStartNfaWithStates_0(4, 39, 23); + return jjMoveStringLiteralDfa5_0(active0, 0x800000810000L, active1, 0L); case 109: - return jjMoveStringLiteralDfa5_0(active0, 0x801b000000000000L, active1, 0xdL); + return jjMoveStringLiteralDfa5_0(active0, 0x1b0000000000000L, active1, 0xd8L); case 110: - return jjMoveStringLiteralDfa5_0(active0, 0x18000L, active1, 0L); + return jjMoveStringLiteralDfa5_0(active0, 0x180000L, active1, 0L); case 111: - return jjMoveStringLiteralDfa5_0(active0, 0x20000L, active1, 0L); + return jjMoveStringLiteralDfa5_0(active0, 0x200000L, active1, 0L); case 112: - if ((active0 & 0x200L) != 0L) - return jjStartNfaWithStates_0(4, 9, 23); - else if ((active0 & 0x100000000000000L) != 0L) - return jjStartNfaWithStates_0(4, 56, 23); + if ((active0 & 0x2000L) != 0L) + return jjStartNfaWithStates_0(4, 13, 23); + else if ((active0 & 0x1000000000000000L) != 0L) + return jjStartNfaWithStates_0(4, 60, 23); break; case 114: - return jjMoveStringLiteralDfa5_0(active0, 0x4000c00100000000L, active1, 0L); + return jjMoveStringLiteralDfa5_0(active0, 0xc001000000000L, active1, 0x4L); case 116: - if ((active0 & 0x40L) != 0L) - return jjStartNfaWithStates_0(4, 6, 23); + if ((active0 & 0x400L) != 0L) + return jjStartNfaWithStates_0(4, 10, 23); break; case 117: - return jjMoveStringLiteralDfa5_0(active0, 0x800000L, active1, 0L); + return jjMoveStringLiteralDfa5_0(active0, 0x8000000L, active1, 0L); case 121: - return jjMoveStringLiteralDfa5_0(active0, 0x200000L, active1, 0L); + return jjMoveStringLiteralDfa5_0(active0, 0x2000000L, active1, 0L); default : break; } @@ -646,52 +663,52 @@ static private int jjMoveStringLiteralDfa5_0(long old0, long active0, long old1, switch(curChar) { case 97: - return jjMoveStringLiteralDfa6_0(active0, 0x8009000000080000L, active1, 0x84L); + return jjMoveStringLiteralDfa6_0(active0, 0x90000000800000L, active1, 0x848L); case 98: - return jjMoveStringLiteralDfa6_0(active0, 0x400000000000000L, active1, 0L); + return jjMoveStringLiteralDfa6_0(active0, 0x4000000000000000L, active1, 0L); case 100: - return jjMoveStringLiteralDfa6_0(active0, 0x4000000000020000L, active1, 0L); + return jjMoveStringLiteralDfa6_0(active0, 0x200000L, active1, 0x4L); case 101: - if ((active0 & 0x1000L) != 0L) - return jjStartNfaWithStates_0(5, 12, 23); - else if ((active0 & 0x80000000000L) != 0L) - return jjStartNfaWithStates_0(5, 43, 23); + if ((active0 & 0x10000L) != 0L) + return jjStartNfaWithStates_0(5, 16, 23); + else if ((active0 & 0x800000000000L) != 0L) + return jjStartNfaWithStates_0(5, 47, 23); break; case 105: - return jjMoveStringLiteralDfa6_0(active0, 0x12000100008000L, active1, 0x9L); + return jjMoveStringLiteralDfa6_0(active0, 0x120001000080000L, active1, 0x90L); case 108: - if ((active0 & 0x20000000L) != 0L) - return jjStartNfaWithStates_0(5, 29, 23); - return jjMoveStringLiteralDfa6_0(active0, 0x800000L, active1, 0L); + if ((active0 & 0x200000000L) != 0L) + return jjStartNfaWithStates_0(5, 33, 23); + return jjMoveStringLiteralDfa6_0(active0, 0x8000000L, active1, 0L); case 109: - if ((active1 & 0x400L) != 0L) - return jjStartNfaWithStates_0(5, 74, 23); + if ((active1 & 0x4000L) != 0L) + return jjStartNfaWithStates_0(5, 78, 23); break; case 110: - if ((active0 & 0x2000000000L) != 0L) - return jjStartNfaWithStates_0(5, 37, 23); - else if ((active0 & 0x20000000000L) != 0L) + if ((active0 & 0x20000000000L) != 0L) return jjStartNfaWithStates_0(5, 41, 23); + else if ((active0 & 0x200000000000L) != 0L) + return jjStartNfaWithStates_0(5, 45, 23); break; case 114: - if ((active0 & 0x1000000L) != 0L) - return jjStartNfaWithStates_0(5, 24, 23); - else if ((active0 & 0x80000000000000L) != 0L) - return jjStartNfaWithStates_0(5, 55, 23); + if ((active0 & 0x10000000L) != 0L) + return jjStartNfaWithStates_0(5, 28, 23); + else if ((active0 & 0x800000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 59, 23); break; case 115: - return jjMoveStringLiteralDfa6_0(active0, 0x240000L, active1, 0L); + return jjMoveStringLiteralDfa6_0(active0, 0x2400000L, active1, 0L); case 116: - return jjMoveStringLiteralDfa6_0(active0, 0x200000000000L, active1, 0L); + return jjMoveStringLiteralDfa6_0(active0, 0x2000000000000L, active1, 0L); case 118: - return jjMoveStringLiteralDfa6_0(active0, 0xc00000010000L, active1, 0L); + return jjMoveStringLiteralDfa6_0(active0, 0xc000000100000L, active1, 0L); case 119: - return jjMoveStringLiteralDfa6_0(active0, 0x100000L, active1, 0L); + return jjMoveStringLiteralDfa6_0(active0, 0x1000000L, active1, 0L); case 120: - if ((active0 & 0x1000000000L) != 0L) - return jjStartNfaWithStates_0(5, 36, 23); - else if ((active0 & 0x10000000000L) != 0L) + if ((active0 & 0x10000000000L) != 0L) return jjStartNfaWithStates_0(5, 40, 23); + else if ((active0 & 0x100000000000L) != 0L) + return jjStartNfaWithStates_0(5, 44, 23); break; default : break; @@ -709,45 +726,45 @@ static private int jjMoveStringLiteralDfa6_0(long old0, long active0, long old1, switch(curChar) { case 97: - if ((active0 & 0x800000L) != 0L) - return jjStartNfaWithStates_0(6, 23, 23); - return jjMoveStringLiteralDfa7_0(active0, 0xc00100110000L, active1, 0L); + if ((active0 & 0x8000000L) != 0L) + return jjStartNfaWithStates_0(6, 27, 23); + return jjMoveStringLiteralDfa7_0(active0, 0xc001001100000L, active1, 0L); case 101: - return jjMoveStringLiteralDfa7_0(active0, 0x200000040000L, active1, 0L); + return jjMoveStringLiteralDfa7_0(active0, 0x2000000400000L, active1, 0L); case 105: - return jjMoveStringLiteralDfa7_0(active0, 0x400000000000000L, active1, 0L); + return jjMoveStringLiteralDfa7_0(active0, 0x4000000000000000L, active1, 0L); case 110: - if ((active0 & 0x2000000000000L) != 0L) - return jjStartNfaWithStates_0(6, 49, 23); - else if ((active0 & 0x10000000000000L) != 0L) - return jjStartNfaWithStates_0(6, 52, 23); - else if ((active1 & 0x1L) != 0L) - return jjStartNfaWithStates_0(6, 64, 23); - else if ((active1 & 0x8L) != 0L) - return jjStartNfaWithStates_0(6, 67, 23); + if ((active0 & 0x20000000000000L) != 0L) + return jjStartNfaWithStates_0(6, 53, 23); + else if ((active0 & 0x100000000000000L) != 0L) + return jjStartNfaWithStates_0(6, 56, 23); + else if ((active1 & 0x10L) != 0L) + return jjStartNfaWithStates_0(6, 68, 23); + else if ((active1 & 0x80L) != 0L) + return jjStartNfaWithStates_0(6, 71, 23); break; case 115: - if ((active0 & 0x4000000000000000L) != 0L) - return jjStartNfaWithStates_0(6, 62, 23); - return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x80L); + if ((active1 & 0x4L) != 0L) + return jjStartNfaWithStates_0(6, 66, 23); + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x800L); case 116: - if ((active0 & 0x8000L) != 0L) - return jjStartNfaWithStates_0(6, 15, 23); - return jjMoveStringLiteralDfa7_0(active0, 0x200000L, active1, 0L); + if ((active0 & 0x80000L) != 0L) + return jjStartNfaWithStates_0(6, 19, 23); + return jjMoveStringLiteralDfa7_0(active0, 0x2000000L, active1, 0L); case 117: - return jjMoveStringLiteralDfa7_0(active0, 0x20000L, active1, 0L); + return jjMoveStringLiteralDfa7_0(active0, 0x200000L, active1, 0L); case 120: - if ((active0 & 0x1000000000000L) != 0L) - return jjStartNfaWithStates_0(6, 48, 23); - else if ((active0 & 0x8000000000000L) != 0L) - return jjStartNfaWithStates_0(6, 51, 23); - else if ((active0 & 0x8000000000000000L) != 0L) - return jjStartNfaWithStates_0(6, 63, 23); - else if ((active1 & 0x4L) != 0L) - return jjStartNfaWithStates_0(6, 66, 23); + if ((active0 & 0x10000000000000L) != 0L) + return jjStartNfaWithStates_0(6, 52, 23); + else if ((active0 & 0x80000000000000L) != 0L) + return jjStartNfaWithStates_0(6, 55, 23); + else if ((active1 & 0x8L) != 0L) + return jjStartNfaWithStates_0(6, 67, 23); + else if ((active1 & 0x40L) != 0L) + return jjStartNfaWithStates_0(6, 70, 23); break; case 121: - return jjMoveStringLiteralDfa7_0(active0, 0x80000L, active1, 0L); + return jjMoveStringLiteralDfa7_0(active0, 0x800000L, active1, 0L); default : break; } @@ -764,17 +781,17 @@ static private int jjMoveStringLiteralDfa7_0(long old0, long active0, long old1, switch(curChar) { case 98: - return jjMoveStringLiteralDfa8_0(active0, 0xc00000000000L, active1, 0L); + return jjMoveStringLiteralDfa8_0(active0, 0xc000000000000L, active1, 0L); case 101: - return jjMoveStringLiteralDfa8_0(active0, 0x280000L, active1, 0L); + return jjMoveStringLiteralDfa8_0(active0, 0x2800000L, active1, 0L); case 108: - return jjMoveStringLiteralDfa8_0(active0, 0x400000000020000L, active1, 0L); + return jjMoveStringLiteralDfa8_0(active0, 0x4000000000200000L, active1, 0L); case 110: - return jjMoveStringLiteralDfa8_0(active0, 0x100000000L, active1, 0L); + return jjMoveStringLiteralDfa8_0(active0, 0x1000000000L, active1, 0L); case 114: - return jjMoveStringLiteralDfa8_0(active0, 0x200000150000L, active1, 0L); + return jjMoveStringLiteralDfa8_0(active0, 0x2000001500000L, active1, 0L); case 116: - return jjMoveStringLiteralDfa8_0(active0, 0L, active1, 0x80L); + return jjMoveStringLiteralDfa8_0(active0, 0L, active1, 0x800L); default : break; } @@ -791,29 +808,29 @@ static private int jjMoveStringLiteralDfa8_0(long old0, long active0, long old1, switch(curChar) { case 100: - return jjMoveStringLiteralDfa9_0(active0, 0x100000L, active1, 0L); + return jjMoveStringLiteralDfa9_0(active0, 0x1000000L, active1, 0L); case 101: - if ((active0 & 0x20000L) != 0L) - return jjStartNfaWithStates_0(8, 17, 23); + if ((active0 & 0x200000L) != 0L) + return jjStartNfaWithStates_0(8, 21, 23); break; case 105: - return jjMoveStringLiteralDfa9_0(active0, 0x400000000010000L, active1, 0x80L); + return jjMoveStringLiteralDfa9_0(active0, 0x4000000000100000L, active1, 0x800L); case 108: - return jjMoveStringLiteralDfa9_0(active0, 0xc00000000000L, active1, 0L); + return jjMoveStringLiteralDfa9_0(active0, 0xc000000000000L, active1, 0L); case 109: - if ((active0 & 0x200000L) != 0L) - return jjStartNfaWithStates_0(8, 21, 23); - return jjMoveStringLiteralDfa9_0(active0, 0x200000000000L, active1, 0L); + if ((active0 & 0x2000000L) != 0L) + return jjStartNfaWithStates_0(8, 25, 23); + return jjMoveStringLiteralDfa9_0(active0, 0x2000000000000L, active1, 0L); case 114: - if ((active0 & 0x80000L) != 0L) - return jjStartNfaWithStates_0(8, 19, 23); + if ((active0 & 0x800000L) != 0L) + return jjStartNfaWithStates_0(8, 23, 23); break; case 116: - if ((active0 & 0x100000000L) != 0L) - return jjStartNfaWithStates_0(8, 32, 23); + if ((active0 & 0x1000000000L) != 0L) + return jjStartNfaWithStates_0(8, 36, 23); break; case 118: - return jjMoveStringLiteralDfa9_0(active0, 0x40000L, active1, 0L); + return jjMoveStringLiteralDfa9_0(active0, 0x400000L, active1, 0L); default : break; } @@ -830,24 +847,24 @@ static private int jjMoveStringLiteralDfa9_0(long old0, long active0, long old1, switch(curChar) { case 97: - return jjMoveStringLiteralDfa10_0(active0, 0x50000L, active1, 0L); + return jjMoveStringLiteralDfa10_0(active0, 0x500000L, active1, 0L); case 99: - if ((active1 & 0x80L) != 0L) - return jjStartNfaWithStates_0(9, 71, 23); + if ((active1 & 0x800L) != 0L) + return jjStartNfaWithStates_0(9, 75, 23); break; case 101: - if ((active0 & 0x400000000000L) != 0L) + if ((active0 & 0x4000000000000L) != 0L) { - jjmatchedKind = 46; + jjmatchedKind = 50; jjmatchedPos = 9; } - return jjMoveStringLiteralDfa10_0(active0, 0x800000000000L, active1, 0L); + return jjMoveStringLiteralDfa10_0(active0, 0x8000000000000L, active1, 0L); case 105: - return jjMoveStringLiteralDfa10_0(active0, 0x200000000000L, active1, 0L); + return jjMoveStringLiteralDfa10_0(active0, 0x2000000000000L, active1, 0L); case 115: - if ((active0 & 0x100000L) != 0L) - return jjStartNfaWithStates_0(9, 20, 23); - return jjMoveStringLiteralDfa10_0(active0, 0x400000000000000L, active1, 0L); + if ((active0 & 0x1000000L) != 0L) + return jjStartNfaWithStates_0(9, 24, 23); + return jjMoveStringLiteralDfa10_0(active0, 0x4000000000000000L, active1, 0L); default : break; } @@ -864,15 +881,15 @@ static private int jjMoveStringLiteralDfa10_0(long old0, long active0, long old1 switch(curChar) { case 98: - return jjMoveStringLiteralDfa11_0(active0, 0x40000L); + return jjMoveStringLiteralDfa11_0(active0, 0x400000L); case 110: - return jjMoveStringLiteralDfa11_0(active0, 0x200000010000L); + return jjMoveStringLiteralDfa11_0(active0, 0x2000000100000L); case 115: - if ((active0 & 0x800000000000L) != 0L) - return jjStartNfaWithStates_0(10, 47, 23); + if ((active0 & 0x8000000000000L) != 0L) + return jjStartNfaWithStates_0(10, 51, 23); break; case 116: - return jjMoveStringLiteralDfa11_0(active0, 0x400000000000000L); + return jjMoveStringLiteralDfa11_0(active0, 0x4000000000000000L); default : break; } @@ -889,12 +906,12 @@ static private int jjMoveStringLiteralDfa11_0(long old0, long active0){ switch(curChar) { case 105: - return jjMoveStringLiteralDfa12_0(active0, 0x400200000000000L); + return jjMoveStringLiteralDfa12_0(active0, 0x4002000000000000L); case 108: - return jjMoveStringLiteralDfa12_0(active0, 0x40000L); + return jjMoveStringLiteralDfa12_0(active0, 0x400000L); case 116: - if ((active0 & 0x10000L) != 0L) - return jjStartNfaWithStates_0(11, 16, 23); + if ((active0 & 0x100000L) != 0L) + return jjStartNfaWithStates_0(11, 20, 23); break; default : break; @@ -912,13 +929,13 @@ static private int jjMoveStringLiteralDfa12_0(long old0, long active0){ switch(curChar) { case 99: - if ((active0 & 0x400000000000000L) != 0L) - return jjStartNfaWithStates_0(12, 58, 23); + if ((active0 & 0x4000000000000000L) != 0L) + return jjStartNfaWithStates_0(12, 62, 23); break; case 101: - return jjMoveStringLiteralDfa13_0(active0, 0x40000L); + return jjMoveStringLiteralDfa13_0(active0, 0x400000L); case 115: - return jjMoveStringLiteralDfa13_0(active0, 0x200000000000L); + return jjMoveStringLiteralDfa13_0(active0, 0x2000000000000L); default : break; } @@ -935,11 +952,11 @@ static private int jjMoveStringLiteralDfa13_0(long old0, long active0){ switch(curChar) { case 115: - if ((active0 & 0x40000L) != 0L) - return jjStartNfaWithStates_0(13, 18, 23); + if ((active0 & 0x400000L) != 0L) + return jjStartNfaWithStates_0(13, 22, 23); break; case 116: - return jjMoveStringLiteralDfa14_0(active0, 0x200000000000L); + return jjMoveStringLiteralDfa14_0(active0, 0x2000000000000L); default : break; } @@ -956,7 +973,7 @@ static private int jjMoveStringLiteralDfa14_0(long old0, long active0){ switch(curChar) { case 105: - return jjMoveStringLiteralDfa15_0(active0, 0x200000000000L); + return jjMoveStringLiteralDfa15_0(active0, 0x2000000000000L); default : break; } @@ -973,8 +990,8 @@ static private int jjMoveStringLiteralDfa15_0(long old0, long active0){ switch(curChar) { case 99: - if ((active0 & 0x200000000000L) != 0L) - return jjStartNfaWithStates_0(15, 45, 23); + if ((active0 & 0x2000000000000L) != 0L) + return jjStartNfaWithStates_0(15, 49, 23); break; default : break; @@ -1016,14 +1033,14 @@ static private int jjMoveNfa_0(int startState, int curPos) case 23: if ((0x3ff000000000000L & l) != 0L) { - if (kind > 116) - kind = 116; + if (kind > 120) + kind = 120; { jjCheckNAdd(22); } } else if (curChar == 39) { - if (kind > 115) - kind = 115; + if (kind > 119) + kind = 119; } if ((0x3ff000000000000L & l) != 0L) { jjCheckNAddTwoStates(20, 21); } @@ -1031,8 +1048,8 @@ else if (curChar == 39) case 0: if ((0x3ff000000000000L & l) != 0L) { - if (kind > 114) - kind = 114; + if (kind > 118) + kind = 118; { jjCheckNAddStates(0, 3); } } else if ((0x100002600L & l) != 0L) @@ -1048,14 +1065,14 @@ else if (curChar == 47) jjstateSet[jjnewStateCnt++] = 1; if ((0x3fe000000000000L & l) != 0L) { - if (kind > 113) - kind = 113; + if (kind > 117) + kind = 117; { jjCheckNAdd(8); } } else if (curChar == 48) { - if (kind > 113) - kind = 113; + if (kind > 117) + kind = 117; } break; case 1: @@ -1091,20 +1108,20 @@ else if (curChar == 48) case 7: if ((0x3fe000000000000L & l) == 0L) break; - if (kind > 113) - kind = 113; + if (kind > 117) + kind = 117; { jjCheckNAdd(8); } break; case 8: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 113) - kind = 113; + if (kind > 117) + kind = 117; { jjCheckNAdd(8); } break; case 9: - if (curChar == 48 && kind > 113) - kind = 113; + if (curChar == 48 && kind > 117) + kind = 117; break; case 10: if (curChar == 46) @@ -1113,8 +1130,8 @@ else if (curChar == 48) case 11: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 114) - kind = 114; + if (kind > 118) + kind = 118; { jjCheckNAddTwoStates(11, 12); } break; case 13: @@ -1124,8 +1141,8 @@ else if (curChar == 48) case 14: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 114) - kind = 114; + if (kind > 118) + kind = 118; { jjCheckNAdd(14); } break; case 15: @@ -1137,14 +1154,14 @@ else if (curChar == 48) { jjCheckNAddTwoStates(16, 17); } break; case 17: - if (curChar == 35 && kind > 117) - kind = 117; + if (curChar == 35 && kind > 121) + kind = 121; break; case 18: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 114) - kind = 114; + if (kind > 118) + kind = 118; { jjCheckNAddStates(0, 3); } break; case 20: @@ -1152,14 +1169,14 @@ else if (curChar == 48) { jjCheckNAddTwoStates(20, 21); } break; case 21: - if (curChar == 39 && kind > 115) - kind = 115; + if (curChar == 39 && kind > 119) + kind = 119; break; case 22: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 116) - kind = 116; + if (kind > 120) + kind = 120; { jjCheckNAdd(22); } break; default : break; @@ -1176,8 +1193,8 @@ else if (curChar < 128) case 23: if ((0x7fffffe87fffffeL & l) != 0L) { - if (kind > 116) - kind = 116; + if (kind > 120) + kind = 120; { jjCheckNAdd(22); } } if ((0x7fffffe87fffffeL & l) != 0L) @@ -1186,8 +1203,8 @@ else if (curChar < 128) case 0: if ((0x7fffffe87fffffeL & l) == 0L) break; - if (kind > 116) - kind = 116; + if (kind > 120) + kind = 120; { jjCheckNAddStates(7, 9); } break; case 2: @@ -1209,8 +1226,8 @@ else if (curChar < 128) case 22: if ((0x7fffffe87fffffeL & l) == 0L) break; - if (kind > 116) - kind = 116; + if (kind > 120) + kind = 120; { jjCheckNAdd(22); } break; default : break; @@ -1239,7 +1256,7 @@ else if (curChar < 128) if (jjCanMove_0(hiByte, i1, i2, l1, l2)) { jjAddStates(12, 13); } break; - default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; } } while(i != startsAt); } @@ -1256,18 +1273,33 @@ else if (curChar < 128) catch(java.io.IOException e) { return curPos; } } } +static final int[] jjnextStates = { + 10, 11, 12, 18, 2, 3, 5, 20, 21, 22, 13, 14, 16, 17, +}; +private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) +{ + switch(hiByte) + { + case 0: + return ((jjbitVec2[i2] & l2) != 0L); + default : + if ((jjbitVec0[i1] & l1) != 0L) + return true; + return false; + } +} /** Token literal values. */ public static final String[] jjstrLiteralImages = { -"", null, null, "\101", "\142\157\157\154", "\143\154\157\143\153", -"\143\157\156\163\164", "\143\163\147", "\143\164\155\143", "\143\164\155\144\160", "\103", -"\144\151\163\143", "\144\157\165\142\154\145", "\144\164\155\143", "\105", -"\145\156\144\151\156\151\164", "\145\156\144\151\156\166\141\162\151\141\156\164", -"\145\156\144\155\157\144\165\154\145", "\145\156\144\157\142\163\145\162\166\141\142\154\145\163", -"\145\156\144\160\154\141\171\145\162", "\145\156\144\162\145\167\141\162\144\163", -"\145\156\144\163\171\163\164\145\155", "\146\141\154\163\145", "\146\157\162\155\165\154\141", -"\146\151\154\164\145\162", "\146\165\156\143", "\106", "\106\143", "\106\60", "\147\154\157\142\141\154", -"\107", "\151\156\151\164", "\151\156\166\141\162\151\141\156\164", "\111", +"", null, null, "\116\105", "\103\105", "\123\127", "\106\122", "\101", +"\142\157\157\154", "\143\154\157\143\153", "\143\157\156\163\164", "\143\163\147", +"\143\164\155\143", "\143\164\155\144\160", "\103", "\144\151\163\143", +"\144\157\165\142\154\145", "\144\164\155\143", "\105", "\145\156\144\151\156\151\164", +"\145\156\144\151\156\166\141\162\151\141\156\164", "\145\156\144\155\157\144\165\154\145", +"\145\156\144\157\142\163\145\162\166\141\142\154\145\163", "\145\156\144\160\154\141\171\145\162", +"\145\156\144\162\145\167\141\162\144\163", "\145\156\144\163\171\163\164\145\155", "\146\141\154\163\145", +"\146\157\162\155\165\154\141", "\146\151\154\164\145\162", "\146\165\156\143", "\106", "\106\143", "\106\60", +"\147\154\157\142\141\154", "\107", "\151\156\151\164", "\151\156\166\141\162\151\141\156\164", "\111", "\151\156\164", "\154\141\142\145\154", "\155\141\170\155\141\170", "\155\141\170\155\151\156", "\155\141\170", "\155\144\160", "\155\151\156\155\141\170", "\155\151\156\155\151\156", "\155\151\156", "\155\157\144\165\154\145", "\130", @@ -1308,21 +1340,6 @@ static protected Token jjFillToken() return t; } -static final int[] jjnextStates = { - 10, 11, 12, 18, 2, 3, 5, 20, 21, 22, 13, 14, 16, 17, -}; -private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) -{ - switch(hiByte) - { - case 0: - return ((jjbitVec2[i2] & l2) != 0L); - default : - if ((jjbitVec0[i1] & l1) != 0L) - return true; - return false; - } -} static int curLexState = 0; static int defaultLexState = 0; @@ -1345,7 +1362,7 @@ public static Token getNextToken() { curChar = input_stream.BeginToken(); } - catch(Exception e) + catch(java.io.IOException e) { jjmatchedKind = 0; jjmatchedPos = -1; @@ -1357,9 +1374,9 @@ public static Token getNextToken() jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_0(); - if (jjmatchedPos == 0 && jjmatchedKind > 118) + if (jjmatchedPos == 0 && jjmatchedKind > 122) { - jjmatchedKind = 118; + jjmatchedKind = 122; } if (jjmatchedKind != 0x7fffffff) { @@ -1410,31 +1427,6 @@ public static Token getNextToken() } } -static void SkipLexicalActions(Token matchedToken) -{ - switch(jjmatchedKind) - { - default : - break; - } -} -static void MoreLexicalActions() -{ - jjimageLen += (lengthOfMatch = jjmatchedPos + 1); - switch(jjmatchedKind) - { - default : - break; - } -} -static void TokenLexicalActions(Token matchedToken) -{ - switch(jjmatchedKind) - { - default : - break; - } -} static private void jjCheckNAdd(int state) { if (jjrounds[state] != jjround) @@ -1478,14 +1470,9 @@ public PrismParserTokenManager (SimpleCharStream stream, int lexState){ } /** Reinitialise parser. */ - static public void ReInit(SimpleCharStream stream) { - - - jjmatchedPos = - jjnewStateCnt = - 0; + jjmatchedPos = jjnewStateCnt = 0; curLexState = defaultLexState; input_stream = stream; ReInitRounds(); @@ -1501,14 +1488,13 @@ static private void ReInitRounds() /** Reinitialise parser. */ static public void ReInit(SimpleCharStream stream, int lexState) - { ReInit(stream); SwitchTo(lexState); } /** Switch to specified lex state. */ - public static void SwitchTo(int lexState) + static public void SwitchTo(int lexState) { if (lexState >= 1 || lexState < 0) throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); @@ -1516,39 +1502,24 @@ public static void SwitchTo(int lexState) curLexState = lexState; } - /** Lexer state names. */ public static final String[] lexStateNames = { "DEFAULT", }; - -/** Lex State array. */ -public static final int[] jjnewLexState = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; static final long[] jjtoToken = { - 0xfffffffffffffff9L, 0x7fffffffffffffL, + 0xfffffffffffffff9L, 0x7ffffffffffffffL, }; static final long[] jjtoSkip = { 0x6L, 0x0L, }; static final long[] jjtoSpecial = { 0x6L, 0x0L, -}; -static final long[] jjtoMore = { - 0x0L, 0x0L, }; static protected SimpleCharStream input_stream; static private final int[] jjrounds = new int[23]; static private final int[] jjstateSet = new int[2 * 23]; - private static final StringBuilder jjimage = new StringBuilder(); - private static StringBuilder image = jjimage; - private static int jjimageLen; - private static int lengthOfMatch; - static protected int curChar; + + + static protected char curChar; } diff --git a/prism/src/parser/SimpleCharStream.java b/prism/src/parser/SimpleCharStream.java index 889869b61..73d4c7f45 100644 --- a/prism/src/parser/SimpleCharStream.java +++ b/prism/src/parser/SimpleCharStream.java @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 7.0 */ +/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 6.0 */ /* JavaCCOptions:STATIC=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package parser; @@ -30,14 +30,13 @@ public class SimpleCharStream static protected char[] buffer; static protected int maxNextCharInd = 0; static protected int inBuf = 0; - static protected int tabSize = 1; - static protected boolean trackLineColumn = true; + static protected int tabSize = 8; + static protected boolean trackLineColumn = false; static public void setTabSize(int i) { tabSize = i; } static public int getTabSize() { return tabSize; } - static protected void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; @@ -472,7 +471,8 @@ static public void adjustBeginLineColumn(int newLine, int newCol) line = bufline[j]; column = bufcolumn[j]; } + static boolean getTrackLineColumn() { return trackLineColumn; } - static void setTrackLineColumn(boolean tlc) { trackLineColumn = tlc; } + static void setTrackLineColumn(boolean trackLineColumn) { trackLineColumn = trackLineColumn; } } -/* JavaCC - OriginalChecksum=312d39869f3bfc3a64bf5e66d85fffff (do not edit this line) */ +/* JavaCC - OriginalChecksum=81090b92d191fc568cf66cb10dcab351 (do not edit this line) */ diff --git a/prism/src/parser/Token.java b/prism/src/parser/Token.java index 49f0d85dc..acc5cc308 100644 --- a/prism/src/parser/Token.java +++ b/prism/src/parser/Token.java @@ -1,5 +1,5 @@ -/* Generated By:JavaCC: Do not edit this line. Token.java Version 7.0 */ -/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +/* Generated By:JavaCC: Do not edit this line. Token.java Version 6.0 */ +/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package parser; /** @@ -97,7 +97,6 @@ public Token(int kind, String image) /** * Returns the image. */ - @Override public String toString() { return image; @@ -129,4 +128,4 @@ public static Token newToken(int ofKind) } } -/* JavaCC - OriginalChecksum=a6e99fa366f40513e8823da999781b1f (do not edit this line) */ +/* JavaCC - OriginalChecksum=7d751264ae152bf5b6855a5f69a4ab67 (do not edit this line) */ diff --git a/prism/src/parser/TokenMgrError.java b/prism/src/parser/TokenMgrError.java index 84cacc780..bc8ef8be2 100644 --- a/prism/src/parser/TokenMgrError.java +++ b/prism/src/parser/TokenMgrError.java @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 7.0 */ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 6.0 */ /* JavaCCOptions: */ package parser; @@ -20,22 +20,22 @@ public class TokenMgrError extends Error /** * Lexical error occurred. */ - public static final int LEXICAL_ERROR = 0; + static final int LEXICAL_ERROR = 0; /** * An attempt was made to create a second instance of a static token manager. */ - public static final int STATIC_LEXER_ERROR = 1; + static final int STATIC_LEXER_ERROR = 1; /** * Tried to change to an invalid lexical state. */ - public static final int INVALID_LEXICAL_STATE = 2; + static final int INVALID_LEXICAL_STATE = 2; /** * Detected (and bailed out of) an infinite loop in the token manager. */ - public static final int LOOP_DETECTED = 3; + static final int LOOP_DETECTED = 3; /** * Indicates the reason why the exception is thrown. It will have @@ -48,11 +48,13 @@ public class TokenMgrError extends Error * equivalents in the given string */ protected static final String addEscapes(String str) { - StringBuilder retval = new StringBuilder(); + StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { + case 0 : + continue; case '\b': retval.append("\\b"); continue; @@ -102,12 +104,11 @@ protected static final String addEscapes(String str) { * curchar : the offending character * Note: You can customize the lexical error message by modifying this method. */ - protected static String LexicalErr(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar) { - char curChar1 = (char)curChar; + protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + - (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar1)) + "\"") + " (" + curChar + "), ") + + (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + "after : \"" + addEscapes(errorAfter) + "\""); } @@ -120,7 +121,6 @@ protected static String LexicalErr(boolean EOFSeen, int lexState, int errorLine, * * from this method for such cases in the release version of your parser. */ - @Override public String getMessage() { return super.getMessage(); } @@ -140,8 +140,8 @@ public TokenMgrError(String message, int reason) { } /** Full Constructor. */ - public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) { - this(LexicalErr(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); + public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { + this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } -/* JavaCC - OriginalChecksum=247c264b970b850ff3f25ab9073c801d (do not edit this line) */ +/* JavaCC - OriginalChecksum=6c4705c2bebd89492711d8a1e624d837 (do not edit this line) */ diff --git a/prism/src/parser/ast/ExpressionMultiNash.java b/prism/src/parser/ast/ExpressionMultiNash.java index 7e5423d06..ef78346b1 100644 --- a/prism/src/parser/ast/ExpressionMultiNash.java +++ b/prism/src/parser/ast/ExpressionMultiNash.java @@ -19,7 +19,16 @@ public class ExpressionMultiNash extends Expression protected Expression bound = null; // Operands protected ArrayList operands; + // Type of equilibrium + protected int eqType; + // Criterion + protected int crit; + public static final int NASH = 1; + public static final int CORR = 2; + public static final int SWEQ = 3; + public static final int FAIR = 4; + // Constructors public ExpressionMultiNash() @@ -65,6 +74,16 @@ public void setOperand(int i, ExpressionQuant e) operands.set(i, e); } + public void setEqType(int eqType) + { + this.eqType = eqType; + } + + public void setCrit(int crit) + { + this.crit = crit; + } + // Get methods /** @@ -107,6 +126,16 @@ public OpRelOpBound getRelopBoundInfo(Values constantValues) throws PrismLangExc return new OpRelOpBound("", getRelOp(), null); } } + + public int getEqType() + { + return eqType; + } + + public int getCrit() + { + return crit; + } // Methods required for Expression: @@ -168,7 +197,13 @@ public Expression deepCopy() @Override public String toString() { - String s = ""; + String s = "{"; + if (getEqType() == 1) s+= "NE"; + if (getEqType() == 2) s+= "CE"; + s += ","; + if (getCrit() == 3) s+= "SW"; + if (getCrit() == 4) s+= "FR"; + s += "}"; s += getRelOp(); s += (getBound() == null) ? "?" : getBound().toString(); s += " ("; @@ -211,6 +246,10 @@ public boolean equals(Object obj) return false; } else if (!bound.equals(other.bound)) return false; + if (eqType != other.eqType) + return false; + if (crit != other.crit) + return false; if (operands == null) { if (other.operands != null) return false; diff --git a/prism/src/prism/PrismSettings.java b/prism/src/prism/PrismSettings.java index ba3d34266..bde909543 100644 --- a/prism/src/prism/PrismSettings.java +++ b/prism/src/prism/PrismSettings.java @@ -132,25 +132,27 @@ public class PrismSettings implements Observer // csg and equilibria public static final String PRISM_ZS_LP_SCALE_FACTOR = "prism.lpscalefactor"; - + public static final String PRISM_EQ_ASSUMPTION_CHECK = "prism.eqassumptioncheck"; + public static final String PRISM_CSG_LPSOLVER = "prism.csglpsolver"; + // multi-objective synthesis for games public static final String PRISM_MULTI_GAUSS_SEIDEL = "prism.multiGaussSeidel"; - // iteration control - public static final String PRISM_MULTI_MAX_C_ITER = "prism.multiMaxCIter"; - public static final String PRISM_MULTI_MAX_R_ITER = "prism.multiMaxRIter"; - public static final String PRISM_MULTI_MAX_D_ITER = "prism.multiMaxDIter"; - public static final String PRISM_MULTI_D_ITER_OFFSET = "prism.multiDIterOffset"; - public static final String PRISM_MULTI_MIN_M = "prism.multiMinM"; - public static final String PRISM_MULTI_MAX_M = "prism.multiMaxM"; - // rounding - public static final String PRISM_MULTI_ROUNDING = "prism.multiRounding"; - public static final String PRISM_MULTI_BASELINE_ACCURACY = "prism.baselineAccuracy"; - public static final String PRISM_MULTI_INCREASE_FACTOR = "prism.increaseFactor"; - // logging - public static final String LOG_MULTI_C_PARETO = "log.multiCPareto"; - public static final String LOG_MULTI_D_PARETO = "log.multiDPareto"; - public static final String LOG_MULTI_R_PARETO = "log.multiRPareto"; - public static final String LOG_MULTI_STRATEGY = "log.multiStrategy"; + // iteration control + public static final String PRISM_MULTI_MAX_C_ITER = "prism.multiMaxCIter"; + public static final String PRISM_MULTI_MAX_R_ITER = "prism.multiMaxRIter"; + public static final String PRISM_MULTI_MAX_D_ITER = "prism.multiMaxDIter"; + public static final String PRISM_MULTI_D_ITER_OFFSET = "prism.multiDIterOffset"; + public static final String PRISM_MULTI_MIN_M = "prism.multiMinM"; + public static final String PRISM_MULTI_MAX_M = "prism.multiMaxM"; + // rounding + public static final String PRISM_MULTI_ROUNDING = "prism.multiRounding"; + public static final String PRISM_MULTI_BASELINE_ACCURACY = "prism.baselineAccuracy"; + public static final String PRISM_MULTI_INCREASE_FACTOR = "prism.increaseFactor"; + // logging + public static final String LOG_MULTI_C_PARETO = "log.multiCPareto"; + public static final String LOG_MULTI_D_PARETO = "log.multiDPareto"; + public static final String LOG_MULTI_R_PARETO = "log.multiRPareto"; + public static final String LOG_MULTI_STRATEGY = "log.multiStrategy"; public static final String PRISM_LTL2DA_TOOL = "prism.ltl2daTool"; @@ -366,7 +368,12 @@ public class PrismSettings implements Observer // CSG ZERO-SUM LP SCALE FACTOR { DOUBLE_TYPE, PRISM_ZS_LP_SCALE_FACTOR, "Scale factor for LPs", "4.5", Double.valueOf(1.0), "1,", "Scale factor used when building linear programs for solving matrix games"}, - + // CSG SOLVER FOR LPS + { CHOICE_TYPE, PRISM_CSG_LPSOLVER, "LP solver for CSGs", "4.5", "Z3", "LpSolve,Z3,Gurobi", + "Solver used when computing solutions for linear programs in CSG model checking"}, + // CSG ASSUMPTION CHECK + { BOOLEAN_TYPE, PRISM_EQ_ASSUMPTION_CHECK, "Assumption check for equilirbia", "4.5", Boolean.valueOf(false), "", + "Assumption check for unbouded equilibria formulae."}, // OUTPUT OPTIONS: { BOOLEAN_TYPE, PRISM_VERBOSE, "Verbose output", "2.1", Boolean.valueOf(false), "", "Display verbose output to log." }, @@ -1168,6 +1175,8 @@ else if (sw.equals("power") || sw.equals("pow") || sw.equals("pwr")) { set(PRISM_MDP_SOLN_METHOD, "Linear programming"); set(PRISM_MDP_MULTI_SOLN_METHOD, "Linear programming"); } + + // CSG-specific else if (sw.equals("lpscalefactor")) {// Scale factor for LPs (zero-sum) if (i < args.length - 1) { try { @@ -1182,6 +1191,24 @@ else if (sw.equals("lpscalefactor")) {// Scale factor for LPs (zero-sum) throw new PrismException("No value specified for -" + sw + " switch"); } } + else if (sw.equals("lpsolver")) { + if (i < args.length - 1) { + s = args[++i]; + if (s.equals("lpsolve")) + set(PRISM_CSG_LPSOLVER, "LpSolve"); + else if (s.equals("z3")) + set(PRISM_CSG_LPSOLVER, "Z3"); + else if (s.equals("gurobi")) + set(PRISM_CSG_LPSOLVER, "Gurobi"); + else + throw new PrismException("Unrecognised option for -" + sw + " switch (options are: lpsolve, z3, gurobi)"); + } else { + throw new PrismException("No value specified for -" + sw + " switch"); + } + } + else if (sw.equals("eqassumptioncheck")) { + set(PRISM_EQ_ASSUMPTION_CHECK, false); + } // Interval iterations else if (sw.equals("intervaliter") || diff --git a/prism/src/strat/CSGStrategy.java b/prism/src/strat/CSGStrategy.java index 09729a1c4..1b1aa541c 100644 --- a/prism/src/strat/CSGStrategy.java +++ b/prism/src/strat/CSGStrategy.java @@ -43,6 +43,7 @@ import prism.PrismComponent; import prism.PrismException; import prism.PrismLog; +import strat.CSGStrategy.CSGStrategyType; public class CSGStrategy extends PrismComponent implements Strategy { @@ -58,7 +59,7 @@ public class CSGStrategy extends PrismComponent implements Strategy { protected int numCoalitions; public enum CSGStrategyType { - ZERO_SUM, EQUILIBRIA_M, EQUILIBRIA_P, EQUILIBRIA_R; + ZERO_SUM, EQUILIBRIA_M, EQUILIBRIA_P, EQUILIBRIA_R, EQUILIBRIA_CE_P, EQUILIBRIA_CE_R, EQUILIBRIA_CE_M; } public CSGStrategy(CSG model, List>>> csgchoices, Map subgames, int numCoalitions, CSGStrategyType type) { @@ -150,6 +151,13 @@ public void exportActions(PrismLog out) { case EQUILIBRIA_R: exportEquilibriaStrategy(out); break; + case EQUILIBRIA_CE_M: + exportMultiEquilibriaStrategy(out); + break; + case EQUILIBRIA_CE_P: + case EQUILIBRIA_CE_R: + exportEquilibriaStrategy(out); + break; } } catch (Exception e) { @@ -226,15 +234,20 @@ public void exportEquilibriaStrategy(PrismLog out) throws PrismException, Invali for (p = 0; p < 2; p++) { reach[p] = new BitSet(); for (i = 0; i < model.getNumStates(); i++) { - if (type == CSGStrategyType.EQUILIBRIA_P) + if (type == CSGStrategyType.EQUILIBRIA_P || type == CSGStrategyType.EQUILIBRIA_CE_P) { if (prechoices[p].soln[i] > 0) reach[p].set(i); - if (type == CSGStrategyType.EQUILIBRIA_R) + } + if (type == CSGStrategyType.EQUILIBRIA_R || type == CSGStrategyType.EQUILIBRIA_CE_R) { if (prechoices[p].soln[i] < Double.POSITIVE_INFINITY) reach[p].set(i); + } } } - generateMDPEquilibria(mdp, onmap, statelist, reach, explored, 0, s); + if (type == CSGStrategyType.EQUILIBRIA_P || type == CSGStrategyType.EQUILIBRIA_R) + generateMDPEquilibria(mdp, onmap, statelist, reach, explored, 0, s); + if (type == CSGStrategyType.EQUILIBRIA_CE_P || type == CSGStrategyType.EQUILIBRIA_CE_R) + generateMDPCorrelatedEquilibria(mdp, onmap, statelist, reach, explored, 0, s); addPrecompStrategies(mdp, onmap, statelist, reach); } mdp.setStatesList(statelist); @@ -475,6 +488,87 @@ else if (!d.isEmpty()) { } } + public void generateMDPMultiCorrelatedEquilibria(MDPSimple mdp, Map onmap, List statelist, BitSet explored, int k, int s) { + Distribution d; + Map prods = new HashMap(); + BitSet tmp = new BitSet(); + BitSet sat = new BitSet(); + String joint = null; + String label = null; + String lsubg = ""; + String prob = ""; + int c, i, m, n, q, p, t; + boolean loop = false; + explored.set(s); + n = onmap.get(s); + for (BitSet subgame : subgames.keySet()) { + if (subgames.get(subgame).get(s)) { + sat.or(subgame); + } + } + for (p = 0; p < numCoalitions; p++) { + if (sat.get(p)) { + lsubg += "Sat(" + p + ")"; + } + else { + lsubg += "Unsat(" + p + ")"; + } + if (p < numCoalitions - 1) + lsubg += " -- "; + } + if (sat.cardinality() == numCoalitions) { + d = new Distribution(); + d.add(n, 1.0); + mdp.addActionLabelledChoice(n, d, lsubg); + } + else { + prods = csgchoices.get(0).get(k).get(s); + d = new Distribution(); + for (t = 0; t < model.getNumChoices(s); t++) { + tmp.clear(); + for (q = 0; q < model.getIndexes(s, t).length; q++) { + i = model.getIndexes(s, t)[q]; + tmp.set((i > 0)? i : model.getIdles()[q]); + } + if (prods.containsKey(tmp)) { + for (int u : model.getChoice(s, t).getSupport()) { + if (!onmap.containsKey(u)) { + m = mdp.addState(); + onmap.put(u, m); + statelist.add(m, model.getStatesList().get(u)); + if (!explored.get(u)) + generateMDPMultiCorrelatedEquilibria(mdp, onmap, statelist, explored, k, u); + } + else { + m = onmap.get(u); + if (m == n && model.getChoice(s, t).getSupport().size() == 1 && model.getNumChoices(s) == 1) + loop = true; + } + d.add(m, model.getChoice(s, t).get(u) * prods.get(tmp)); + } + } + } + if (loop) { + mdp.addActionLabelledChoice(n, d, lsubg); + } + else if (!d.isEmpty()) { + label = "CSG: "; + c = csgchoices.get(0).get(k).get(s).keySet().size(); + for (BitSet act : csgchoices.get(0).get(k).get(s).keySet()) { + prob += csgchoices.get(0).get(k).get(s).get(act) +": "; + joint = ""; + for (i = act.nextSetBit(0); i >= 0; i = act.nextSetBit(i + 1)) { + joint += "[" + model.getActions().get(i - 1) + "]"; + } + c--; + prob += joint + ((c > 0)? " + " : ""); + } + label += prob; + mdp.addActionLabelledChoice(n, d, label); + } + } + } + public void generateMDPEquilibria(MDPSimple mdp, Map onmap, List statelist, BitSet[] reach, BitSet explored, int k, int s) { Distribution d; String[] action = new String[csgchoices.size()]; @@ -557,6 +651,79 @@ else if (!targets[0].get(s) && !targets[1].get(s) && !reach[0].get(s) && !reach[ } } + public void generateMDPCorrelatedEquilibria(MDPSimple mdp, Map onmap, List statelist, BitSet[] reach, BitSet explored, int k, int s) { + Distribution d; + String prob = ""; + String label = null; + String joint = null; + BitSet tmp = new BitSet(); + Map prods = new HashMap(); + int c, i, m, n, q, t; + n = onmap.get(s); + explored.set(s); + if (targets[0].get(s) && targets[1].get(s)) { + d = new Distribution(); + d.add(n, 1.0); + mdp.addActionLabelledChoice(n, d, "CSG: Sat(0) -- Sat(1)"); + } + else if (targets[0].get(s) && !targets[1].get(s) && !reach[0].get(s)) { + d = new Distribution(); + d.add(n, 1.0); + mdp.addActionLabelledChoice(n, d, "CSG: Sat(0) -- Unsat(1)"); + } + else if (!targets[0].get(s) && targets[1].get(s) && !reach[1].get(s)) { + d = new Distribution(); + d.add(n, 1.0); + mdp.addActionLabelledChoice(n, d, "CSG: Unsat(0) -- Sat(1)"); + } + else if (!targets[0].get(s) && !targets[1].get(s) && !reach[0].get(s) && !reach[1].get(s)) { + d = new Distribution(); + d.add(n, 1.0); + mdp.addActionLabelledChoice(n, d, "CSG: Unsat(0) -- Unsat(1)"); + } + else if (csgchoices.get(0).get(k).get(s) != null) { + prods = csgchoices.get(0).get(k).get(s); + d = new Distribution(); + for (t = 0; t < model.getNumChoices(s); t++) { + tmp.clear(); + for (q = 0; q < model.getIndexes(s, t).length; q++) { + i = model.getIndexes(s, t)[q]; + tmp.set((i > 0)? i : model.getIdles()[q]); + } + if (prods.containsKey(tmp)) { + for (int u : model.getChoice(s, t).getSupport()) { + if (!onmap.containsKey(u)) { + m = mdp.addState(); + onmap.put(u, m); + statelist.add(m, model.getStatesList().get(u)); + if (!explored.get(u)) + generateMDPCorrelatedEquilibria(mdp, onmap, statelist, reach, explored, k, u); // should check for explored? + } + else { + m = onmap.get(u); + } + d.add(m, model.getChoice(s, t).get(u) * prods.get(tmp)); + } + } + } + if (!d.isEmpty()) { + label = "CSG: "; + c = csgchoices.get(0).get(k).get(s).keySet().size(); + for (BitSet act : csgchoices.get(0).get(k).get(s).keySet()) { + prob += csgchoices.get(0).get(k).get(s).get(act) +": "; + joint = ""; + for (i = act.nextSetBit(0); i >= 0; i = act.nextSetBit(i + 1)) { + joint += "[" + model.getActions().get(i - 1) + "]"; + } + c--; + prob += joint + ((c > 0)? " + " : ""); + } + label += prob; + mdp.addActionLabelledChoice(n, d, label); + } + } + } + public void generateMDPZeroSum(MDPSimple mdp, Map onmap, List statelist, BitSet explored, int k, int p, int s) { Distribution d; BitSet tmp1 = new BitSet(); @@ -633,4 +800,48 @@ public void clear() { // TODO Auto-generated method stub } + + @Override + public String toString() { + String[] action; + String joint, label; + int c, i, k, p, s; + boolean chck; + label = "CSG:"; + k = 0; + if (csgchoices != null) { + /* + for (List>> entry : csgchoices) { + s += entry.toString(); + s += "\n"; + } + */ + for (s = 0; s < model.getNumStates(); s++) { + action = new String[csgchoices.size()]; + chck = true; + for (p = 0; p < numCoalitions; p++) { + chck = chck && csgchoices.get(p).get(k).get(s) != null; + action[p] = ""; + } + label += " $ s:" + s + " -> "; + for (p = 0; p < numCoalitions; p++) { + if (csgchoices.get(p).get(k).get(s) != null) { + c = csgchoices.get(p).get(k).get(s).keySet().size(); + for (BitSet act : csgchoices.get(p).get(k).get(s).keySet()) { + joint = ""; + for (i = act.nextSetBit(0); i >= 0; i = act.nextSetBit(i + 1)) { + joint += "[" + model.getActions().get(i - 1) + "]"; + } + c--; + action[p] += csgchoices.get(p).get(k).get(s).get(act) +": " + joint + ((c > 0)? " + " : ""); + } + label += (p + 1 < csgchoices.size())? action[p] + " -- " : action[p]; + } + } + } + return label; + } + else + return label; + } }