Package com.mockturtlesolutions.jpHtools.database

Examples of com.mockturtlesolutions.jpHtools.database.SMPBStorage


    //Instantiate the buffer's designated generator and run the optimization a bit...
    //String generatorName = remoteStorage.getComplexBufferPredictorGeneratorClass();

    if (remoteStorage.hasTitrationData())
    {
      SMPBStorage storage = new SMPBStorage(Connection,repos);
     
      storage.setNickname(buffername);
      storage.transferStorage(remoteStorage);
      storage.setMaxIterations(this.maxIterations);
     
     
      storage.setObjectsToSample(this.getObjectsToSample());
     
      // if (this.produceRandomDraw)
//       {
//        
//         final String bufferName = buffername;
//        
//        
//         randomRep.addReportListener(new ReporterListener()
//         {
//           public void actionPerformed(ReporterEvent e)
//           {
//             ObjectReportInstance obj = (ObjectReportInstance)e.getSource();
//             BufferSolution randomSol = (BufferSolution)obj.getObject();
//            
//             Vector samples = null;
//             if (!randomSamples.containsKey(bufferName))
//             {
//               samples = new Vector();
//             }
//             else
//             {
//               samples = (Vector)randomSamples.get(bufferName);
//             }
//            
//             samples.add(randomSol);
//            
//             System.out.println("");
//             System.out.println("Adding a random draw for "+bufferName);
//             System.out.println("Current length of samples Vector= "+samples.size());
//             System.out.println("");
//            
//            
//             randomSamples.put(bufferName,samples);
//           }
//         });
//       }
//       else
//       {
//         System.out.println("Not being asked to produce a random draw!");
//       }
     
     
     
     
      storage.prepareForNewFit();
     
      long START_TIME = System.currentTimeMillis();
      long MAX_TIME = (Integer.valueOf(Config.getConfigValue(repos,"maxtimeout"))).longValue()*60000;
     
     
     
      storage.newFit(); //This starts a new thread of execution internally... 
        //so through multiple turns of while-loop we'd have multiple threads running...
        //Need some thread/resource management in here...
     
     
      //
      //NOTE: This initial wait seems to be necessary for mcmc to pick up sometimes and register as isStillOptimizing...
      try
      {
        Thread.sleep(5000);

      }
      catch (java.lang.InterruptedException err)
      {
        throw new RuntimeException("Problem waiting thread.",err);
      }
     
     
      while (storage.isStillOptimizing())
      {
     
        System.out.println("storage.isStillOptimizing():"+buffername);
        try
        {
          Thread.sleep(5000);
          long time_running = (System.currentTimeMillis())-START_TIME;
         
          System.out.println("MAX_TIME="+MAX_TIME+" time_running="+time_running+" for buffer "+buffername);
         
          if (time_running  > MAX_TIME)
          {
            System.out.println("MAXTIMEOUT exceeded during optimization of the buffer "+buffername+".  Halting...");
            storage.haltSolution(true);
          }
         
          
          System.out.println("Waiting for completion...");
        }
        catch (java.lang.InterruptedException err)
        {
          throw new RuntimeException("Problem waiting thread.",err);
        }
      }
     
      storage.haltSolution(true);
     
     
      if (this.getObjectsToSample().length>0) //Yes we are doing some sampling...
      {
     
        //System.out.println(" TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT Yes we are doing some sampling for "+buffername);
        LinkedList chain = storage.getObjectChain();
       
        if (chain == null)
        {
          throw new RuntimeException("Object chain can not be null for buffer "+buffername);
        }
        //System.out.println("The chain length for "+buffername+" is "+chain.size());
        this.objectChainMap.put(buffername,chain);
      }
      else
      {
        //System.out.println(" NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN We are not doing sampling for "+buffername);
      }
     
     
      try
      {
        if (!this.optimizeNoSave)
        {
          System.out.println("Saving results for buffer "+buffername+".");
          storage.executeTransfer();
        }
        else
        {
          System.out.println("Not saving results for buffer "+buffername+" because the option optimizeNoSave was set to true.");
        }
View Full Code Here


    //Instantiate the buffer's designated generator and run the optimization a bit...
    //String generatorName = remoteStorage.getComplexBufferPredictorGeneratorClass();

    if (remoteStorage.hasTitrationData())
    {
      SMPBStorage storage = new SMPBStorage(Connection,repos);
     
      storage.setNickname(buffername);
      storage.transferStorage(remoteStorage);
      storage.setMaxIterations(this.maxIterations);
     
     
      storage.setObjectsToSample(this.getObjectsToSample());
     
      // if (this.produceRandomDraw)
//       {
//        
//         final String bufferName = buffername;
//        
//        
//         randomRep.addReportListener(new ReporterListener()
//         {
//           public void actionPerformed(ReporterEvent e)
//           {
//             ObjectReportInstance obj = (ObjectReportInstance)e.getSource();
//             BufferSolution randomSol = (BufferSolution)obj.getObject();
//            
//             Vector samples = null;
//             if (!randomSamples.containsKey(bufferName))
//             {
//               samples = new Vector();
//             }
//             else
//             {
//               samples = (Vector)randomSamples.get(bufferName);
//             }
//            
//             samples.add(randomSol);
//            
//             System.out.println("");
//             System.out.println("Adding a random draw for "+bufferName);
//             System.out.println("Current length of samples Vector= "+samples.size());
//             System.out.println("");
//            
//            
//             randomSamples.put(bufferName,samples);
//           }
//         });
//       }
//       else
//       {
//         System.out.println("Not being asked to produce a random draw!");
//       }
     
     
     
     
      storage.prepareForNewFit();
     
      long START_TIME = System.currentTimeMillis();
      long MAX_TIME = (Integer.valueOf(Config.getConfigValue(repos,"maxtimeout"))).longValue()*60000;
     
     
     
      storage.newFit(); //This starts a new thread of execution internally... 
        //so through multiple turns of while-loop we'd have multiple threads running...
        //Need some thread/resource management in here...
     
     
      //
      //NOTE: This initial wait seems to be necessary for mcmc to pick up sometimes and register as isStillOptimizing...
      try
      {
        Thread.sleep(5000);

      }
      catch (java.lang.InterruptedException err)
      {
        throw new RuntimeException("Problem waiting thread.",err);
      }
     
     
      while (storage.isStillOptimizing())
      {
     
        System.out.println("storage.isStillOptimizing():"+buffername);
        try
        {
          Thread.sleep(5000);
          long time_running = (System.currentTimeMillis())-START_TIME;
         
          System.out.println("MAX_TIME="+MAX_TIME+" time_running="+time_running+" for buffer "+buffername);
         
          if (time_running  > MAX_TIME)
          {
            System.out.println("MAXTIMEOUT exceeded during optimization of the buffer "+buffername+".  Halting...");
            storage.haltSolution(true);
          }
         
          
          System.out.println("Waiting for completion...");
        }
        catch (java.lang.InterruptedException err)
        {
          throw new RuntimeException("Problem waiting thread.",err);
        }
      }
     
      storage.haltSolution(true);
     
     
      if (this.getObjectsToSample().length>0) //Yes we are doing some sampling...
      {
     
        //System.out.println(" TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT Yes we are doing some sampling for "+buffername);
        LinkedList chain = storage.getObjectChain();
       
        if (chain == null)
        {
          throw new RuntimeException("Object chain can not be null for buffer "+buffername);
        }
        //System.out.println("The chain length for "+buffername+" is "+chain.size());
        this.objectChainMap.put(buffername,chain);
      }
      else
      {
        //System.out.println(" NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN We are not doing sampling for "+buffername);
      }
     
     
      try
      {
        if (!this.optimizeNoSave)
        {
          System.out.println("Saving results for buffer "+buffername+".");
          storage.executeTransfer();
        }
        else
        {
          System.out.println("Not saving results for buffer "+buffername+" because the option optimizeNoSave was set to true.");
        }
View Full Code Here

TOP

Related Classes of com.mockturtlesolutions.jpHtools.database.SMPBStorage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.