@Override public GreedyState generate( SourceOfRandomness sourceOfRandomness, GenerationStatus generationStatus) { int numTokens = sourceOfRandomness.nextInt(2, 10); String[] tokens = new String[numTokens]; for (int i = 0; i < numTokens; i++) { tokens[i] = "blah"; } int numNodes = sourceOfRandomness.nextInt(2, 10); AMR.Node[] nodes = new AMR.Node[numNodes]; for (int i = 1; i < nodes.length; i++) { nodes[i] = new AMR.Node("b" + i, "blah" + i, AMR.NodeType.ENTITY); nodes[i].alignment = sourceOfRandomness.nextInt(numTokens); } GreedyState state = new GreedyState(nodes, tokens, null); while (!state.finished) { // Sometimes we stop early if (sourceOfRandomness.nextBoolean()) break; // Run a random oracle policy String[] headArcs = new String[nodes.length]; for (int i = 1; i < nodes.length; i++) { if (sourceOfRandomness.nextDouble() > 0.8) { headArcs[i] = "ARG" + sourceOfRandomness.nextInt(4); } else { headArcs[i] = "NONE"; } } state = state.transition(headArcs); } return state; }
public static List<Pair<GreedyState, String[]>> run(GreedyState state, Oracle oracle) { List<Pair<GreedyState, String[]>> decisions = new ArrayList<>(); // Add state progressions and oracle decisions while (!state.finished) { String[] decision = oracle.predictArcs(state); decisions.add(new Pair<>(state, decision)); state = state.transition(decision); } // Add final state decisions.add(new Pair<>(state, null)); return decisions; }