package librec;



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import net.librec.common.LibrecException;
import net.librec.conf.Configuration;
import net.librec.conf.Configuration.Resource;
import net.librec.job.RecommenderJob;
/**
 *
 * @author Oriol
 */
public class LibTest {
    
    public static void main(String[] args) throws Exception {       
            LibTest lb = new LibTest();
            lb.benchmark();
    }
    
    //Execute all methods for all specified datasets in folders.
    public void benchmark() throws ClassNotFoundException, LibrecException, IOException {
        ArrayList<String> cities = new ArrayList<String>(Arrays.asList("NewYork","Chicago","SanDiego","Washington","LosAngeles"));
       
        ArrayList<String> algorithms = new ArrayList<String>(Arrays.asList("randomguess","mostpopular","userknn","itemknn","BPR","SVDPP","biasedMF"));
        //ArrayList<String> algorithms = new ArrayList<String>(Arrays.asList("distanceaware", "DistanceawareUserknn", "timeaware", "TimeawareUserknn"));
        
        
        ArrayList<Integer> givenNBySplit = new ArrayList<Integer>(Arrays.asList(1,1,2,3,5,10,20));  //1 less than the minimum of the split!
        int nsplits = 7;
        Configuration conf = null;
        Resource resource = null;
        Double p = 0.85;
        
        for(String city : cities){
            for(int split = 4; split <= nsplits; split++){
                for(String algorithm: algorithms){    
                    conf = new Configuration();
                    resource = new Resource("conf/" + algorithm + ".properties");
                    conf.addResource(resource);
                    conf.set("data.input.path",city + "/" + split);
                    conf.set("rec.alpha", p.toString());

                    conf.set("data.model.splitter","givenn");
                    conf.set("data.splitter.givenn","user");
                    conf.set("data.splitter.givenn.n",givenNBySplit.get(split-1).toString());

                    RecommenderJob job = new RecommenderJob(conf);
                    System.out.println("============================================================");
                    System.out.println("NEW EXECUTION OF LIBREC. PARAMETERS:");
                    System.out.println("City: " + city + " - Split: " + split + "(" + givenNBySplit.get(split-1).toString() + ")  - Algorithm: " + algorithm);
                    System.out.println("Param: " + "alpha" + " - " + "Value: " + p.toString());
                    System.out.println("============================================================");
                    job.runJob();   
                }
            }                 
        }
    }
}
