Beispiel #1
0
  public void resetProxy() throws MatlabInvocationException, MatlabConnectionException {
    MatlabProxyFactory factory = new MatlabProxyFactory(options);

    if (proxy.isConnected()) {
      proxy.exit();
    }
    proxy = factory.getProxy();
    runner.eval("clear all");
  }
Beispiel #2
0
 @Override
 public String getVariableString(String var) {
   try {
     return (String) proxy.getVariable(var);
   } catch (MatlabInvocationException e) {
     DBSeerExceptionHandler.handleException(e);
   }
   return null;
 }
Beispiel #3
0
 @Override
 public boolean eval(String str) {
   try {
     proxy.eval(str);
   } catch (MatlabInvocationException e) {
     DBSeerExceptionHandler.handleException(e);
     return false;
   }
   return true;
 }
Beispiel #4
0
  private MatlabRunner() {
    MatlabProxyFactory factory = new MatlabProxyFactory(options);

    try {
      proxy = factory.getProxy();
      proxy.eval("clear all");
    } catch (Exception e) {
      DBSeerExceptionHandler.handleException(e);
    }
  }
Beispiel #5
0
  public static void exporter(LinkedList<profile> usr, MatlabProxy proxy)
      throws MatlabConnectionException, MatlabInvocationException {

    String file = "/Users/richarddavies/NetBeansProjects/typ_MatlabGraph/rotCmp_2012.txt";
    int i = 0;

    try {

      double result;
      int index_a = 0;
      int index_b = 0;
      int item;

      FileWriter fw = new FileWriter(file);
      BufferedWriter bw = new BufferedWriter(fw);
      PrintWriter outFile = new PrintWriter(bw);

      outFile.println("nodedef>name VARCHAR,label VARCHAR,sex VARCHAR,locale VARCHAR");

      for (i = 0; i < usr.size(); i++) {

        outFile.println(
            usr.get(i).idProf
                + ","
                + usr.get(i).firstName
                + ","
                + usr.get(i).gender
                + ","
                + usr.get(i).nat);
      }

      outFile.println("edgedef>node1 VARCHAR,node2 VARCHAR");

      for (i = 0; i < usr.size(); i++) {

        System.out.println(usr.get(i).firstName + ": ");

        for (int j = 0; j < usr.size(); j++) {

          index_a = i + 1;
          index_b = j + 1;

          // result = proxy.getVariable("adjMatrix("+index_a+","+index_b+");");

          result = ((double[]) proxy.getVariable("adjMatrix(" + index_a + "," + index_b + ");"))[0];

          item = (int) result;

          // item = ((Integer)result).intValue();
          // System.out.println(result);
          if (item == 1) {

            System.out.print(" (" + usr.get(j).firstName + ") ");

            outFile.println(usr.get(i).idProf + "," + usr.get(j).idProf);
          }
        }

        System.out.println(" ");
        System.out.println(" ");
        System.out.println(" ");
        System.out.println(" ");
      }

      outFile.close();
    } catch (IOException ex) {
      System.out.println(" error : " + ex);
    }
  }
Beispiel #6
0
  public static LinkedList<edge> importer(MatlabProxy proxy)
      throws IOException, MatlabConnectionException, MatlabInvocationException {

    Scanner sFile;
    edge entry;
    LinkedList<edge> tie = new LinkedList<edge>();
    Long k, p;

    try {
      sFile =
          new Scanner(new File("/Users/richarddavies/NetBeansProjects/typ_MatlabGraph/edges.dat"));

      System.out.println(sFile.nextLine());

      while (sFile.hasNext()) {

        String edge = sFile.nextLine();
        // System.out.println(edge);

        Scanner edgeScan = new Scanner(edge);
        edgeScan.useDelimiter(",");

        while (edgeScan.hasNext()) {

          k = edgeScan.nextLong();
          System.out.print(k + " ");

          String ident_k = String.valueOf(k);
          String rot_Id_k = rot13.encrypt(ident_k);
          Long rot_k = Long.parseLong(rot_Id_k);

          p = edgeScan.nextLong();
          System.out.print(p);

          String ident_p = String.valueOf(p);
          String rot_Id_p = rot13.encrypt(ident_p);
          Long rot_p = Long.parseLong(rot_Id_p);

          // System.out.println(rot_k+" : "+rot_p);
          entry = new edge(k, p);

          int n = search.search(k);
          int m = search.search(p);
          System.out.print(
              " : "
                  + Typ_MatlabGraph.people.get(n).idProf
                  + " "
                  + Typ_MatlabGraph.people.get(m).idProf);
          System.out.println("");
          n++;
          m++;

          proxy.eval("adjMatrix(" + n + "," + m + ") = 1");

          tie.add(entry);
        }
      }

    } catch (IOException ex) {

      System.out.println("(No System File profile.txt)" + ex);
    }

    return tie;
  }