Ignore:
Timestamp:
05/03/16 15:17:36 (9 years ago)
Author:
sherbold
Message:
  • updated new result storage concept and cross-project experiments to first check if a result is available. If this is the case, the experiment is not executed.
Location:
trunk/CrossPare/src/de/ugoe/cs/cpdp
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/Runner.java

    r41 r69  
    4545    public static void main(String[] args) { 
    4646        new TextConsole(Level.FINE); 
    47         final int concurrentThreads = Runtime.getRuntime().availableProcessors() - 2; 
     47        final int concurrentThreads = Runtime.getRuntime().availableProcessors(); 
    4848        final ExecutorService threadPool = Executors.newFixedThreadPool(concurrentThreads); 
    4949        for (String arg : args) { 
     
    8989 
    9090        if (config != null) { 
    91             Console.trace(Level.FINE, config.toString()); 
     91            Console.trace(Level.FINEST, config.toString()); 
    9292            // Instantiate the class like it was given as parameter in the config file and cast it 
    9393            // to the interface 
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/IResultStorage.java

    r68 r69  
    44 
    55    public void addResult(ExperimentResult result); 
     6     
     7    public boolean containsResult(String experimentName, String productName); 
    68} 
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/MySQLResultStorage.java

    r68 r69  
    44import java.sql.Connection; 
    55import java.sql.DriverManager; 
     6import java.sql.ResultSet; 
    67import java.sql.SQLException; 
    78import java.sql.Statement; 
     
    3435 
    3536    public void addResult(ExperimentResult result) { 
    36         Statement stmt; 
    37         try { 
    38             stmt = con.createStatement(); 
    39         } 
    40         catch (SQLException e) { 
    41             Console.printerr("Problem with MySQL connection: "); 
    42             Console.printerr("SQLException: " + e.getMessage()); 
    43             Console.printerr("SQLState: " + e.getSQLState()); 
    44             Console.printerr("VendorError: " + e.getErrorCode()); 
    45             return; 
    46         } 
    4737        StringBuilder sql = new StringBuilder(); 
    4838        sql.append("INSERT INTO crosspare.results VALUES (NULL,"); 
     
    7262        sql.append(result.getTn()+","); 
    7363        sql.append(result.getFp()+");"); 
     64         
     65        Statement stmt; 
    7466        try { 
     67            stmt = con.createStatement(); 
    7568            stmt.executeUpdate(sql.toString().replace("NaN", "NULL")); 
    7669        } 
     
    8477    } 
    8578     
    86     //public boolean containsResult(String configurationName, String productName, String classifier); 
     79    @Override 
     80    public boolean containsResult(String experimentName, String productName) { 
     81        String sql = "SELECT COUNT(*) as cnt FROM crosspare.results WHERE configurationName=\'" + experimentName + "\' AND productName=\'" + productName + "\';"; 
     82        Statement stmt; 
     83        boolean contained = false; 
     84        try { 
     85            stmt = con.createStatement(); 
     86            ResultSet results = stmt.executeQuery(sql); 
     87            results.next(); 
     88            int count = results.getInt("cnt"); 
     89            contained = count>0; 
     90        } 
     91        catch (SQLException e) { 
     92            Console.printerr("Problem with MySQL connection: \n"); 
     93            Console.printerr("SQLException: " + e.getMessage() + "\n"); 
     94            Console.printerr("SQLState: " + e.getSQLState() + "\n"); 
     95            Console.printerr("VendorError: " + e.getErrorCode() + "\n"); 
     96        } 
     97        return contained; 
     98    } 
    8799} 
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/execution/AbstractCrossProjectExperiment.java

    r68 r69  
    2929import de.ugoe.cs.cpdp.dataselection.ISetWiseDataselectionStrategy; 
    3030import de.ugoe.cs.cpdp.eval.IEvaluationStrategy; 
     31import de.ugoe.cs.cpdp.eval.IResultStorage; 
    3132import de.ugoe.cs.cpdp.loader.IVersionLoader; 
    3233import de.ugoe.cs.cpdp.training.ISetWiseTestdataAwareTrainingStrategy; 
     
    163164                                              config.getExperimentName(), versionCount, 
    164165                                              testVersionCount, testVersion.getVersion())); 
     166                if (resultsAvailable(testVersion)) { 
     167                    Console.traceln(Level.INFO, 
     168                                    String.format( 
     169                                                  "[%s] [%02d/%02d] %s: results already available; skipped", 
     170                                                  config.getExperimentName(), versionCount, 
     171                                                  testVersionCount, testVersion.getVersion())); 
     172                    versionCount++; 
     173                    continue; 
     174                } 
    165175 
    166176                // Setup testdata and training data 
     
    299309                            config.getExperimentName() + ".csv"); 
    300310                    } 
    301                     evaluator.apply(testdata, traindata, allTrainers, writeHeader, config.getResultStorages()); 
     311                    evaluator.apply(testdata, traindata, allTrainers, writeHeader, 
     312                                    config.getResultStorages()); 
    302313                    writeHeader = false; 
    303314                } 
     
    327338        return result; 
    328339    } 
     340 
     341    private boolean resultsAvailable(SoftwareVersion version) { 
     342        if (config.getResultStorages().isEmpty()) { 
     343            return false; 
     344        } 
     345        boolean available = true; 
     346        for (IResultStorage storage : config.getResultStorages()) { 
     347            available &= storage.containsResult(config.getExperimentName(), version.getVersion()); 
     348        } 
     349        return available; 
     350    } 
    329351} 
Note: See TracChangeset for help on using the changeset viewer.