Example usage for org.apache.commons.configuration ConfigurationException printStackTrace

List of usage examples for org.apache.commons.configuration ConfigurationException printStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.configuration ConfigurationException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Usage

From source file:ch.epfl.lsir.xin.algorithm.core.SocialReg.java

/**
 * constructor/*from  w  ww. j  av  a2s  .  c  om*/
 * */
public SocialReg(RatingMatrix ratings, RatingMatrix social, boolean readModel, String modelFile) {
    //set configuration file for parameter setting.
    config.setFile(new File(".//conf//SocialReg.properties"));
    try {
        config.load();
    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    this.ratingMatrix = ratings;
    this.socialMatrix = social;
    //      this.similarityMatrix = new ArrayList<HashMap<Integer , Double>>();
    //      for( int i = 0 ; i < this.socialMatrix.getRow() ; i++ )
    //      {
    //         this.similarityMatrix.add(new HashMap<Integer , Double>());
    //      }
    this.initialization = this.config.getInt("INITIALIZATION");
    this.latentFactors = this.config.getInt("LATENT_FACTORS");
    this.Iterations = this.config.getInt("ITERATIONS");
    this.learningRate = this.config.getDouble("LEARNING_RATE");
    this.regUser = this.config.getDouble("REGULARIZATION_USER");
    this.regItem = this.config.getDouble("REGULARIZATION_ITEM");
    this.convergence = this.config.getDouble("CONVERGENCE");
    this.optimization = this.config.getString("OPTIMIZATION_METHOD");
    this.userMatrix = new LatentMatrix(this.ratingMatrix.getRow(), this.latentFactors);
    this.userMatrix.setInitialization(this.initialization);
    this.userMatrix.valueInitialization();
    this.userMatrixPrevious = this.userMatrix.clone();
    this.itemMatrix = new LatentMatrix(this.ratingMatrix.getColumn(), this.latentFactors);
    this.itemMatrix.setInitialization(this.initialization);
    this.itemMatrix.valueInitialization();
    this.itemMatrixPrevious = this.itemMatrix.clone();
    this.topN = this.config.getInt("TOP_N_RECOMMENDATION");
    this.socialReg = this.config.getDouble("SOCIAL_REGULARIZATION");
    this.maxRating = this.config.getInt("MAX_RATING");
    this.minRating = this.config.getInt("MIN_RATING");

    if (readModel) {
        this.readModel(modelFile);
    } else {
        //calculate the similarity matrix
        this.calculateSimilarityMatrix(this.config.getString("USER_SIMILARITY"));
        //         try{
        //            PrintWriter printer = new PrintWriter("similarity");
        //            for( int i = 0 ; i < this.socialMatrix.getRatingMatrix().size() ; i++ )
        //            {
        //               for( Map.Entry<Integer, Double> entry : this.socialMatrix.getRatingMatrix().get(i).entrySet() )
        //               {
        //                  printer.print(entry.getValue() + "\t");
        //               }
        //               printer.println();
        //            }
        //            printer.flush();
        //            printer.close();
        //         }catch( IOException e )
        //         {
        //            e.printStackTrace();
        //         }
    }
}

From source file:main.java.workload.tpcc.TpccWorkload.java

public void readConfig() {
    BufferedReader config_file = null;
    AbstractFileConfiguration parameters = null;
    int i, j = 0;

    try {//  www .  j  a va2  s .  c o m
        config_file = new BufferedReader(
                new InputStreamReader(getClass().getResourceAsStream(this.getFile_name())));

        //Load configuration parameters
        parameters = new PropertiesConfiguration();
        parameters.load(config_file);

        //Read TPCC scale
        //WorkloadConstants.SCALE_FACTOR = parameters.getDouble("tpcc.scale");
        WorkloadConstants.SCALE_FACTOR = Global.scaleFactor;
        Global.LOGGER.info("TPCC scale: " + WorkloadConstants.SCALE_FACTOR);

        //Read TPCC warehouses
        TpccConstants.NUM_WAREHOUSES = parameters.getInt("tpcc.warehouses");
        Global.LOGGER.info("TPCC warehouses: " + TpccConstants.NUM_WAREHOUSES);

        //Read TPCC table types
        i = 1;
        for (Object param : parameters.getList("tpcc.tbl.type")) {
            tbl_types.put(i, Integer.parseInt((String) param));
            ++i;
        }
        Global.LOGGER.info("TPCC tables types: " + tbl_types);

        //Read TPCC schema
        i = j = 0;
        ArrayList<Integer> temp = null;
        for (Object param : parameters.getList("tpcc.schema")) {
            if (j >= 9 || j == 0) {
                ++i;
                j = 0;
                temp = new ArrayList<Integer>();
                schema.put(i, temp);
            }

            schema.get(i).add(Integer.parseInt((String) param));
            ++j;
        }
        Global.LOGGER.info("TPCC table-level schema: " + schema);

        //Read TPCC transaction proportion
        i = 0;
        //new 
        this.trTypes = new int[tr_types];
        this.trProbabilities = new double[tr_types];

        for (Object param : parameters.getList("tpcc.trs.proportions")) {
            ++i;
            tr_proportions.put(i, Double.parseDouble((String) param));

            // new
            this.trTypes[i - 1] = i;
            this.trProbabilities[i - 1] = Double.parseDouble((String) param);
        }
        Global.LOGGER.info("TPCC transaction proportions: " + tr_proportions);

        //Read TPCC transactions
        i = j = 0;
        temp = null;
        for (Object param : parameters.getList("tpcc.trs.tbl_data")) {
            if (j >= 9 || j == 0) {
                ++i;
                j = 0;
                temp = new ArrayList<Integer>();
                tr_tuple_distributions.put(i, temp);
            }

            tr_tuple_distributions.get(i).add(Integer.parseInt((String) param));
            ++j;
        }
        Global.LOGGER.info("TPCC transaction table-level data distributions: " + tr_tuple_distributions);

        //Read TPCC transactional changes
        i = j = 0;
        temp = null;
        for (Object param : parameters.getList("tpcc.trs.tbl_changes")) {
            if (j >= 9 || j == 0) {
                ++i;
                j = 0;
                temp = new ArrayList<Integer>();
                tr_changes.put(i, temp);
            }

            tr_changes.get(i).add(Integer.parseInt((String) param));
            ++j;
        }
        Global.LOGGER.info("TPCC table-level transactional changes: " + tr_changes);
    } catch (ConfigurationException e) {
        e.printStackTrace();
    } finally {
        if (config_file != null) {
            try {
                config_file.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.nilostep.xlsql.database.xlInstanceOLD.java

private xlInstanceOLD(String cfg) throws xlException {
    logger = Logger.getLogger(this.getClass().getName());
    instance = this;
    //name = cfg;

    try {/*from w  w w  .j a v a 2 s .c o  m*/
        //            file = new File(cfg + "_config.xml");
        //            handler = new XMLFileHandler();
        //            handler.setFile(file);
        //
        //            cm = ConfigurationManager.getInstance();
        //            config = cm.getConfiguration(name);
        //            config.addConfigurationListener(this);
        //
        //            if (file.exists()) {

        PropertiesConfiguration config = new PropertiesConfiguration();
        config.load(this.getClass().getResourceAsStream(cfg + ".properties"));
        String engine = config.getString("general.engine");

        //cm.load(handler, name);                
        //Category cat = config.getCategory("general");                                                                
        //engine = config.getProperty("engine", null, "general");
        //config.setCategory(engine, true);
        //logger.info("Configuration file: " + file + " loaded");
        logger.info("Configuration engine: " + engine + " loaded");
        //            } else {

        //
        //                assert (config.isNew());
        //
        //                //
        //                config.setCategory("general", true);
        //
        //                String engine = "hsqldb";
        //                setLog("xlsql.log");
        //                setDatabase(System.getProperty("user.dir"));
        //
        //                //
        //                this.engine = engine;
        //                this.config.setProperty("engine", engine);
        //                addEngine(engine);
        //                config.setCategory(engine, true);
        //
        //
        //                //
        //                setDriver("org.hsqldb.jdbcDriver");
        //                setUrl("jdbc:hsqldb:.");
        //                setSchema("");
        //                setUser("sa");
        //                setPassword("");
        //                config.setCategory(getEngine(), true);
        //                logger.info("Configuration file: " + file + " created.");
        //            }
    }
    //catch (ConfigurationManagerException cme) {
    //   config = cm.getConfiguration(name);
    //} 
    catch (ConfigurationException e) {
        e.printStackTrace();
        throw new xlException(e.getMessage());
    }

    try {
        if (getLog() == null) {
            setLog("xlsql.log");
        }

        boolean append = true;
        FileHandler loghandler = new FileHandler(getLog(), append);
        loghandler.setFormatter(new SimpleFormatter());
        logger.addHandler(loghandler);
    } catch (IOException e) {
        throw new xlException("error while creating logfile");
    }

    //logger.info("Instance created with engine " + getEngine());
    logger.info("Instance created with engine " + engine);

    //
    //
    //
}

From source file:ch.epfl.lsir.xin.algorithm.core.SVDPlusPlus.java

/**
 * constructor/*from  w  ww . j  a  v  a  2s . com*/
 * */
public SVDPlusPlus(RatingMatrix ratingMatrix, boolean readModel, String modelFile) {
    //set configuration file for parameter setting.
    config.setFile(new File(".//conf//SVDPlusPlus.properties"));
    try {
        config.load();
    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    this.ratingMatrix = ratingMatrix;
    this.ratingMatrix.calculateRatedItemIndex();
    this.initialization = this.config.getInt("INITIALIZATION");
    this.iteration = this.config.getInt("ITERATIONS");
    this.convergence = this.config.getDouble("CONVERGENCE");
    this.optimization = this.config.getString("OPTIMIZATION_METHOD");
    this.topN = this.config.getInt("TOP_N_RECOMMENDATION");
    this.ratingMatrix.calculateGlobalAverage();
    this.globalAverage = this.ratingMatrix.getAverageRating();
    this.maxRating = this.config.getInt("MAX_RATING");
    this.minRating = this.config.getInt("MIN_RATING");

    this.latentFactors = this.config.getInt("LATENT_FACTORS");
    this.userReg = this.config.getDouble("REGULARIZATION_USER");
    this.itemReg = this.config.getDouble("REGULARIZATION_ITEM");
    this.biasUserReg = this.config.getDouble("BIAS_REGULARIZATION_USER");
    this.biasItemReg = this.config.getDouble("BIAS_REGULARIZATION_ITEM");
    this.learningRate = this.config.getDouble("LEARNING_RATE");
    this.biasLearningRate = this.config.getDouble("BIAS_LEARNING_RATE");

    this.userMatrix = new LatentMatrix(this.ratingMatrix.getRow(), this.latentFactors);
    this.userMatrix.setInitialization(this.initialization);
    this.userMatrix.valueInitialization();
    this.userMatrixPrevious = this.userMatrix.clone();
    this.itemMatrix = new LatentMatrix(this.ratingMatrix.getColumn(), this.latentFactors);
    this.itemMatrix.setInitialization(this.initialization);
    this.itemMatrix.valueInitialization();
    this.itemMatrixPrevious = this.itemMatrix.clone();
    this.Y = new LatentMatrix(this.ratingMatrix.getColumn(), this.latentFactors);
    this.Y.setInitialization(this.initialization);
    this.Y.valueInitialization();
    this.YPrevious = this.Y.clone();
    this.userBias = new double[this.ratingMatrix.getRow()];
    this.itemBias = new double[this.ratingMatrix.getColumn()];

    if (readModel) {
        this.readModel(modelFile);
    }
}

From source file:ezbake.IntentQuery.Sample.MongoDatasource.Server.MongoExternalDataSourceHandler.java

/***********
<tablesMetaData>//from  ww w. j a v a2 s  .  c o m
   <num_table>1</num_table>
   <tables>
 <table>
    <name>impalaTest_users</name>
    <num_columns>6</num_columns>
    <init_string></init_string>
    <columns>
       <column>
          <name>user_id</name>
          <primitiveType>INT</primitiveType>
          <len></len>
          <precision></precision>
          <scale></scale>
          <ops>LT,LE,EQ,NEQ,GE,GT</ops>
       </column>
       ...
       <column>
       </column>
    <columns>
 </table>
 <table>
 </table>
   </tables>
</tablesMetaData>
***********/

private void parseDataSourceMetadata() {

    table_metadata_map = new HashMap<String, TableMetadata>();

    try {
        Configuration xmlConfig = new XMLConfiguration(impalaExternalDsConfigFile);

        dbHost = xmlConfig.getString("mongodb.host");
        dbPort = xmlConfig.getInt("mongodb.port");
        dbName = xmlConfig.getString("mongodb.database_name");

        String key = null;
        String table_name = null;
        int num_columns = -1;
        String init_str = null;
        List<TableColumnDesc> table_col_desc_list = new ArrayList<TableColumnDesc>();

        int total_tables = xmlConfig.getInt("tablesMetaData.num_table");
        for (int i = 0; i < total_tables; i++) {
            // get table name
            key = String.format("tablesMetaData.tables.table(%d).name", i);
            table_name = xmlConfig.getString(key);
            // get table number of columns
            key = String.format("tablesMetaData.tables.table(%d).num_columns", i);
            num_columns = xmlConfig.getInt(key);
            // get table init_string
            key = String.format("tablesMetaData.tables.table(%d).init_string", i);
            init_str = xmlConfig.getString(key);

            // get columns
            String col_name = null;
            String col_type = null;
            int col_len = 0;
            int col_precision = 0;
            int col_scale = 0;
            Set<String> col_ops = null;

            for (int j = 0; j < num_columns; j++) {
                key = String.format("tablesMetaData.tables.table(%d).columns.column(%d).name", i, j);
                col_name = xmlConfig.getString(key);
                key = String.format("tablesMetaData.tables.table(%d).columns.column(%d).primitiveType", i, j);
                col_type = xmlConfig.getString(key);
                if (col_type.equals("CHAR")) {
                    key = String.format("tablesMetaData.tables.table(%d).columns.column(%d).len", i, j);
                    col_len = xmlConfig.getInt(key);
                } else if (col_type.equals("DECIMAL")) {
                    key = String.format("tablesMetaData.tables.table(%d).columns.column(%d).precision", i, j);
                    col_precision = xmlConfig.getInt(key);
                    key = String.format("tablesMetaData.tables.table(%d).columns.column(%d).scale", i, j);
                    col_scale = xmlConfig.getInt(key);
                }

                key = String.format("tablesMetaData.tables.table(%d).columns.column(%d).ops", i, j);
                //List<String>   opsList = xmlConfig.getList(key);
                String[] opsArray = xmlConfig.getStringArray(key);
                col_ops = new HashSet<String>(Arrays.asList(opsArray));

                TableColumnDesc tableColumnDesc = new TableColumnDesc(col_name, col_type, col_len,
                        col_precision, col_scale, col_ops);

                table_col_desc_list.add(tableColumnDesc);
            }

            TableMetadata tableMetadata = new TableMetadata(table_name, num_columns, init_str,
                    table_col_desc_list);

            System.out.println(tableMetadata);

            table_metadata_map.put(table_name, tableMetadata);
        }
    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:edu.uw.sig.frames2owl.Converter.java

private boolean init(String framesPath, String owlUriString, String configPath,
        Map<FrameID, String> frame2ProjectMap) {
    try {//from   w  w  w  . jav a 2 s.c  o  m
        cReader = new ConfigReader(configPath);
    } catch (ConfigurationException e1) {
        e1.printStackTrace();
        return false;
    }

    // load frames ontology
    framesKB = KnowledgeBaseLoader.loadKB(framesPath);
    if (framesKB == null) {
        System.err.println("Error: frames ontology not found");
        return false;
    }

    // create new owl ontology
    man = OWLManager.createOWLOntologyManager();
    df = man.getOWLDataFactory();
    try {
        owlOnt = man.createOntology(IRI.create(owlUriString));
    } catch (OWLOntologyCreationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return false;
    }

    this.iriUtils = new IRIUtils(framesKB, owlOnt, cReader, frame2ProjectMap);
    this.convUtils = new ConvUtils(iriUtils, df, framesKB);

    // handle import statements (for includes in frames)
    String owlExt = ".owl";
    for (URI includedFileURI : (Collection<URI>) framesKB.getProject().getDirectIncludedProjectURIs()) {
        // this block parses the name of the included ontology out of the include file path
        // (that is the only place it is really represented)
        String path = includedFileURI.getPath();

        int lastSlashInd = path.lastIndexOf('/');
        int lastPeriodInd = path.lastIndexOf('.');
        String fileName = path.substring(lastSlashInd + 1, lastPeriodInd);

        // create import statement
        // construct IRI
        String iriString = /*iriUtils.getProjectIRIBaseString(fileName);iriUtils.getIRIBaseString()//*/fileName
                + owlExt;
        IRI importIRI = IRI.create(iriString);
        System.err.println("will gen import statement for " + importIRI);

        // insert import statement
        OWLImportsDeclaration importDec = df.getOWLImportsDeclaration(importIRI);
        man.applyChange(new AddImport(owlOnt, importDec));
    }

    // determine if we should assert that sibling classes are disjoint
    Map<String, Boolean> configFlags = cReader.getConfigFlags();
    makeSiblingClsesDisj = configFlags.get("disjoint-siblings");

    // determine if domain and range classes will be created, set-up if necessary
    createAnnotDomainRangeClses = configFlags.get("create-annot-domain-range");
    if (createAnnotDomainRangeClses == null)
        createAnnotDomainRangeClses = false;
    if (createAnnotDomainRangeClses == true) {
        String domainClsName = cReader.getDomainClsName();
        if (domainClsName != null) {
            try {
                IRI domainClassIRI = iriUtils.getClassIRIForString(domainClsName);
                domainClass = df.getOWLClass(domainClassIRI);
                addLabel(domainClass, domainClsName);

                // Now create the subclass axiom
                OWLAxiom axiom = df.getOWLSubClassOfAxiom(domainClass, df.getOWLThing());

                // add the subclass axiom to the ontology.
                AddAxiom addAxiom = new AddAxiom(owlOnt, axiom);

                // We now use the manager to apply the change
                man.applyChange(addAxiom);
            } catch (IRIGenerationException e) {
                e.printStackTrace();
            }

        }
        String rangeClsName = cReader.getRangeClsName();
        if (rangeClsName != null) {
            try {
                IRI rangeClassIRI = iriUtils.getClassIRIForString(rangeClsName);
                rangeClass = df.getOWLClass(rangeClassIRI);
                addLabel(rangeClass, rangeClsName);

                // Now create the subclass axiom
                OWLAxiom axiom = df.getOWLSubClassOfAxiom(rangeClass, df.getOWLThing());

                // add the subclass axiom to the ontology.
                AddAxiom addAxiom = new AddAxiom(owlOnt, axiom);

                // We now use the manager to apply the change
                man.applyChange(addAxiom);
            } catch (IRIGenerationException e) {
                e.printStackTrace();
            }
        }
    }

    Map<String, Class> slotConvClassMap = cReader.getSlotConvClassMap();
    Map<String, Map<String, String>> slotInitArgsMap = cReader.getConvInitArgsMap();

    // build reified slot exclusion set
    List<String> excReifSubSlots = cReader.getReifExclusions();
    for (String subSlotName : excReifSubSlots) {
        Slot currSlot = framesKB.getSlot(subSlotName);
        if (currSlot == null) {
            System.err.println("unknown slot marked for exclusion: " + subSlotName);
            continue;
        }
        reifExclusions.add(currSlot);
    }

    // build slot annotation exclusion set
    List<String> excSlotAnnotSlots = cReader.getSlotAnnotExclusions();
    for (String slotName : excSlotAnnotSlots) {
        Slot currSlot = framesKB.getSlot(slotName);
        if (currSlot == null) {
            System.err.println("unknown slot marked for exclusion: " + slotName);
            continue;
        }
        slotAnnotExclusions.add(currSlot);
    }
    //TODO, the above exclusions are not yet passed to any converters !!!

    for (Slot currSlot : (Collection<Slot>) framesKB.getSlots()) {
        if (currSlot.isSystem() || currSlot.isIncluded())
            continue;

        String slotName = currSlot.getName();
        try {
            //SlotValueConverter currConverter = null;
            Class convClass = slotConvClassMap.get(slotName);
            Map<String, String> initArgs = slotInitArgsMap.get(slotName);
            if (convClass == null)
                convClass = guessSlotConverter(currSlot);
            if (initArgs == null) // use empty map
                initArgs = new HashMap<String, String>();
            SlotValueConverter converter = (SlotValueConverter) convClass
                    .asSubclass(SlotValueConverter.class).getConstructor(KnowledgeBase.class, Slot.class,
                            OWLOntology.class, IRIUtils.class, ConvUtils.class)
                    .newInstance(framesKB, currSlot, owlOnt, iriUtils, convUtils);

            // add additional reified exclusions if necessary
            if (converter instanceof BaseReifiedPropertyConverter) {
                BaseReifiedPropertyConverter reifConv = (BaseReifiedPropertyConverter) converter;
                reifConv.addExcludedSlots(reifExclusions);
            }

            // add domain and range classes for annotation property if needed
            if (converter instanceof AnnotationPropertyConverter && createAnnotDomainRangeClses == true) {
                AnnotationPropertyConverter annotConv = (AnnotationPropertyConverter) converter;
                annotConv.setDomainClass(domainClass);
                annotConv.setRangeClass(rangeClass);
            }

            // init with any args from the config file
            boolean initSuccess = converter.init(initArgs);
            if (!initSuccess) {
                System.err.println("Failed to initialize converter for slot " + slotName);
                System.exit(-1);
            }
            slot2ConvMap.put(currSlot, converter);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            continue;
        } catch (SecurityException e) {
            e.printStackTrace();
            continue;
        } catch (InstantiationException e) {
            e.printStackTrace();
            continue;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            continue;
        } catch (InvocationTargetException e) {
            e.printStackTrace();
            continue;
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
            continue;
        }
    }

    return true;
}

From source file:ch.epfl.lsir.xin.algorithm.core.MatrixFactorization.java

/**
 * constructor//  w  ww  .j ava2s .co  m
 * @param: rating matrix
 * @param: indicator for loading an existing model
 * @param: location of the file that stores the model
 * */
public MatrixFactorization(RatingMatrix ratingMatrix, boolean readModel, String modelFile) {
    //set configuration file for parameter setting.
    config.setFile(new File(".//conf//MF.properties"));
    try {
        config.load();
    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    this.ratingMatrix = ratingMatrix;
    this.initialization = this.config.getInt("INITIALIZATION");
    this.latentFactors = this.config.getInt("LATENT_FACTORS");
    this.Iterations = this.config.getInt("ITERATIONS");
    this.learningRate = this.config.getDouble("LEARNING_RATE");
    this.regUser = this.config.getDouble("REGULARIZATION_USER");
    this.regItem = this.config.getDouble("REGULARIZATION_ITEM");
    this.convergence = this.config.getDouble("CONVERGENCE");
    this.optimization = this.config.getString("OPTIMIZATION_METHOD");
    this.userMatrix = new LatentMatrix(this.ratingMatrix.getRow(), this.latentFactors);
    this.userMatrix.setInitialization(this.initialization);
    this.userMatrix.valueInitialization();
    this.userMatrixPrevious = this.userMatrix.clone();
    this.itemMatrix = new LatentMatrix(this.ratingMatrix.getColumn(), this.latentFactors);
    this.itemMatrix.setInitialization(this.initialization);
    this.itemMatrix.valueInitialization();
    this.itemMatrixPrevious = this.itemMatrix.clone();
    this.topN = this.config.getInt("TOP_N_RECOMMENDATION");
    this.maxRating = this.config.getInt("MAX_RATING");
    this.minRating = this.config.getInt("MIN_RATING");

    if (readModel) {
        this.readModel(modelFile);
    }
}

From source file:ch.epfl.lsir.xin.algorithm.core.BiasedMF.java

/**
 * constructor//from  ww w  .  j  av  a 2  s.  c o m
 * */
public BiasedMF(RatingMatrix ratingMatrix, boolean readModel, String modelFile) {
    //set configuration file for parameter setting.
    config.setFile(new File(".//conf//biasedMF.properties"));
    try {
        config.load();
    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    this.ratingMatrix = ratingMatrix;
    this.initialization = this.config.getInt("INITIALIZATION");
    this.iterations = this.config.getInt("ITERATIONS");
    this.convergence = this.config.getDouble("CONVERGENCE");
    this.optimization = this.config.getString("OPTIMIZATION_METHOD");
    this.topN = this.config.getInt("TOP_N_RECOMMENDATION");
    this.ratingMatrix.calculateGlobalAverage();
    this.globalAverage = this.ratingMatrix.getAverageRating();
    this.maxRating = this.config.getInt("MAX_RATING");
    this.minRating = this.config.getInt("MIN_RATING");

    this.latentFactors = this.config.getInt("LATENT_FACTORS");
    this.userReg = this.config.getDouble("REGULARIZATION_USER");
    this.itemReg = this.config.getDouble("REGULARIZATION_ITEM");
    this.biasUserReg = this.config.getDouble("BIAS_REGULARIZATION_USER");
    this.biasItemReg = this.config.getDouble("BIAS_REGULARIZATION_ITEM");
    this.learningRate = this.config.getDouble("LEARNING_RATE");
    this.biasLearningRate = this.config.getDouble("BIAS_LEARNING_RATE");

    this.userMatrix = new LatentMatrix(this.ratingMatrix.getRow(), this.latentFactors);
    this.userMatrix.setInitialization(this.initialization);
    this.userMatrix.valueInitialization();
    this.userMatrixPrevious = this.userMatrix.clone();
    this.itemMatrix = new LatentMatrix(this.ratingMatrix.getColumn(), this.latentFactors);
    this.itemMatrix.setInitialization(this.initialization);
    this.itemMatrix.valueInitialization();
    this.itemMatrixPrevious = this.itemMatrix.clone();

    this.userBias = new double[this.ratingMatrix.getRow()];
    this.itemBias = new double[this.ratingMatrix.getColumn()];

    if (readModel) {
        this.readModel(modelFile);
    }
}

From source file:edu.isi.wings.portal.classes.domains.Domain.java

public boolean saveDomain() {
    PropertyListConfiguration config = new PropertyListConfiguration();
    config.addProperty("name", this.domainName);
    config.addProperty("useSharedTripleStore", this.useSharedTripleStore);

    config.addProperty("executions.engine.plan", this.planEngine);
    config.addProperty("executions.engine.step", this.stepEngine);

    this.setUrlMapProp(config, "workflows.library", this.templateLibrary);
    this.setUrlMapProp(config, "workflows.prefix", this.newTemplateDirectory);

    this.setUrlMapProp(config, "executions.library", this.executionLibrary);
    this.setUrlMapProp(config, "executions.prefix", this.newExecutionDirectory);

    this.setUrlMapProp(config, "data.ontology", this.dataOntology);
    this.setUrlMapProp(config, "data.library", this.dataLibrary);
    config.addProperty("data.library.storage", this.dataLibrary.getStorageDirectory());

    config.addProperty("components.namespace", this.componentLibraryNamespace);
    this.setUrlMapProp(config, "components.abstract", this.abstractComponentLibrary);
    config.addProperty("components.concrete", this.concreteComponentLibrary.getName());

    for (DomainLibrary clib : this.concreteComponentLibraries) {
        config.addProperty("components.libraries.library(-1).url", clib.getUrl());
        config.addProperty("components.libraries.library.map", clib.getMapping());
        config.addProperty("components.libraries.library.name", clib.getName());
        config.addProperty("components.libraries.library.storage", clib.getStorageDirectory());
    }/*from w  w w  .ja v a 2  s .  c  o  m*/

    for (Permission permission : this.permissions) {
        config.addProperty("permissions.permission(-1).userid", permission.getUserid());
        config.addProperty("permissions.permission.canRead", permission.canRead());
        config.addProperty("permissions.permission.canWrite", permission.canWrite());
        config.addProperty("permissions.permission.canExecute", permission.canExecute());
    }

    if (this.domainDirectory != null) {
        File domdir = new File(this.domainDirectory);
        if (!domdir.exists() && !domdir.mkdirs())
            System.err.println("Could not create domain directory: " + this.domainDirectory);
    }
    try {
        config.save(this.domainConfigFile);
        return true;
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:edu.isi.wings.portal.classes.domains.Domain.java

private void initializeDomain() {
    try {// ww  w  . ja  v a 2 s.  com
        PropertyListConfiguration config = new PropertyListConfiguration(this.domainConfigFile);

        this.useSharedTripleStore = config.getBoolean("useSharedTripleStore", true);
        this.planEngine = config.getString("executions.engine.plan", "Local");
        this.stepEngine = config.getString("executions.engine.step", "Local");

        this.templateLibrary = new DomainLibrary(config.getString("workflows.library.url"),
                config.getString("workflows.library.map"));
        this.newTemplateDirectory = new UrlMapPrefix(config.getString("workflows.prefix.url"),
                config.getString("workflows.prefix.map"));

        this.executionLibrary = new DomainLibrary(config.getString("executions.library.url"),
                config.getString("executions.library.map"));
        this.newExecutionDirectory = new UrlMapPrefix(config.getString("executions.prefix.url"),
                config.getString("executions.prefix.map"));

        this.dataOntology = new DomainOntology(config.getString("data.ontology.url"),
                config.getString("data.ontology.map"));
        this.dataLibrary = new DomainLibrary(config.getString("data.library.url"),
                config.getString("data.library.map"));
        this.dataLibrary.setStorageDirectory(config.getString("data.library.storage"));

        this.componentLibraryNamespace = config.getString("components.namespace");
        this.abstractComponentLibrary = new DomainLibrary(config.getString("components.abstract.url"),
                config.getString("components.abstract.map"));

        String concreteLibraryName = config.getString("components.concrete");
        List<HierarchicalConfiguration> clibs = config.configurationsAt("components.libraries.library");
        for (HierarchicalConfiguration clib : clibs) {
            String url = clib.getString("url");
            String map = clib.getString("map");
            String name = clib.getString("name");
            String codedir = clib.getString("storage");
            DomainLibrary concreteLib = new DomainLibrary(url, map, name, codedir);
            this.concreteComponentLibraries.add(concreteLib);
            if (name.equals(concreteLibraryName))
                this.concreteComponentLibrary = concreteLib;
        }

        List<HierarchicalConfiguration> perms = config.configurationsAt("permissions.permission");
        for (HierarchicalConfiguration perm : perms) {
            String userid = perm.getString("userid");
            boolean canRead = perm.getBoolean("canRead", false);
            boolean canWrite = perm.getBoolean("canWrite", false);
            boolean canExecute = perm.getBoolean("canExecute", false);
            Permission permission = new Permission(userid, canRead, canWrite, canExecute);
            this.permissions.add(permission);
        }
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
}