コード例 #1
0
  @Test
  public void test2() {

    Set<String> res = new HashSet<String>();
    res = Permute.permutation("abc");
    String[] out = res.toArray(new String[res.size()]);
    String[] exp = {"bca", "acb", "abc", "cba", "bac", "cab"};
    assertArrayEquals(exp, out);
  }
コード例 #2
0
  @Test
  public void test1() {

    Set<String> res = new HashSet<String>();
    res = Permute.permutation("111b");
    String[] out = res.toArray(new String[res.size()]);
    String[] exp = {"b111", "1b11", "111b", "11b1"};
    assertArrayEquals(exp, out);
  }
コード例 #3
0
ファイル: Evaluate.java プロジェクト: ucl-cssb/signalMatch
  /**
   * A gate with two transcriptional units (e.g. AND) can have two different wirings. Doesn't matter
   * for a gate with one txn unit.
   *
   * @param g
   * @param gate_library
   * @param options
   */
  public static void setBestVariableMapping(Gate g, GateLibrary gate_library, Args options) {

    ArrayList<ArrayList<String>> variable_name_orders =
        Permute.getVariableNamePermutation(g.get_variable_names());
    Integer best_variable_name_order_index = 0;
    Double best_score = 0.0;

    int v = 0;
    for (ArrayList<String> variable_name_order : variable_name_orders) {

      g.get_outreus().clear();

      for (int i = 0; i < g.get_logics().size(); ++i) { // rows in truth table

        /*if (Args.dontcare_rows.contains(i)) {
            g.get_outreus().add(0.0);
            continue;
        }*/

        GateUtil.mapWiresToVariables(g, variable_name_order);

        double output_reu =
            ResponseFunction.computeOutput(
                GateUtil.getVariableValues(g, i, gate_library, options),
                g.get_params(),
                g.get_equation());

        g.get_outreus().add(output_reu);
      }

      evaluateGate(g, options);

      if (g.get_scores().get_score() > best_score) {
        best_score = g.get_scores().get_score();
        best_variable_name_order_index = v;
      }
      v++;
    }

    // this is the critical part, it's ordering the variable names in the list
    g.set_variable_names(variable_name_orders.get(best_variable_name_order_index));
  }
コード例 #4
0
ファイル: Permute.java プロジェクト: rahul8448/Interview_2013
 /** @param args */
 public static void main(String[] args) {
   // TODO Auto-generated method stub
   Permute pm = new Permute();
   pm.permute("ABCD");
 }