├── .github └── workflows │ └── ci-pipeline.yml ├── .gitignore ├── README.md ├── code ├── common │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── ca │ │ │ └── sfu │ │ │ └── cs │ │ │ └── common │ │ │ └── Configuration │ │ │ └── Config.java │ └── target │ │ ├── common-1.0-SNAPSHOT 2.jar │ │ ├── common-1.0-SNAPSHOT.jar │ │ ├── maven-archiver │ │ └── pom.properties │ │ └── maven-status │ │ └── maven-compiler-plugin │ │ └── compile │ │ └── default-compile │ │ ├── createdFiles 2.lst │ │ ├── createdFiles.lst │ │ └── inputFiles.lst ├── componentsrunner │ ├── pom.xml │ ├── src │ │ └── main │ │ │ ├── configs │ │ │ └── components-runner.cfg │ │ │ └── java │ │ │ └── ca │ │ │ └── sfu │ │ │ └── cs │ │ │ └── componentsrunner │ │ │ └── app │ │ │ └── RunComponent.java │ └── target │ │ ├── componentsrunner-1.0-SNAPSHOT 2.jar │ │ ├── componentsrunner-1.0-SNAPSHOT.jar │ │ ├── maven-archiver │ │ ├── pom 2.properties │ │ └── pom.properties │ │ ├── maven-status │ │ └── maven-compiler-plugin │ │ │ └── compile │ │ │ └── default-compile │ │ │ ├── createdFiles 2.lst │ │ │ ├── createdFiles.lst │ │ │ ├── inputFiles 2.lst │ │ │ └── inputFiles.lst │ │ ├── original-componentsrunner-1.0-SNAPSHOT 2.jar │ │ └── original-componentsrunner-1.0-SNAPSHOT.jar ├── factorbase │ ├── pom.xml │ ├── src │ │ └── main │ │ │ ├── java │ │ │ ├── ca │ │ │ │ └── sfu │ │ │ │ │ └── cs │ │ │ │ │ └── factorbase │ │ │ │ │ ├── app │ │ │ │ │ └── RunBB.java │ │ │ │ │ ├── data │ │ │ │ │ ├── ContingencyTable.java │ │ │ │ │ ├── ContingencyTableGenerator.java │ │ │ │ │ ├── DataExtractor.java │ │ │ │ │ ├── DataExtractorGenerator.java │ │ │ │ │ ├── DataSet.java │ │ │ │ │ ├── DataSetMetaData.java │ │ │ │ │ ├── FunctorNode.java │ │ │ │ │ ├── FunctorNodesInfo.java │ │ │ │ │ ├── MySQLDataExtractor.java │ │ │ │ │ ├── RandomVariableAssignment.java │ │ │ │ │ └── TSVDataExtractor.java │ │ │ │ │ ├── database │ │ │ │ │ ├── FactorBaseDataBase.java │ │ │ │ │ ├── FactorBaseDataBaseInfo.java │ │ │ │ │ └── MySQLFactorBaseDataBase.java │ │ │ │ │ ├── exception │ │ │ │ │ ├── DataBaseException.java │ │ │ │ │ ├── DataExtractionException.java │ │ │ │ │ └── ScoringException.java │ │ │ │ │ ├── exporter │ │ │ │ │ ├── bifexporter │ │ │ │ │ │ ├── BIF_Generator.java │ │ │ │ │ │ └── bif │ │ │ │ │ │ │ ├── BIFExport.java │ │ │ │ │ │ │ └── BIF_IO.java │ │ │ │ │ └── csvexporter │ │ │ │ │ │ └── CSVPrecomputor.java │ │ │ │ │ ├── graph │ │ │ │ │ └── Edge.java │ │ │ │ │ ├── jbn │ │ │ │ │ └── BayesNet_Learning_main.java │ │ │ │ │ ├── lattice │ │ │ │ │ ├── LatticeGenerator.java │ │ │ │ │ └── RelationshipLattice.java │ │ │ │ │ ├── learning │ │ │ │ │ ├── BayesBaseH.java │ │ │ │ │ ├── CP.java │ │ │ │ │ ├── CPGenerator.java │ │ │ │ │ ├── CountingStrategy.java │ │ │ │ │ ├── CountsManager.java │ │ │ │ │ └── KLD_generator.java │ │ │ │ │ ├── search │ │ │ │ │ ├── BDeuScore.java │ │ │ │ │ ├── BDeuScoreOnDemand.java │ │ │ │ │ └── DiscreteLocalScore.java │ │ │ │ │ └── util │ │ │ │ │ ├── KeepTablesOnly.java │ │ │ │ │ ├── LoggerConfig.java │ │ │ │ │ ├── Mapper.java │ │ │ │ │ ├── MySQLScriptRunner.java │ │ │ │ │ ├── QueryGenerator.java │ │ │ │ │ ├── RuntimeLogger.java │ │ │ │ │ └── Sort_merge3.java │ │ │ └── edu │ │ │ │ └── cmu │ │ │ │ └── tetrad │ │ │ │ ├── data │ │ │ │ ├── IKnowledge.java │ │ │ │ ├── Knowledge.java │ │ │ │ └── KnowledgeTransferable.java │ │ │ │ ├── graph │ │ │ │ ├── Dag.java │ │ │ │ ├── EdgeListGraph.java │ │ │ │ ├── Graph.java │ │ │ │ ├── Pair.java │ │ │ │ └── Pattern.java │ │ │ │ └── search │ │ │ │ ├── DagInPatternIterator.java │ │ │ │ ├── GesCT.java │ │ │ │ ├── GraphScorer.java │ │ │ │ ├── MeekRules.java │ │ │ │ ├── PatternToDag.java │ │ │ │ └── SearchGraphUtils.java │ │ │ └── resources │ │ │ └── scripts │ │ │ ├── initialize_databases.sql │ │ │ ├── latticegenerator_initialize.sql │ │ │ ├── latticegenerator_initialize_local.sql │ │ │ ├── latticegenerator_populate.sql │ │ │ ├── logging.sql │ │ │ ├── metadata.sql │ │ │ ├── metadata_storedprocedures.sql │ │ │ ├── metaqueries_RChain.sql │ │ │ ├── metaqueries_initialize.sql │ │ │ ├── metaqueries_populate.sql │ │ │ ├── modelmanager_initialize.sql │ │ │ ├── modelmanager_populate.sql │ │ │ ├── transfer_cascade.sql │ │ │ └── transfer_initialize.sql │ └── target │ │ ├── classes │ │ └── scripts │ │ │ ├── initialize_databases 3.sql │ │ │ ├── initialize_databases.sql │ │ │ ├── latticegenerator_initialize.sql │ │ │ ├── latticegenerator_initialize_local 3.sql │ │ │ ├── latticegenerator_initialize_local.sql │ │ │ ├── latticegenerator_populate 2.sql │ │ │ ├── latticegenerator_populate.sql │ │ │ ├── logging 3.sql │ │ │ ├── logging.sql │ │ │ ├── metadata 3.sql │ │ │ ├── metadata.sql │ │ │ ├── metadata_storedprocedures 3.sql │ │ │ ├── metadata_storedprocedures.sql │ │ │ ├── metaqueries_RChain 2.sql │ │ │ ├── metaqueries_RChain.sql │ │ │ ├── metaqueries_initialize 3.sql │ │ │ ├── metaqueries_initialize.sql │ │ │ ├── metaqueries_populate 3.sql │ │ │ ├── metaqueries_populate.sql │ │ │ ├── modelmanager_initialize 3.sql │ │ │ ├── modelmanager_initialize.sql │ │ │ ├── modelmanager_populate 3.sql │ │ │ ├── modelmanager_populate.sql │ │ │ ├── transfer_cascade 2.sql │ │ │ ├── transfer_cascade.sql │ │ │ ├── transfer_initialize 2.sql │ │ │ └── transfer_initialize.sql │ │ ├── factorbase-1.0-SNAPSHOT.jar │ │ ├── maven-archiver │ │ └── pom.properties │ │ ├── maven-status │ │ └── maven-compiler-plugin │ │ │ └── compile │ │ │ └── default-compile │ │ │ ├── createdFiles 2.lst │ │ │ ├── createdFiles 3.lst │ │ │ ├── createdFiles.lst │ │ │ └── inputFiles.lst │ │ └── original-factorbase-1.0-SNAPSHOT.jar ├── mlnexporter │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── ca │ │ │ └── sfu │ │ │ └── cs │ │ │ └── mlnexporter │ │ │ ├── app │ │ │ └── Exporter.java │ │ │ ├── graph │ │ │ └── BNNode.java │ │ │ └── util │ │ │ └── MergeSort.java │ └── target │ │ ├── maven-archiver │ │ ├── pom 2.properties │ │ └── pom.properties │ │ ├── maven-status │ │ └── maven-compiler-plugin │ │ │ └── compile │ │ │ └── default-compile │ │ │ ├── createdFiles 2.lst │ │ │ ├── createdFiles.lst │ │ │ ├── inputFiles 2.lst │ │ │ └── inputFiles.lst │ │ ├── mlnexporter-1.0-SNAPSHOT 2.jar │ │ ├── mlnexporter-1.0-SNAPSHOT.jar │ │ ├── original-mlnexporter-1.0-SNAPSHOT 2.jar │ │ └── original-mlnexporter-1.0-SNAPSHOT.jar ├── pom.xml └── thirdparty │ ├── pom.xml │ └── tetrad │ ├── tetrad-6.5.3.pom │ └── tetrad-lib-6.5.3.jar ├── config.cfg ├── documentation ├── FACTORBASE DOCUMENTATION.docx ├── RandomGenerator.docx ├── WorkFlow.txt ├── ct-table-generator.md ├── flow_diagram_for_CP.tif ├── flow_diagram_for_CP.vsd ├── kurt-comment.rtf ├── manual.pdf └── readme.rtf ├── examples ├── Financial │ └── Financial_std.sql ├── Hepatitis │ ├── Hepatitis_std_Bio.sql │ ├── Hepatitis_std_dispat.sql │ ├── Hepatitis_std_indis.sql │ ├── Hepatitis_std_inf.sql │ ├── Hepatitis_std_rel11.sql │ ├── Hepatitis_std_rel12.sql │ └── Hepatitis_std_rel13.sql ├── MovieLens_TQ │ ├── .DS_Store │ └── MovieLens_TQ.sql ├── MovieLens_std │ ├── input │ │ ├── MovieLens_std_User.sql │ │ ├── MovieLens_std_item2.sql │ │ └── MovieLens_std_u2base.sql │ └── output │ │ └── Bif_MovieLens_std.xml ├── Mutagenesis_std │ ├── input │ │ └── Mutagenesis_std.sql │ └── output │ │ └── Bif_Mutagenesis_std.xml ├── Toy │ └── toyexample.sql ├── UW │ └── UW_std.sql ├── imdb_MovieLens │ ├── imdb_MovieLens_actors.sql │ ├── imdb_MovieLens_directors.sql │ ├── imdb_MovieLens_movies.sql │ ├── imdb_MovieLens_movies2actors.sql │ ├── imdb_MovieLens_movies2directors.sql │ ├── imdb_MovieLens_u2base.sql │ └── imdb_MovieLens_users.sql └── unielwin │ ├── input │ └── unielwin.sql │ └── output │ └── Bif_unielwin.xml ├── factorbase-1.0-SNAPSHOT.jar ├── images ├── configuration.png └── univschema.png ├── make_xml_sum_to_one.py ├── obsolete ├── .travis.yml ├── BIFReader.java ├── FunctorWrapper.java ├── MakeTargetSetup.java ├── MarkovBlanket.java ├── TestWrapper.java ├── columnstore │ ├── CountsManager.java │ ├── MySQLFactorBaseDataBase.java │ ├── MySQLScriptRunner.java │ ├── QueryGenerator.java │ └── counts_storedprocedures.sql ├── commented-out │ ├── BIFImport.java │ ├── BIF_Generator.java │ ├── BIF_IO.java │ ├── BayesBaseCT_SortMerge.java │ ├── BayesBaseH.java │ ├── BayesNet_Learning_main.java │ ├── CPGenerator.java │ ├── CSVPrecomputor.java │ ├── KLD_generator.java │ └── short_rnid_LatticeGenerator.java ├── jars │ ├── Jama-1.0.3.jar │ ├── colt.jar │ ├── commons-collections-3.1.jar │ ├── commons-lang-2.6.jar │ ├── ibatis-common-2.jar │ ├── mtj.jar │ ├── mysql-connector-java-5.1.22-bin.jar │ ├── unreferenced │ │ ├── junit.jar │ │ ├── opt77.jar │ │ └── pal-1.4.jar │ ├── weka.jar │ └── xom-1.1.jar ├── old-factorbase │ ├── FactorBase.jar │ └── src │ │ ├── config.cfg │ │ ├── scripts │ │ ├── bayesedges.sql │ │ ├── metadata_2.sql │ │ ├── setup.sql │ │ ├── storedprocs.sql │ │ └── transfer.sql │ │ └── unused-scripts │ │ ├── markov_blanket.sql │ │ ├── metadata_2_cont.sql │ │ ├── metadata_2_nolink.sql │ │ ├── metadata_3.sql │ │ ├── metadata_3_Test_Temp.sql │ │ ├── metadata_3_cont.sql │ │ ├── metadata_3_nolink.sql │ │ ├── transfer2.sql │ │ └── transfer_to_target.sql ├── old-mlnexporter │ └── MLNExporter.jar ├── refactored │ ├── BayesBaseH.java │ ├── KeepTablesOnly.java │ ├── MakeSetup.java │ └── Sort_merge3.java ├── scripts │ ├── add_orig_rnid.sql │ ├── bayesedges.sql │ ├── drop_tmpProc.sql │ ├── markov_blanket.sql │ ├── metadata.sql │ ├── metadata_3.sql │ ├── metadata_3_Test_Temp.sql │ ├── metadata_3_cont.sql │ ├── metadata_3_nolink.sql │ ├── metaqueries-old.sql │ ├── metaqueries_cont.sql │ ├── model_manager.sql │ ├── transfer2.sql │ └── transfer_to_target.sql ├── tetrad │ ├── data │ │ ├── AbstractVariable.java │ │ ├── AndersonDarlingTest.java │ │ ├── CaseExpander.java │ │ ├── ColtDataSet.java │ │ ├── ContinuousDiscretizationSpec.java │ │ ├── ContinuousVariable.java │ │ ├── CovarianceMatrix.java │ │ ├── DataFilter.java │ │ ├── DataModel.java │ │ ├── DataReader.java │ │ ├── DataSet.java │ │ ├── DataUtils.java │ │ ├── DelimiterType.java │ │ ├── DiscreteDiscretizationSpec.java │ │ ├── DiscreteVariable.java │ │ ├── DiscreteVariableType.java │ │ ├── DiscretizationSpec.java │ │ ├── Discretizer.java │ │ ├── ICovarianceMatrix.java │ │ ├── KnowledgeEdge.java │ │ ├── KnowledgeGroup.java │ │ ├── Lineizer.java │ │ ├── RegexTokenizer.java │ │ ├── Variable.java │ │ └── VariableSource.java │ ├── graph │ │ ├── AtMostOneEdgePerPair.java │ │ ├── DirectedEdgesOnly.java │ │ ├── DirectedUndirectedOnly.java │ │ ├── Edge.java │ │ ├── Edges.java │ │ ├── Endpoint.java │ │ ├── FruchtermanReingoldLayout.java │ │ ├── GraphConstraint.java │ │ ├── GraphGeneratorRandomNumEdges.java │ │ ├── GraphNode.java │ │ ├── GraphUtils.java │ │ ├── InArrowImpliesNonancestor.java │ │ ├── KamadaKawaiLayout.java │ │ ├── LayeredDrawing.java │ │ ├── MeasuredLatentOnly.java │ │ ├── NoEdgesToSelf.java │ │ ├── Node.java │ │ ├── NodePair.java │ │ ├── NodeType.java │ │ ├── SemGraph.java │ │ ├── TimeLagGraph.java │ │ ├── Triple.java │ │ └── UniformGraphGenerator.java │ ├── regression │ │ ├── Regression.java │ │ ├── RegressionDataset.java │ │ └── RegressionResult.java │ ├── search │ │ ├── BDeuScore.java │ │ ├── DagIterator.java │ │ ├── Ges3.java │ │ ├── GraphSearch.java │ │ ├── ImpliedOrientation.java │ │ ├── IndependenceTest.java │ │ ├── LegalPairs.java │ │ ├── LocalDiscreteScore.java │ │ ├── LocalScoreCache.java │ │ ├── MdluScore.java │ │ ├── ScoredGraph.java │ │ ├── SearchLogUtils.java │ │ └── SepsetMap.java │ ├── test │ │ └── search │ │ │ └── BDeuScoreTest.java │ └── util │ │ ├── ChoiceGenerator.java │ │ ├── CombinationGenerator.java │ │ ├── DefaultTetradLoggerConfig.java │ │ ├── MatrixUtils.java │ │ ├── NamingProtocol.java │ │ ├── NumberFormatUtil.java │ │ ├── PointXy.java │ │ ├── ProbUtils.java │ │ ├── RandomUtil.java │ │ ├── StatUtils.java │ │ ├── TetradLogger.java │ │ ├── TetradLoggerConfig.java │ │ ├── TetradLoggerEvent.java │ │ ├── TetradLoggerListener.java │ │ ├── TetradSerializable.java │ │ └── TextTable.java ├── travis-resources │ ├── Mutagenesis_std_Atom.sql │ ├── Mutagenesis_std_Mole.sql │ ├── Mutagenesis_std_bond.sql │ └── Mutagenesis_std_moleatm.sql └── unreferenced │ ├── BN_ScoreComputation.java │ ├── BayesBaseCT_SortMerge_cont.java │ ├── Compute_Local_CT.java │ ├── Local_CT.java │ ├── RelationalClassification.java │ ├── ScoreComputation.java │ ├── SubsetCTComputation.java │ ├── callLocal_CT.java │ ├── convert_BN_families.java │ ├── fmt.java │ └── local_CP.java └── travis-resources ├── bifchecker.py ├── config.cfg ├── dbdump.sh ├── expected-output ├── Bif_unielwin.xml └── mysql-extraction.txt ├── tests-database.sql ├── unielwin_RA.sql ├── unielwin_course.sql ├── unielwin_prof.sql ├── unielwin_registration.sql └── unielwin_student.sql /.github/workflows/ci-pipeline.yml: -------------------------------------------------------------------------------- 1 | name: Build Status 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | services: 13 | mariadb: 14 | image: mariadb:10.4.17 15 | env: 16 | MYSQL_ROOT_PASSWORD: 123456 17 | options: >- 18 | --health-cmd "mysqladmin ping" 19 | --health-interval 5s 20 | --health-timeout 2s 21 | --health-retries 3 22 | ports: 23 | - 3306:3306 24 | steps: 25 | - uses: actions/checkout@v2 26 | - name: Set up OpenJDK 11 27 | uses: actions/setup-java@v2 28 | with: 29 | java-version: '11.0.12' 30 | distribution: 'temurin' 31 | cache: maven 32 | - name: Setup Database 33 | run: | 34 | mysql -h 127.0.0.1 -uroot -p123456 < travis-resources/unielwin_course.sql 35 | mysql -h 127.0.0.1 -uroot -p123456 < travis-resources/unielwin_prof.sql 36 | mysql -h 127.0.0.1 -uroot -p123456 < travis-resources/unielwin_RA.sql 37 | mysql -h 127.0.0.1 -uroot -p123456 < travis-resources/unielwin_registration.sql 38 | mysql -h 127.0.0.1 -uroot -p123456 < travis-resources/unielwin_student.sql 39 | mysql -h 127.0.0.1 -uroot -p123456 < travis-resources/tests-database.sql 40 | - name: Build and Test 41 | run: | 42 | cd code 43 | mvn install -DtestDBUserName=root -DtestDBPassword=123456 44 | java -Dconfig=../travis-resources/config.cfg -jar factorbase/target/factorbase*SNAPSHOT.jar 45 | ls -lh 46 | tail dag_.txt 47 | # Compare the structure of the graphs in the BIF files. 48 | python3 ../travis-resources/bifchecker.py --compare Bif_unielwin.xml ../travis-resources/expected-output/Bif_unielwin.xml 49 | # Check for any differences in the BIF files. 50 | diff Bif_unielwin.xml ../travis-resources/expected-output/Bif_unielwin.xml 51 | bash ../travis-resources/dbdump.sh -h 127.0.0.1 -n unielwin -p 123456 52 | diff mysql-extraction.txt ../travis-resources/expected-output/mysql-extraction.txt 53 | java -Dconfig=../travis-resources/config.cfg -jar mlnexporter/target/mlnexporter*SNAPSHOT.jar > mln_jar.txt 54 | tail mln_jar.txt 55 | - name: View Database 56 | run: | 57 | mysql -e "show databases;" -h 127.0.0.1 -uroot -p123456 58 | mysql -e "use unielwin_BN; show tables;" -h 127.0.0.1 -uroot -p123456 59 | mysql -e "use unielwin_CT; show tables;" -h 127.0.0.1 -uroot -p123456 60 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *.bak 3 | _*.sql 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /code/common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | ca.sfu.cs 6 | common 7 | 1.0-SNAPSHOT 8 | common 9 | https://github.com/sfu-cl-lab/FactorBase/common 10 | 11 | 12 | UTF-8 13 | 1.8 14 | 1.8 15 | 16 | 17 | 18 | 19 | mysql 20 | mysql-connector-java 21 | 8.0.19 22 | 23 | 24 | -------------------------------------------------------------------------------- /code/common/src/main/java/ca/sfu/cs/common/Configuration/Config.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.common.Configuration; 2 | 3 | import java.io.FileReader; 4 | import java.util.Properties; 5 | 6 | public class Config { 7 | public static final String SCRIPTS_DIRECTORY = "scripts/"; 8 | public static final String DEFAULT_CONFIGFILE = "config.cfg"; 9 | 10 | Properties configFile; 11 | 12 | public Config() { 13 | configFile = new java.util.Properties(); 14 | 15 | String config = System.getProperty("config"); 16 | if (config == null) { 17 | config = DEFAULT_CONFIGFILE; 18 | } 19 | 20 | try (FileReader fileReader = new FileReader(config)) { 21 | configFile.load(fileReader); 22 | } catch(Exception eta) { 23 | eta.printStackTrace(); 24 | } 25 | } 26 | 27 | public String getProperty(String key) { 28 | return this.configFile.getProperty(key); 29 | } 30 | } -------------------------------------------------------------------------------- /code/common/target/common-1.0-SNAPSHOT 2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/common/target/common-1.0-SNAPSHOT 2.jar -------------------------------------------------------------------------------- /code/common/target/common-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/common/target/common-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /code/common/target/maven-archiver/pom.properties: -------------------------------------------------------------------------------- 1 | artifactId=common 2 | groupId=ca.sfu.cs 3 | version=1.0-SNAPSHOT 4 | -------------------------------------------------------------------------------- /code/common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles 2.lst: -------------------------------------------------------------------------------- 1 | ca/sfu/cs/common/Configuration/Config.class 2 | -------------------------------------------------------------------------------- /code/common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst: -------------------------------------------------------------------------------- 1 | ca/sfu/cs/common/Configuration/Config.class 2 | -------------------------------------------------------------------------------- /code/common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst: -------------------------------------------------------------------------------- 1 | /Users/parmis/Desktop/FactorBase/code/common/src/main/java/ca/sfu/cs/common/Configuration/Config.java 2 | -------------------------------------------------------------------------------- /code/componentsrunner/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ca.sfu.cs 5 | componentsrunner 6 | 1.0-SNAPSHOT 7 | componentsrunner 8 | https://github.com/sfu-cl-lab/FactorBase/componentsrunner 9 | 10 | 11 | UTF-8 12 | 1.8 13 | 1.8 14 | 15 | 16 | 17 | 18 | 19 | org.apache.maven.plugins 20 | maven-shade-plugin 21 | 3.1.1 22 | 23 | 24 | package 25 | 26 | shade 27 | 28 | 29 | false 30 | 31 | 32 | ca.sfu.cs.componentsrunner.app.RunComponent 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | ca.sfu.cs 45 | factorbase 46 | 1.0-SNAPSHOT 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /code/componentsrunner/src/main/configs/components-runner.cfg: -------------------------------------------------------------------------------- 1 | # Database information. 2 | dbaddress = mysql://127.0.0.1 3 | dbname = imdb_MovieLens_CT 4 | dbusername = root 5 | dbpassword = 123456 6 | 7 | # See RunComponent.java for possible components. 8 | component = SortMerge 9 | 10 | # Sort Merge Configurations 11 | SortMergeCartesianTableSubQuery = SELECT * FROM b3_1_star 12 | SortMergeSubsetTable = b3_1_flat 13 | SortMergeOutputTable = components_runner_b3_1_false 14 | 15 | # Data Extraction Configurations 16 | ExtractorType = TSV 17 | TSVFile = unielwin/csv/prof0.tsv 18 | CountsTable = a,b,c_a_CT 19 | CountsColumn = MULT 20 | IsDiscrete = true -------------------------------------------------------------------------------- /code/componentsrunner/target/componentsrunner-1.0-SNAPSHOT 2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/componentsrunner/target/componentsrunner-1.0-SNAPSHOT 2.jar -------------------------------------------------------------------------------- /code/componentsrunner/target/componentsrunner-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/componentsrunner/target/componentsrunner-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /code/componentsrunner/target/maven-archiver/pom 2.properties: -------------------------------------------------------------------------------- 1 | artifactId=componentsrunner 2 | groupId=ca.sfu.cs 3 | version=1.0-SNAPSHOT 4 | -------------------------------------------------------------------------------- /code/componentsrunner/target/maven-archiver/pom.properties: -------------------------------------------------------------------------------- 1 | artifactId=componentsrunner 2 | groupId=ca.sfu.cs 3 | version=1.0-SNAPSHOT 4 | -------------------------------------------------------------------------------- /code/componentsrunner/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles 2.lst: -------------------------------------------------------------------------------- 1 | ca/sfu/cs/componentsrunner/app/RunComponent.class 2 | -------------------------------------------------------------------------------- /code/componentsrunner/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst: -------------------------------------------------------------------------------- 1 | ca/sfu/cs/componentsrunner/app/RunComponent.class 2 | -------------------------------------------------------------------------------- /code/componentsrunner/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles 2.lst: -------------------------------------------------------------------------------- 1 | /Users/parmis/Desktop/FactorBase/code/componentsrunner/src/main/java/ca/sfu/cs/componentsrunner/app/RunComponent.java 2 | -------------------------------------------------------------------------------- /code/componentsrunner/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst: -------------------------------------------------------------------------------- 1 | /Users/parmis/Desktop/FactorBase/code/componentsrunner/src/main/java/ca/sfu/cs/componentsrunner/app/RunComponent.java 2 | -------------------------------------------------------------------------------- /code/componentsrunner/target/original-componentsrunner-1.0-SNAPSHOT 2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/componentsrunner/target/original-componentsrunner-1.0-SNAPSHOT 2.jar -------------------------------------------------------------------------------- /code/componentsrunner/target/original-componentsrunner-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/componentsrunner/target/original-componentsrunner-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/data/DataExtractor.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.data; 2 | 3 | import ca.sfu.cs.factorbase.exception.DataExtractionException; 4 | 5 | /** 6 | * Methods expected to be implemented to enable the extraction of data from a data source. 7 | */ 8 | public interface DataExtractor { 9 | DataSet extractData() throws DataExtractionException; 10 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/data/DataSet.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.data; 2 | 3 | /** 4 | * Class to hold information from a data source. 5 | */ 6 | public class DataSet { 7 | private boolean isDiscrete; 8 | private double[][] data; 9 | private DataSetMetaData metadata; 10 | 11 | 12 | /** 13 | * Create a Java representation of a dataset, which consists of data and metadata. 14 | * 15 | * @param data - a representation of the dataset where each state has been converted into an indexed value. 16 | * @param metadata - the associated metadata for the given {@code data}. 17 | * @param isDiscrete - true if the dataset only contains discrete information; otherwise false. 18 | */ 19 | public DataSet(double[][] data, DataSetMetaData metadata, boolean isDiscrete) { 20 | this.data = data; 21 | this.metadata = metadata; 22 | this.isDiscrete = isDiscrete; 23 | } 24 | 25 | 26 | /** 27 | * Retrieve the data for the dataset. 28 | * 29 | * @return a 2D array representation of the dataset where each state has been converted into an indexed value. 30 | */ 31 | public double[][] getData() { 32 | return this.data; 33 | } 34 | 35 | 36 | /** 37 | * The metadata for the associated 2D array representation of the dataset. 38 | * 39 | * @return the metadata for the dataset. 40 | */ 41 | public DataSetMetaData getMetaData() { 42 | return this.metadata; 43 | } 44 | 45 | 46 | /** 47 | * Indicates whether or not the dataset given to the ContingencyTableGenerator only contains 48 | * discrete information. 49 | * 50 | * @return true if the dataset only contains discrete information; otherwise false. 51 | */ 52 | public boolean isDiscrete() { 53 | return this.isDiscrete; 54 | } 55 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/data/FunctorNode.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.data; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | /** 7 | * Class to store information for a FunctorNode. 8 | */ 9 | public class FunctorNode { 10 | private String functorNodeID; 11 | private Set functorNodeStates; 12 | 13 | 14 | /** 15 | * Create a FunctorNode to store its metadata. 16 | * 17 | * @param functorNodeID - the ID for the functor node. 18 | */ 19 | public FunctorNode(String functorNodeID) { 20 | this.functorNodeID = functorNodeID; 21 | this.functorNodeStates = new HashSet(); 22 | } 23 | 24 | 25 | /** 26 | * Store a possible state for the functor node (duplicates will be ignored). 27 | * 28 | * @param stateValue - the value of the state for the functor node. 29 | */ 30 | public void addState(String stateValue) { 31 | this.functorNodeStates.add(stateValue); 32 | } 33 | 34 | 35 | /** 36 | * Retrieve the ID for the functor node. 37 | * 38 | * @return the ID for the functor node. 39 | */ 40 | public String getFunctorNodeID() { 41 | return this.functorNodeID; 42 | } 43 | 44 | 45 | /** 46 | * Retrieve the possible states for the functor node. 47 | * 48 | * @return the possible states for the functor node. 49 | */ 50 | public Set getFunctorNodeStates() { 51 | return this.functorNodeStates; 52 | } 53 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/data/RandomVariableAssignment.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.data; 2 | 3 | import java.util.Objects; 4 | 5 | /** 6 | * Class to hold information for the assignment state of a random variable. 7 | */ 8 | public class RandomVariableAssignment { 9 | private int columnIndex; 10 | private int stateIndex; 11 | 12 | 13 | /** 14 | * Store information for the assignment of a random variable. 15 | * 16 | * @param columnIndex - the column index of the random variable in the dataset. 17 | * @param stateIndex - the assignment for the random variable, using the index position of the state. 18 | */ 19 | public RandomVariableAssignment(int columnIndex, int stateIndex) { 20 | this.columnIndex = columnIndex; 21 | this.stateIndex = stateIndex; 22 | } 23 | 24 | 25 | /** 26 | * Retrieve the column index of the random variable for the assignment. 27 | * 28 | * @return the column index of the random variable for the assignment. 29 | */ 30 | public int getVariableColumnIndex() { 31 | return this.columnIndex; 32 | } 33 | 34 | 35 | /** 36 | * Retrieve the index position of the state. 37 | * 38 | * @return the index position of the state. 39 | */ 40 | public int getStateIndex() { 41 | return this.stateIndex; 42 | } 43 | 44 | 45 | @Override 46 | public boolean equals(Object objectToCompare) { 47 | if (objectToCompare == this) { 48 | return true; 49 | } else if (!(objectToCompare instanceof RandomVariableAssignment)) { 50 | return false; 51 | } 52 | 53 | RandomVariableAssignment randomVariable = (RandomVariableAssignment) objectToCompare; 54 | 55 | return this.columnIndex == randomVariable.getVariableColumnIndex() && this.stateIndex == randomVariable.getStateIndex(); 56 | } 57 | 58 | 59 | @Override 60 | public int hashCode() { 61 | return Objects.hash(this.columnIndex, this.stateIndex); 62 | } 63 | 64 | 65 | @Override 66 | public String toString() { 67 | return this.columnIndex + " = " + this.stateIndex; 68 | } 69 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/database/FactorBaseDataBaseInfo.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.database; 2 | 3 | import ca.sfu.cs.common.Configuration.Config; 4 | 5 | /** 6 | * Class to store and pass database information related to FactorBase. 7 | */ 8 | public class FactorBaseDataBaseInfo { 9 | private String bnDatabaseName; 10 | private String ctCacheDatabaseName; 11 | private String ctDatabaseName; 12 | private String globalCountsDatabaseName; 13 | private String setupDatabaseName; 14 | private String countColumnName; 15 | private boolean isDiscrete; 16 | 17 | /** 18 | * Extract the database information related to FactorBase. 19 | * 20 | * @param config - configuration information used to help determine database information related to FactorBase. 21 | */ 22 | public FactorBaseDataBaseInfo(Config config) { 23 | String dbName = config.getProperty("dbname"); 24 | this.bnDatabaseName = dbName + "_BN"; 25 | this.ctCacheDatabaseName = dbName + "_CT_cache"; 26 | this.ctDatabaseName = dbName + "_CT"; 27 | this.globalCountsDatabaseName = dbName + "_global_counts"; 28 | this.setupDatabaseName = dbName + "_setup"; 29 | this.countColumnName = "MULT"; 30 | this.isDiscrete = !config.getProperty("Continuous").equals("1"); 31 | } 32 | 33 | 34 | /** 35 | * Retrieve the name of the BN database for FactorBase. 36 | * 37 | * @return the name of the BN database. 38 | */ 39 | public String getBNDatabaseName() { 40 | return this.bnDatabaseName; 41 | } 42 | 43 | 44 | /** 45 | * Retrieve the name of the CT cache database for FactorBase. 46 | * 47 | * @return the name of the CT cache database. 48 | */ 49 | public String getCTCacheDatabaseName() { 50 | return this.ctCacheDatabaseName; 51 | } 52 | 53 | 54 | /** 55 | * Retrieve the name of the CT database for FactorBase. 56 | * 57 | * @return the name of the CT database. 58 | */ 59 | public String getCTDatabaseName() { 60 | return this.ctDatabaseName; 61 | } 62 | 63 | 64 | /** 65 | * Retrieve the name of the global counts database for FactorBase. 66 | * 67 | * @return the name of the global counts database. 68 | */ 69 | public String getGlobalCountsDatabaseName() { 70 | return this.globalCountsDatabaseName; 71 | } 72 | 73 | 74 | /** 75 | * Retrieve the name of the setup database for FactorBase. 76 | * 77 | * @return the name of the setup database. 78 | */ 79 | public String getSetupDatabaseName() { 80 | return this.setupDatabaseName; 81 | } 82 | 83 | 84 | /** 85 | * Retrieve the name of the column containing the counts information. 86 | * 87 | * @return the name of the column containing the counts information. 88 | */ 89 | public String getCountColumnName() { 90 | return this.countColumnName; 91 | } 92 | 93 | 94 | /** 95 | * Indicates if the dataset only contains discrete data. 96 | * 97 | * @return true iff the dataset only contains discrete data, otherwise false. 98 | */ 99 | public boolean isDiscrete() { 100 | return this.isDiscrete; 101 | } 102 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/exception/DataBaseException.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.exception; 2 | 3 | 4 | /** 5 | * Custom exception to wrap and throw the specific cause of an error. Should be thrown when an 6 | * error occurs when attempting to access a database. 7 | */ 8 | public class DataBaseException extends Exception { 9 | 10 | 11 | /** 12 | * Serial version - auto-generated by Eclipse. 13 | */ 14 | private static final long serialVersionUID = -6623897407612813075L; 15 | 16 | 17 | /** 18 | * Used to wrap the root cause of an exception when attempting to access a database. 19 | * 20 | * @param message - useful message telling the user what has potentially gone wrong. 21 | * @param cause - the exception that caused the error to occur when accessing a database. 22 | */ 23 | public DataBaseException(String message, Throwable cause) { 24 | super(message, cause); 25 | } 26 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/exception/DataExtractionException.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.exception; 2 | 3 | 4 | /** 5 | * Custom exception to wrap and throw the specific cause of an error. Should be thrown when an 6 | * error occurs when attempting to extract data from a data source. 7 | */ 8 | public class DataExtractionException extends Exception { 9 | 10 | 11 | /** 12 | * Serial version - auto-generated by Eclipse. 13 | */ 14 | private static final long serialVersionUID = -2844261251784379099L; 15 | 16 | 17 | /** 18 | * Used to wrap the root cause of an exception when attempting to extract data from a data source. 19 | * 20 | * @param message - useful message telling the user what has potentially gone wrong. 21 | * @param cause - the exception that caused the error to occur when extracting data from a data source. 22 | */ 23 | public DataExtractionException(String message, Throwable cause) { 24 | super(message, cause); 25 | } 26 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/exception/ScoringException.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.exception; 2 | 3 | 4 | /** 5 | * Custom exception to wrap and throw the specific cause of an error. Should be thrown when an 6 | * error occurs when attempting to compute the score for a Bayesian Network structure. 7 | */ 8 | public class ScoringException extends Exception { 9 | 10 | 11 | /** 12 | * Serial version - auto-generated by Eclipse. 13 | */ 14 | private static final long serialVersionUID = 526269150042072120L; 15 | 16 | /** 17 | * Used to wrap the root cause of an exception when attempting to compute the score for a Bayesian Network 18 | * structure. 19 | * 20 | * @param message - useful message telling the user what has potentially gone wrong. 21 | * @param cause - the exception that caused the error to occur when computing the score. 22 | */ 23 | public ScoringException(String message, Throwable cause) { 24 | super(message, cause); 25 | } 26 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/exporter/bifexporter/bif/BIF_IO.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.exporter.bifexporter.bif; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class BIF_IO { 6 | public static String writeBifHeader() { 7 | StringBuilder builder = new StringBuilder(); 8 | builder.append("\n"); 9 | builder.append("\n"); 10 | builder.append("\n"); 12 | builder.append("\t\t\n"); 13 | builder.append("\t\n"); 14 | builder.append("\t\n"); 15 | builder.append("\t\n"); 16 | builder.append("\t\t\n"); 17 | builder.append("\t\n"); 18 | builder.append("\t\n"); 19 | builder.append("\t\n"); 20 | builder.append("\t\n"); 21 | builder.append("\t\n"); 22 | builder.append("\t\n"); 23 | builder.append("]>\n\n"); 24 | return builder.toString(); 25 | } 26 | 27 | 28 | public static String writeNetworkBegin(String name) { 29 | return "\n\n" + name + "\n"; 30 | } 31 | 32 | 33 | public static String writeNetworkEnd() { 34 | return "\n\n"; 35 | } 36 | 37 | 38 | public static String writeVariable(String variable, ArrayList outcomes) { 39 | StringBuilder builder = new StringBuilder("\n"); 40 | builder.append("\t"); 41 | builder.append(variable); 42 | builder.append("\n"); 43 | 44 | for (String outcome : outcomes) { 45 | builder.append("\t"); 46 | builder.append(outcome); 47 | builder.append("\n"); 48 | } 49 | 50 | builder.append("\n"); 51 | return builder.toString(); 52 | } 53 | 54 | 55 | public static String writeDefinition(String forVariable, ArrayList givenVariables) { 56 | StringBuilder builder = new StringBuilder("\n"); 57 | builder.append("\t"); 58 | builder.append(forVariable); 59 | builder.append("\n"); 60 | 61 | for (String given : givenVariables) { 62 | builder.append("\t"); 63 | builder.append(given); 64 | builder.append("\n"); 65 | } 66 | 67 | builder.append("\n"); 68 | return builder.toString(); 69 | } 70 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/graph/Edge.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.graph; 2 | 3 | /** 4 | * Simple class to store information for an edge between a parent and a child node. 5 | */ 6 | public class Edge { 7 | 8 | private String parent; 9 | private String child; 10 | 11 | 12 | /** 13 | * Create an Edge object that represents an edge between the given child and parent nodes. 14 | * @param parent - the parent node. 15 | * @param child - the child node. 16 | */ 17 | public Edge(String parent, String child) { 18 | this.parent = parent; 19 | this.child = child; 20 | } 21 | 22 | /** 23 | * Retrieve the parent for the given edge. 24 | * @return the parent for the given edge. 25 | */ 26 | public String getParent() { 27 | return this.parent; 28 | } 29 | 30 | /** 31 | * Retrieve the child for the given edge. 32 | * @return the child for the given edge. 33 | */ 34 | public String getChild() { 35 | return this.child; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/lattice/RelationshipLattice.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.lattice; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import ca.sfu.cs.factorbase.data.FunctorNodesInfo; 9 | 10 | /** 11 | * Class to store the information for a relationship lattice. 12 | */ 13 | public class RelationshipLattice { 14 | private Map> rchainInfosPerLevel = new HashMap>(); 15 | private int latticeHeight = 0; 16 | private String longestRChain; 17 | 18 | 19 | /** 20 | * Initialize a {@code RelationshipLattice} to store relationship lattice information. 21 | */ 22 | public RelationshipLattice() { 23 | } 24 | 25 | 26 | /** 27 | * Retrieve the height of the lattice. 28 | * 29 | * @return the height of the lattice. 30 | */ 31 | public int getHeight() { 32 | return this.latticeHeight; 33 | } 34 | 35 | 36 | /** 37 | * Retrieve the name of the longest RChain in the lattice. 38 | * 39 | * @return the name of the longest RChain in the lattice. 40 | */ 41 | public String getLongestRChain() { 42 | return this.longestRChain; 43 | } 44 | 45 | 46 | /** 47 | * Add the given functor node information of an RChain to the specified lattice level. 48 | * 49 | * @param rchainInfo - the functor node information of the RChain to add. 50 | * @param level - the level (height) of the RChain in the lattice. 51 | */ 52 | public void addRChainInfo(FunctorNodesInfo rchainInfo, int level) { 53 | // Update some information if the new RChain being added is the longest we've seen so far. 54 | if (level > this.latticeHeight) { 55 | this.latticeHeight = level; 56 | this.longestRChain = rchainInfo.getID(); 57 | } 58 | 59 | this.rchainInfosPerLevel.computeIfAbsent( 60 | level, 61 | _level -> new ArrayList() 62 | ).add(rchainInfo); 63 | } 64 | 65 | 66 | /** 67 | * Retrieve all the functor node information for the RChains with the specified length. 68 | * 69 | * @param length - the length of the RChains to retrieve. 70 | * @return the {@code FunctorNodesInfo}s for RChains with the specified length. 71 | */ 72 | public List getRChainsInfo(int length) { 73 | return this.rchainInfosPerLevel.get(length); 74 | } 75 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/learning/CPGenerator.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.learning; 2 | 3 | import java.io.IOException; 4 | import java.sql.Connection; 5 | 6 | /** 7 | * @Jun 6, zqian 8 | * generating CP tables by calling a store procedure in _BN database 9 | * And also computing BIC,AIC,loglikelihood 10 | * 11 | * August 9. This just adds Boolean values for the relationship values to the Attribute_Values tables. Todo: move this to Find_Values part. 12 | */ 13 | import java.sql.ResultSet; 14 | import java.sql.SQLException; 15 | import java.sql.Statement; 16 | 17 | public class CPGenerator { 18 | public static void Generator( 19 | String databaseName, 20 | Connection con 21 | ) throws SQLException, IOException { 22 | try ( 23 | Statement rnodeStatement = con.createStatement(); 24 | Statement statement = con.createStatement(); 25 | ResultSet results = rnodeStatement.executeQuery("SELECT rnid FROM RNodes;") 26 | ) { 27 | // Convert FNodes view into a table so that UPDATEs can be called on it. 28 | statement.executeUpdate("RENAME TABLE FNodes TO FNodes_view"); 29 | statement.executeUpdate("CREATE TABLE FNodes AS SELECT * FROM FNodes_view"); 30 | statement.executeUpdate("DROP VIEW FNodes_view"); 31 | 32 | // Adding possible values of Rnodes into Attribute_Value. // Jun 6. 33 | while(results.next()) { 34 | String rnid = results.getString("rnid"); 35 | statement.execute("SET SQL_SAFE_UPDATES = 0;"); 36 | 37 | // Adding boolean values for rnodes. 38 | // TODO: Figure out if this DELETE query is actually necessary. 39 | statement.execute( 40 | "DELETE FROM " + 41 | databaseName + "_setup.Attribute_Value " + 42 | "WHERE " + 43 | "column_name = '" + rnid + "';" 44 | ); 45 | statement.execute( 46 | "INSERT INTO " + databaseName + "_setup.Attribute_Value " + 47 | "VALUES('" + rnid + "', 'T');" 48 | ); 49 | statement.execute( 50 | "INSERT INTO " + databaseName + "_setup.Attribute_Value " + 51 | "VALUES('" + rnid + "', 'F');" 52 | ); 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/search/BDeuScore.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.search; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.List; 5 | import java.util.Set; 6 | 7 | import ca.sfu.cs.factorbase.data.ContingencyTable; 8 | import ca.sfu.cs.factorbase.data.ContingencyTableGenerator; 9 | import ca.sfu.cs.factorbase.data.RandomVariableAssignment; 10 | import ca.sfu.cs.factorbase.search.DiscreteLocalScore; 11 | import edu.cmu.tetrad.util.ProbUtils; 12 | 13 | /** 14 | * Class to compute the BDeuScore for a given child and its parents. 15 | */ 16 | public class BDeuScore implements DiscreteLocalScore { 17 | 18 | private ContingencyTableGenerator contingencyTableGenerator; 19 | private double samplePrior; 20 | private double structurePrior; 21 | 22 | 23 | /** 24 | * Create a new BDeuScore object for the given dataset and using the given hyperparameters. 25 | * @param ctGenerator - {@code ContingencyTableGenerator} object to create the CT tables necessary for computing 26 | * the BDeuScore of a given child and its parents. 27 | * @param samplePrior - the equivalent sample size (N'). 28 | * @param structurePrior - the prior probability for the network structure. 29 | */ 30 | public BDeuScore (ContingencyTableGenerator ctGenerator, double samplePrior, double structurePrior) { 31 | this.contingencyTableGenerator = ctGenerator; 32 | this.samplePrior = samplePrior; 33 | this.structurePrior = structurePrior; 34 | } 35 | 36 | 37 | @Override 38 | public double localScore(String child, Set parents) { 39 | int childColumnIndex = this.contingencyTableGenerator.getColumnIndex(child); 40 | int[] parentColumnIndices = this.contingencyTableGenerator.getColumnIndices(parents); 41 | 42 | // Number of child states. 43 | int r = this.contingencyTableGenerator.getNumberOfStates(childColumnIndex); 44 | 45 | // Number of parent states. 46 | int q = 1; 47 | for (int parent : parentColumnIndices) { 48 | q *= this.contingencyTableGenerator.getNumberOfStates(parent); 49 | } 50 | 51 | ContingencyTable ct = this.contingencyTableGenerator.generateCT(childColumnIndex, parentColumnIndices, r * q); 52 | 53 | // Calculate score. 54 | BigDecimal score = new BigDecimal((r - 1) * q * Math.log(this.structurePrior)); 55 | 56 | for (List parentAssignments : this.contingencyTableGenerator.getStates(parentColumnIndices)) { 57 | double countsSum = 0; 58 | long counts; 59 | for (int childStateIndex = 0; childStateIndex < r; childStateIndex++) { 60 | RandomVariableAssignment childAssignment = new RandomVariableAssignment(childColumnIndex, childStateIndex); 61 | counts = ct.getCounts(childAssignment, parentAssignments); 62 | countsSum += counts; 63 | score = score.add(new BigDecimal(ProbUtils.lngamma(this.samplePrior / (r * q) + counts))); 64 | } 65 | 66 | score = score.subtract(new BigDecimal(ProbUtils.lngamma(this.samplePrior / q + countsSum))); 67 | } 68 | 69 | score = score.add(new BigDecimal(q * ProbUtils.lngamma(this.samplePrior / q))); 70 | score = score.subtract(new BigDecimal((r * q) * ProbUtils.lngamma(this.samplePrior / (r * q)))); 71 | 72 | return score.doubleValue(); 73 | } 74 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/search/DiscreteLocalScore.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.search; 2 | 3 | import java.util.Set; 4 | 5 | import ca.sfu.cs.factorbase.exception.ScoringException; 6 | 7 | public interface DiscreteLocalScore { 8 | /** 9 | * Compute the score for the given family of nodes. 10 | * 11 | * @param child - name of child node. 12 | * @param parents - name of parent nodes. 13 | * @return the score of the given family of nodes. 14 | * @throws ScoringException if an error occurs when trying to compute the score. 15 | */ 16 | double localScore(String child, Set parents) throws ScoringException; 17 | } 18 | -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/util/Mapper.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.util; 2 | 3 | import java.util.Collection; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import java.util.function.Function; 7 | 8 | /** 9 | * Class related to Map objects used by FactorBase. 10 | */ 11 | public final class Mapper { 12 | private static StringBuilder builder = new StringBuilder(); 13 | 14 | /** 15 | * Private constructor to prevent instantiation of the utility class. 16 | */ 17 | private Mapper() { 18 | } 19 | 20 | 21 | /** 22 | * Generate a Map that has key:value pairs of column-name:column-index. 23 | * 24 | * @param header - header from the dataset. 25 | * @return Map object that maps each column name to its associated column index. 26 | */ 27 | public static Map mapHeadersToColumnIndices(String[] header) { 28 | Map headerToColumnIndex = new HashMap(); 29 | 30 | // for loop to create a Map that has key:value pairs of column-name:column-index. 31 | for (int index = 0; index < header.length; index++) { 32 | headerToColumnIndex.put(header[index], index); 33 | } 34 | 35 | return headerToColumnIndex; 36 | } 37 | 38 | 39 | /** 40 | * Generate the Map key for a variable when it is assigned a particular value. This is the key that should be used 41 | * to retrieve a value from the Map generated by the {@code Mapper.mapVariableStateToInteger()} method. 42 | * 43 | * @param variable - the name of the variable being assigned a particular value. 44 | * @param state - the state being assigned to the variable given. 45 | * @return a key to retrieve the integer encoding for the variable assignment. 46 | */ 47 | public static String generateVariableStateKey(String variable, String state) { 48 | builder.setLength(0); 49 | builder.append(variable); 50 | builder.append(" = "); 51 | builder.append(state); 52 | return builder.toString(); 53 | } 54 | 55 | 56 | /** 57 | * Retrieve the indices for the given {@code String}s using the provided mapping {@code Function}. 58 | *

59 | * Note: From testing, this implementation seems a bit faster than using Java's built-in .map() function when the 60 | * number of items is small and about the same when the number of items is large. 61 | *

62 | * 63 | * @param items - the items to translate into its associated index. 64 | * @param indexMapper - {@code Function} to map each of the given items to an associated index. 65 | * @return the indices of the given items. 66 | */ 67 | public static int[] convertToIndices(Collection items, Function indexMapper) { 68 | int[] columnIndices = new int[items.size()]; 69 | 70 | // for loop to get the associated index for each item. 71 | int insertIndex = 0; 72 | for (String item : items) { 73 | columnIndices[insertIndex] = indexMapper.apply(item); 74 | insertIndex++; 75 | } 76 | 77 | return columnIndices; 78 | } 79 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/ca/sfu/cs/factorbase/util/Sort_merge3.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.util; 2 | 3 | /** 4 | * Aug 18, 2014. zqian 5 | * Handle the extreme case when there's only `mult` column. 6 | * Fixed the bug found on July 6th. 7 | */ 8 | 9 | /** 10 | * July 6th, 2014. zqian 11 | * Bug for processing the following case: 12 | * star: mult1 13 | * flat: mult2 14 | * false: mult1-mult2 ? 15 | * try: Financial_std_Training1_db.`operation(trans0)_a_star` 16 | */ 17 | import java.sql.Connection; 18 | import java.sql.ResultSet; 19 | import java.sql.SQLException; 20 | import java.sql.Statement; 21 | import java.util.ArrayList; 22 | import java.util.logging.Logger; 23 | 24 | /** 25 | * Sort merge version3 26 | * Here the compare function is also good without concatenating the order by columns. 27 | */ 28 | public class Sort_merge3 { 29 | private static Logger logger = Logger.getLogger(Sort_merge3.class.getName()); 30 | 31 | 32 | /** 33 | * Subtract the MULT column of the rows in {@code table1Subquery} by the MULT column of the matching row in 34 | * {@code table2}. 35 | * 36 | * @param conn - connection to the database containing {@code table1} and {@code table2}. 37 | * @param sourceDatabaseName - the name of the database containing {@code table1} and {@code table2}. 38 | * @param table1Subquery - a subquery that generates a table to have its values in the MULT column subtracted by 39 | * the MULT column in {@code table2}. 40 | * @param table2 - the table to match rows with in {@code table1} and subtract by the values found in the 41 | * MULT column. 42 | * @return an SQL query that applies the sort merge algorithm to the two specified tables. 43 | * @throws SQLException if there are issues executing the queries. 44 | */ 45 | public static String sort_merge( 46 | Connection conn, 47 | String sourceDatabaseName, 48 | String table1Subquery, 49 | String table2 50 | ) throws SQLException { 51 | // Ensure that all the table names are escaped before attempting to execute any queries with them. 52 | table2 = sourceDatabaseName + ".`" + table2 + "`"; 53 | 54 | Statement st1 = conn.createStatement(); 55 | 56 | ArrayList joinOnList = new ArrayList(); 57 | 58 | /** 59 | * Get the JOIN ON columns using TABLE2. 60 | */ 61 | ResultSet rst = st1.executeQuery( 62 | "SHOW COLUMNS FROM " + table2 + 63 | "WHERE field <> \"MULT\";" 64 | ); 65 | 66 | while(rst.next()) { 67 | joinOnList.add(rst.getString(1)); 68 | } 69 | rst.close(); 70 | st1.close(); 71 | 72 | String selectQuery; 73 | if (joinOnList.size() > 0) { 74 | selectQuery = QueryGenerator.createSubtractionQuery(table1Subquery, table2, "MULT", joinOnList); 75 | } else { 76 | // Aug 18, 2014 zqian: Handle the extreme case when there's only the `MULT` column. 77 | selectQuery = 78 | "SELECT (SUBQUERY.MULT - " + table2 + ".MULT) AS MULT " + 79 | "FROM (" + table1Subquery + ") AS SUBQUERY, " + table2; 80 | } 81 | 82 | return selectQuery; 83 | } 84 | } -------------------------------------------------------------------------------- /code/factorbase/src/main/java/edu/cmu/tetrad/data/KnowledgeTransferable.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.data; 23 | 24 | import edu.cmu.tetrad.util.TetradSerializable; 25 | 26 | /** 27 | * Interface implemented by classes that are capable of participating in the 28 | * transfer of knowledge objects. 29 | * 30 | * @author Joseph Ramsey 31 | * @see Knowledge 32 | */ 33 | public interface KnowledgeTransferable extends TetradSerializable { 34 | static final long serialVersionUID = 23L; 35 | 36 | /** 37 | * Returns a copy of the knowledge for this class. 38 | */ 39 | Knowledge getKnowledge(); 40 | 41 | /** 42 | * Sets knowledge to a copy of the given object. 43 | */ 44 | void setKnowledge(Knowledge knowledge); 45 | } 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /code/factorbase/src/main/java/edu/cmu/tetrad/search/GraphScorer.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.search; 23 | 24 | import edu.cmu.tetrad.graph.Graph; 25 | 26 | /** 27 | * Scores a pattern. 28 | * 29 | * @author Joseph Ramsey 30 | */ 31 | public interface GraphScorer { 32 | double scoreGraph(Graph graph); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /code/factorbase/src/main/resources/scripts/initialize_databases.sql: -------------------------------------------------------------------------------- 1 | -- Initialize the databases required by FactorBase. 2 | 3 | SET collation_server = 'utf8_general_ci'; 4 | 5 | DROP SCHEMA IF EXISTS @database@_setup; 6 | CREATE SCHEMA @database@_setup; 7 | 8 | DROP SCHEMA IF EXISTS @database@_BN; 9 | CREATE SCHEMA @database@_BN; 10 | 11 | DROP SCHEMA IF EXISTS @database@_CT; 12 | CREATE SCHEMA @database@_CT; 13 | 14 | DROP SCHEMA IF EXISTS @database@_global_counts; 15 | CREATE SCHEMA @database@_global_counts; 16 | 17 | DROP SCHEMA IF EXISTS @database@_CT_cache; 18 | CREATE SCHEMA @database@_CT_cache; -------------------------------------------------------------------------------- /code/factorbase/src/main/resources/scripts/latticegenerator_initialize.sql: -------------------------------------------------------------------------------- 1 | /* Create the tables necessary for generating the lattice. */ 2 | SET storage_engine=INNODB; 3 | 4 | CREATE TABLE lattice_membership ( 5 | name VARCHAR(300), 6 | member VARCHAR(300), 7 | PRIMARY KEY(name, member) 8 | ); 9 | 10 | 11 | CREATE TABLE lattice_rel ( 12 | parent VARCHAR(300), 13 | child VARCHAR(300), 14 | removed VARCHAR(300), 15 | PRIMARY KEY(parent, child) 16 | ); 17 | 18 | 19 | CREATE TABLE lattice_set ( 20 | name VARCHAR(300), 21 | length INT(11), 22 | PRIMARY KEY(name, length) 23 | ); 24 | 25 | 26 | CREATE TABLE lattice_mapping ( 27 | orig_rnid VARCHAR(300), 28 | short_rnid VARCHAR(20), 29 | PRIMARY KEY(orig_rnid, short_rnid) 30 | ); -------------------------------------------------------------------------------- /code/factorbase/src/main/resources/scripts/latticegenerator_initialize_local.sql: -------------------------------------------------------------------------------- 1 | /* Create the tables necessary for generating the lattice. */ 2 | SET storage_engine=MEMORY; 3 | 4 | CREATE TABLE lattice_membership ( 5 | name VARCHAR(300), 6 | member VARCHAR(300), 7 | PRIMARY KEY(name, member) 8 | ); 9 | 10 | 11 | CREATE TABLE lattice_rel ( 12 | parent VARCHAR(300), 13 | child VARCHAR(300), 14 | removed VARCHAR(300), 15 | PRIMARY KEY(parent, child) 16 | ); 17 | 18 | 19 | CREATE TABLE lattice_set ( 20 | name VARCHAR(300), 21 | length INT(11), 22 | PRIMARY KEY(name, length) 23 | ); 24 | 25 | 26 | CREATE VIEW lattice_mapping AS 27 | SELECT 28 | orig_rnid, 29 | short_rnid 30 | FROM 31 | @database@_setup.lattice_mapping; -------------------------------------------------------------------------------- /code/factorbase/src/main/resources/scripts/latticegenerator_populate.sql: -------------------------------------------------------------------------------- 1 | /** 2 | * Populate the local relationship lattice tables by extracting information from the global relationship lattice 3 | * tables. 4 | */ 5 | CREATE PROCEDURE populateLattice() 6 | BEGIN 7 | 8 | TRUNCATE lattice_membership; 9 | INSERT INTO lattice_membership 10 | -- Get the "name"s and "member"s where the "name"s are unique to the local lattice. 11 | SELECT 12 | name, 13 | member 14 | FROM 15 | @database@_setup.lattice_membership LMEM, 16 | LatticeRNodes LR 17 | WHERE 18 | LMEM.member = LR.orig_rnid 19 | AND 20 | name 21 | NOT IN ( 22 | -- Get the "name"s that belong to RNodes that are not in the local lattice. 23 | SELECT 24 | name 25 | FROM 26 | @database@_setup.lattice_membership 27 | WHERE 28 | member 29 | NOT IN ( 30 | -- Get the RNodes for the local lattice. 31 | SELECT 32 | orig_rnid 33 | FROM 34 | LatticeRNodes 35 | ) 36 | ); 37 | 38 | 39 | TRUNCATE lattice_rel; 40 | INSERT INTO lattice_rel 41 | SELECT 42 | parent, 43 | child, 44 | removed 45 | FROM 46 | @database@_setup.lattice_rel LREL, 47 | LatticeRNodes LR 48 | WHERE 49 | LREL.removed = LR.orig_rnid; 50 | 51 | 52 | TRUNCATE lattice_set; 53 | INSERT INTO lattice_set 54 | SELECT 55 | LS.name, 56 | length 57 | FROM 58 | @database@_setup.lattice_set LS, 59 | lattice_membership LMEM, 60 | LatticeRNodes LR 61 | WHERE 62 | LMEM.member = LR.orig_rnid 63 | AND 64 | LS.name = LMEM.name 65 | GROUP BY 66 | LS.name; 67 | END// -------------------------------------------------------------------------------- /code/factorbase/src/main/resources/scripts/logging.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE CallLogs ( 2 | CallNumber INT, 3 | cascadeFS INT, -- MetaData 4 | lattice INT, -- MetaData 5 | populateMQ INT, -- MetaData 6 | populateMQRChain INT, -- MetaData 7 | buildPVarsCounts INT, -- Counts 8 | buildRNodeCounts INT, -- Add to Counts, Subtract from Mobius Join 9 | buildRChainCounts INT, -- Counts 10 | createJoinTableQueries INT, -- Mobius Join 11 | buildFlatStarCT INT -- Mobius Join 12 | ) ENGINE = MEMORY; -------------------------------------------------------------------------------- /code/factorbase/src/main/resources/scripts/metadata_storedprocedures.sql: -------------------------------------------------------------------------------- 1 | CREATE PROCEDURE `find_values`() 2 | BEGIN 3 | DECLARE done INT DEFAULT 0; 4 | DECLARE tablename VARCHAR(30); 5 | DECLARE columnname VARCHAR(30); 6 | DECLARE cur1 CURSOR FOR 7 | SELECT TABLE_NAME, COLUMN_NAME FROM AttributeColumns; 8 | DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; 9 | OPEN cur1; 10 | 11 | DROP TABLE IF EXISTS Attribute_Value; 12 | CREATE TABLE 13 | Attribute_Value ( 14 | COLUMN_NAME VARCHAR(269), 15 | VALUE VARCHAR(30)); 16 | 17 | LOOP1: LOOP 18 | FETCH cur1 INTO tablename, columnname; 19 | IF done = 1 THEN 20 | LEAVE LOOP1; 21 | END IF; 22 | SET @SQLQUERY = 'INSERT INTO Attribute_Value ('; 23 | SET @SQLQUERY = CONCAT(@SQLQUERY, 'SELECT distinct "', columnname); 24 | SET @SQLQUERY = CONCAT(@SQLQUERY, '", ', columnname); 25 | SET @SQLQUERY = CONCAT(@SQLQUERY, ' FROM @database@.', tablename, ')'); 26 | 27 | PREPARE stmt1 FROM @SQLQUERY; 28 | EXECUTE stmt1; 29 | END LOOP LOOP1; 30 | 31 | CLOSE cur1; 32 | 33 | END// -------------------------------------------------------------------------------- /code/factorbase/src/main/resources/scripts/metaqueries_initialize.sql: -------------------------------------------------------------------------------- 1 | /* Create the table and view necessary for storing metaquery information. */ 2 | 3 | /*SET storage_engine=MEMORY;*/ 4 | 5 | CREATE TABLE MetaQueries ( 6 | Lattice_Point varchar(398), /* e.g. pvid, rchain, prof0, a */ 7 | TableType varchar(100), /* e.g. star, flat, counts */ 8 | ClauseType varchar(10), /* FROM, WHERE, SELECT, GROUPBY */ 9 | EntryType varchar(100), /* e.g. 1node, aggregate like count */ 10 | Entries varchar(150) 11 | ); 12 | 13 | 14 | CREATE VIEW RChain_pvars AS 15 | SELECT DISTINCT 16 | M.name AS rchain, 17 | pvid 18 | FROM 19 | lattice_membership M, 20 | RNodes_pvars R 21 | WHERE 22 | R.rnid = M.member; -------------------------------------------------------------------------------- /code/factorbase/src/main/resources/scripts/transfer_cascade.sql: -------------------------------------------------------------------------------- 1 | /* Cascade the information (based on the FunctorSet table) into the tables created by the transfer_initialize.sql script. */ 2 | 3 | CREATE PROCEDURE cascadeFS() 4 | BEGIN 5 | 6 | TRUNCATE 1Nodes; 7 | INSERT INTO 1Nodes 8 | SELECT 9 | N.1nid, 10 | N.COLUMN_NAME, 11 | N.pvid, 12 | N.main 13 | FROM 14 | @database@_setup.1Nodes N, 15 | @database@_setup.FunctorSet F 16 | WHERE 17 | N.1nid = F.fid; 18 | 19 | 20 | TRUNCATE 2Nodes; 21 | INSERT INTO 2Nodes 22 | SELECT 23 | N.2nid, 24 | N.COLUMN_NAME, 25 | N.pvid1, 26 | N.pvid2, 27 | N.TABLE_NAME, 28 | N.main 29 | FROM 30 | @database@_setup.2Nodes N, 31 | @database@_setup.FunctorSet F 32 | WHERE 33 | N.2nid = F.Fid; 34 | 35 | 36 | /* Map the 2nodes to rnodes for the given 2Nodes in the functor set. */ 37 | TRUNCATE RNodes_2Nodes; 38 | INSERT INTO RNodes_2Nodes 39 | SELECT 40 | N.rnid, 41 | N.2nid, 42 | N.main 43 | FROM 44 | @database@_setup.RNodes_2Nodes N, 45 | 2Nodes F 46 | WHERE 47 | N.2nid = F.2nid; 48 | 49 | 50 | /* Copy the rnodes for the functor set. */ 51 | TRUNCATE RNodes; 52 | INSERT INTO RNodes 53 | SELECT 54 | N.rnid, 55 | N.TABLE_NAME, 56 | N.pvid1, 57 | N.pvid2, 58 | N.COLUMN_NAME1, 59 | N.COLUMN_NAME2, 60 | N.main 61 | FROM 62 | @database@_setup.RNodes N, 63 | @database@_setup.FunctorSet F 64 | WHERE 65 | N.rnid = F.Fid 66 | 67 | /* For each 2node that's included in the FunctorSet, copy its rnode as well in case the user missed it. */ 68 | UNION DISTINCT 69 | 70 | SELECT 71 | N.rnid, 72 | N.TABLE_NAME, 73 | N.pvid1, 74 | N.pvid2, 75 | N.COLUMN_NAME1, 76 | N.COLUMN_NAME2, 77 | N.main 78 | FROM 79 | @database@_setup.RNodes N, 80 | RNodes_2Nodes F 81 | WHERE 82 | N.rnid = F.rnid; 83 | 84 | 85 | TRUNCATE RNodes_pvars; 86 | INSERT INTO RNodes_pvars 87 | SELECT 88 | N.rnid, 89 | N.pvid, 90 | N.TABLE_NAME, 91 | N.COLUMN_NAME, 92 | N.REFERENCED_COLUMN_NAME 93 | FROM 94 | @database@_setup.RNodes_pvars N, 95 | RNodes F 96 | WHERE 97 | N.rnid = F.rnid; 98 | 99 | 100 | /* Transfer pvariables. Only those that occur in the functor set. */ 101 | TRUNCATE PVariables; 102 | INSERT INTO PVariables 103 | SELECT DISTINCT 104 | P.pvid, 105 | P.ID_COLUMN_NAME, 106 | P.TABLE_NAME, 107 | P.index_number 108 | FROM 109 | @database@_setup.PVariables P, 110 | @database@_setup.FNodes_pvars FP, 111 | FNodes F 112 | WHERE 113 | P.pvid = FP.pvid 114 | AND 115 | FP.Fid = F.Fid; 116 | 117 | 118 | /** 119 | * Prepare lattice generator by copying information from LatticeRNodes in the "_setup" database, restricted to the 120 | * FunctorSet. 121 | */ 122 | TRUNCATE LatticeRNodes; 123 | INSERT INTO LatticeRNodes 124 | SELECT 125 | LR.orig_rnid, 126 | LR.short_rnid 127 | FROM 128 | @database@_setup.LatticeRNodes LR, 129 | RNodes R 130 | WHERE 131 | LR.orig_rnid = R.rnid; 132 | 133 | END// -------------------------------------------------------------------------------- /code/factorbase/src/main/resources/scripts/transfer_initialize.sql: -------------------------------------------------------------------------------- 1 | /* Create the tables necessary for cascading information based on the FunctorSet table. */ 2 | SET storage_engine=MEMORY; 3 | 4 | CREATE TABLE 1Nodes AS 5 | SELECT 6 | N.1nid, 7 | N.COLUMN_NAME, 8 | N.pvid, 9 | N.main 10 | FROM 11 | @database@_setup.1Nodes N 12 | LIMIT 13 | 0; 14 | 15 | 16 | CREATE TABLE 2Nodes AS 17 | SELECT 18 | N.2nid, 19 | N.COLUMN_NAME, 20 | N.pvid1, 21 | N.pvid2, 22 | N.TABLE_NAME, 23 | N.main 24 | FROM 25 | @database@_setup.2Nodes N 26 | LIMIT 27 | 0; 28 | 29 | 30 | CREATE TABLE RNodes_2Nodes AS 31 | SELECT 32 | N.rnid, 33 | N.2nid, 34 | N.main 35 | FROM 36 | @database@_setup.RNodes_2Nodes N 37 | LIMIT 38 | 0; 39 | 40 | 41 | CREATE TABLE RNodes AS 42 | SELECT 43 | N.rnid, 44 | N.TABLE_NAME, 45 | N.pvid1, 46 | N.pvid2, 47 | N.COLUMN_NAME1, 48 | N.COLUMN_NAME2, 49 | N.main 50 | FROM 51 | @database@_setup.RNodes N 52 | LIMIT 53 | 0; 54 | 55 | 56 | /* Make comprehensive view for all functor nodes but restricted to the functor set. */ 57 | CREATE VIEW FNodes AS 58 | SELECT 59 | 1nid AS Fid, 60 | COLUMN_NAME AS FunctorName, 61 | '1Node' AS Type, 62 | main 63 | FROM 64 | 1Nodes 65 | 66 | UNION ALL 67 | 68 | SELECT 69 | 2nid AS Fid, 70 | COLUMN_NAME AS FunctorName, 71 | '2Node' AS Type, 72 | main 73 | FROM 74 | 2Nodes 75 | 76 | UNION ALL 77 | 78 | SELECT 79 | rnid AS Fid, 80 | TABLE_NAME AS FunctorName, 81 | 'Rnode' AS Type, 82 | main 83 | FROM 84 | RNodes; 85 | 86 | 87 | CREATE TABLE RNodes_pvars AS 88 | SELECT 89 | N.rnid, 90 | N.pvid, 91 | N.TABLE_NAME, 92 | N.COLUMN_NAME, 93 | N.REFERENCED_COLUMN_NAME 94 | FROM 95 | @database@_setup.RNodes_pvars N 96 | LIMIT 97 | 0; 98 | 99 | 100 | CREATE TABLE PVariables AS 101 | SELECT 102 | N.pvid, 103 | N.ID_COLUMN_NAME, 104 | N.TABLE_NAME, 105 | N.index_number 106 | FROM 107 | @database@_setup.PVariables N 108 | LIMIT 109 | 0; 110 | 111 | 112 | CREATE TABLE LatticeRNodes AS 113 | SELECT 114 | orig_rnid, 115 | short_rnid 116 | FROM 117 | @database@_setup.LatticeRNodes 118 | LIMIT 119 | 0; 120 | 121 | 122 | ALTER TABLE LatticeRNodes 123 | ADD UNIQUE INDEX rnid_UNIQUE (short_rnid ASC); -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/initialize_databases 3.sql: -------------------------------------------------------------------------------- 1 | -- Initialize the databases required by FactorBase. 2 | /*M!100316 SET collation_server = 'utf8_general_ci';*/ 3 | SET collation_server = 'utf8_general_ci'; 4 | 5 | DROP SCHEMA IF EXISTS @database@_setup; 6 | CREATE SCHEMA @database@_setup; 7 | 8 | DROP SCHEMA IF EXISTS @database@_BN; 9 | CREATE SCHEMA @database@_BN; 10 | 11 | DROP SCHEMA IF EXISTS @database@_CT; 12 | CREATE SCHEMA @database@_CT; 13 | 14 | DROP SCHEMA IF EXISTS @database@_global_counts; 15 | CREATE SCHEMA @database@_global_counts; 16 | 17 | DROP SCHEMA IF EXISTS @database@_CT_cache; 18 | CREATE SCHEMA @database@_CT_cache; -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/initialize_databases.sql: -------------------------------------------------------------------------------- 1 | -- Initialize the databases required by FactorBase. 2 | /*M!100316 SET collation_server = 'utf8_general_ci';*/ 3 | SET collation_server = 'utf8_general_ci'; 4 | 5 | DROP SCHEMA IF EXISTS @database@_setup; 6 | CREATE SCHEMA @database@_setup; 7 | 8 | DROP SCHEMA IF EXISTS @database@_BN; 9 | CREATE SCHEMA @database@_BN; 10 | 11 | DROP SCHEMA IF EXISTS @database@_CT; 12 | CREATE SCHEMA @database@_CT; 13 | 14 | DROP SCHEMA IF EXISTS @database@_global_counts; 15 | CREATE SCHEMA @database@_global_counts; 16 | 17 | DROP SCHEMA IF EXISTS @database@_CT_cache; 18 | CREATE SCHEMA @database@_CT_cache; -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/latticegenerator_initialize.sql: -------------------------------------------------------------------------------- 1 | /* Create the tables necessary for generating the lattice. */ 2 | SET storage_engine=INNODB; 3 | 4 | CREATE TABLE lattice_membership ( 5 | name VARCHAR(300), 6 | member VARCHAR(300), 7 | PRIMARY KEY(name, member) 8 | ); 9 | 10 | 11 | CREATE TABLE lattice_rel ( 12 | parent VARCHAR(300), 13 | child VARCHAR(300), 14 | removed VARCHAR(300), 15 | PRIMARY KEY(parent, child) 16 | ); 17 | 18 | 19 | CREATE TABLE lattice_set ( 20 | name VARCHAR(300), 21 | length INT(11), 22 | PRIMARY KEY(name, length) 23 | ); 24 | 25 | 26 | CREATE TABLE lattice_mapping ( 27 | orig_rnid VARCHAR(300), 28 | short_rnid VARCHAR(20), 29 | PRIMARY KEY(orig_rnid, short_rnid) 30 | ); -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/latticegenerator_initialize_local 3.sql: -------------------------------------------------------------------------------- 1 | /* Create the tables necessary for generating the lattice. */ 2 | SET storage_engine=MEMORY; 3 | 4 | CREATE TABLE lattice_membership ( 5 | name VARCHAR(300), 6 | member VARCHAR(300), 7 | PRIMARY KEY(name, member) 8 | ); 9 | 10 | 11 | CREATE TABLE lattice_rel ( 12 | parent VARCHAR(300), 13 | child VARCHAR(300), 14 | removed VARCHAR(300), 15 | PRIMARY KEY(parent, child) 16 | ); 17 | 18 | 19 | CREATE TABLE lattice_set ( 20 | name VARCHAR(300), 21 | length INT(11), 22 | PRIMARY KEY(name, length) 23 | ); 24 | 25 | 26 | CREATE VIEW lattice_mapping AS 27 | SELECT 28 | orig_rnid, 29 | short_rnid 30 | FROM 31 | @database@_setup.lattice_mapping; -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/latticegenerator_initialize_local.sql: -------------------------------------------------------------------------------- 1 | /* Create the tables necessary for generating the lattice. */ 2 | SET storage_engine=MEMORY; 3 | 4 | CREATE TABLE lattice_membership ( 5 | name VARCHAR(300), 6 | member VARCHAR(300), 7 | PRIMARY KEY(name, member) 8 | ); 9 | 10 | 11 | CREATE TABLE lattice_rel ( 12 | parent VARCHAR(300), 13 | child VARCHAR(300), 14 | removed VARCHAR(300), 15 | PRIMARY KEY(parent, child) 16 | ); 17 | 18 | 19 | CREATE TABLE lattice_set ( 20 | name VARCHAR(300), 21 | length INT(11), 22 | PRIMARY KEY(name, length) 23 | ); 24 | 25 | 26 | CREATE VIEW lattice_mapping AS 27 | SELECT 28 | orig_rnid, 29 | short_rnid 30 | FROM 31 | @database@_setup.lattice_mapping; -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/latticegenerator_populate 2.sql: -------------------------------------------------------------------------------- 1 | /** 2 | * Populate the local relationship lattice tables by extracting information from the global relationship lattice 3 | * tables. 4 | */ 5 | CREATE PROCEDURE populateLattice() 6 | BEGIN 7 | 8 | TRUNCATE lattice_membership; 9 | INSERT INTO lattice_membership 10 | -- Get the "name"s and "member"s where the "name"s are unique to the local lattice. 11 | SELECT 12 | name, 13 | member 14 | FROM 15 | @database@_setup.lattice_membership LMEM, 16 | LatticeRNodes LR 17 | WHERE 18 | LMEM.member = LR.orig_rnid 19 | AND 20 | name 21 | NOT IN ( 22 | -- Get the "name"s that belong to RNodes that are not in the local lattice. 23 | SELECT 24 | name 25 | FROM 26 | @database@_setup.lattice_membership 27 | WHERE 28 | member 29 | NOT IN ( 30 | -- Get the RNodes for the local lattice. 31 | SELECT 32 | orig_rnid 33 | FROM 34 | LatticeRNodes 35 | ) 36 | ); 37 | 38 | 39 | TRUNCATE lattice_rel; 40 | INSERT INTO lattice_rel 41 | SELECT 42 | parent, 43 | child, 44 | removed 45 | FROM 46 | @database@_setup.lattice_rel LREL, 47 | LatticeRNodes LR 48 | WHERE 49 | LREL.removed = LR.orig_rnid; 50 | 51 | 52 | TRUNCATE lattice_set; 53 | INSERT INTO lattice_set 54 | SELECT 55 | LS.name, 56 | length 57 | FROM 58 | @database@_setup.lattice_set LS, 59 | lattice_membership LMEM, 60 | LatticeRNodes LR 61 | WHERE 62 | LMEM.member = LR.orig_rnid 63 | AND 64 | LS.name = LMEM.name 65 | GROUP BY 66 | LS.name; 67 | END// -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/latticegenerator_populate.sql: -------------------------------------------------------------------------------- 1 | /** 2 | * Populate the local relationship lattice tables by extracting information from the global relationship lattice 3 | * tables. 4 | */ 5 | CREATE PROCEDURE populateLattice() 6 | BEGIN 7 | 8 | TRUNCATE lattice_membership; 9 | INSERT INTO lattice_membership 10 | -- Get the "name"s and "member"s where the "name"s are unique to the local lattice. 11 | SELECT 12 | name, 13 | member 14 | FROM 15 | @database@_setup.lattice_membership LMEM, 16 | LatticeRNodes LR 17 | WHERE 18 | LMEM.member = LR.orig_rnid 19 | AND 20 | name 21 | NOT IN ( 22 | -- Get the "name"s that belong to RNodes that are not in the local lattice. 23 | SELECT 24 | name 25 | FROM 26 | @database@_setup.lattice_membership 27 | WHERE 28 | member 29 | NOT IN ( 30 | -- Get the RNodes for the local lattice. 31 | SELECT 32 | orig_rnid 33 | FROM 34 | LatticeRNodes 35 | ) 36 | ); 37 | 38 | 39 | TRUNCATE lattice_rel; 40 | INSERT INTO lattice_rel 41 | SELECT 42 | parent, 43 | child, 44 | removed 45 | FROM 46 | @database@_setup.lattice_rel LREL, 47 | LatticeRNodes LR 48 | WHERE 49 | LREL.removed = LR.orig_rnid; 50 | 51 | 52 | TRUNCATE lattice_set; 53 | INSERT INTO lattice_set 54 | SELECT 55 | LS.name, 56 | length 57 | FROM 58 | @database@_setup.lattice_set LS, 59 | lattice_membership LMEM, 60 | LatticeRNodes LR 61 | WHERE 62 | LMEM.member = LR.orig_rnid 63 | AND 64 | LS.name = LMEM.name 65 | GROUP BY 66 | LS.name; 67 | END// -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/logging 3.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE CallLogs ( 2 | CallNumber INT, 3 | cascadeFS INT, -- MetaData 4 | lattice INT, -- MetaData 5 | populateMQ INT, -- MetaData 6 | populateMQRChain INT, -- MetaData 7 | buildPVarsCounts INT, -- Counts 8 | buildRNodeCounts INT, -- Add to Counts, Subtract from Mobius Join 9 | buildRChainCounts INT, -- Counts 10 | createJoinTableQueries INT, -- Mobius Join 11 | buildFlatStarCT INT -- Mobius Join 12 | ) ENGINE = MEMORY; -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/logging.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE CallLogs ( 2 | CallNumber INT, 3 | cascadeFS INT, -- MetaData 4 | lattice INT, -- MetaData 5 | populateMQ INT, -- MetaData 6 | populateMQRChain INT, -- MetaData 7 | buildPVarsCounts INT, -- Counts 8 | buildRNodeCounts INT, -- Add to Counts, Subtract from Mobius Join 9 | buildRChainCounts INT, -- Counts 10 | createJoinTableQueries INT, -- Mobius Join 11 | buildFlatStarCT INT -- Mobius Join 12 | ) ENGINE = MEMORY; -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/metadata_storedprocedures 3.sql: -------------------------------------------------------------------------------- 1 | CREATE PROCEDURE `find_values`() 2 | BEGIN 3 | DECLARE done INT DEFAULT 0; 4 | DECLARE tablename VARCHAR(30); 5 | DECLARE columnname VARCHAR(30); 6 | DECLARE cur1 CURSOR FOR 7 | SELECT TABLE_NAME, COLUMN_NAME FROM AttributeColumns; 8 | DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; 9 | OPEN cur1; 10 | 11 | DROP TABLE IF EXISTS Attribute_Value; 12 | CREATE TABLE 13 | Attribute_Value ( 14 | COLUMN_NAME VARCHAR(269), 15 | VALUE VARCHAR(30)); 16 | 17 | LOOP1: LOOP 18 | FETCH cur1 INTO tablename, columnname; 19 | IF done = 1 THEN 20 | LEAVE LOOP1; 21 | END IF; 22 | SET @SQLQUERY = 'INSERT INTO Attribute_Value ('; 23 | SET @SQLQUERY = CONCAT(@SQLQUERY, 'SELECT distinct "', columnname); 24 | SET @SQLQUERY = CONCAT(@SQLQUERY, '", ', columnname); 25 | SET @SQLQUERY = CONCAT(@SQLQUERY, ' FROM @database@.', tablename, ')'); 26 | 27 | PREPARE stmt1 FROM @SQLQUERY; 28 | EXECUTE stmt1; 29 | END LOOP LOOP1; 30 | 31 | CLOSE cur1; 32 | 33 | END// -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/metadata_storedprocedures.sql: -------------------------------------------------------------------------------- 1 | CREATE PROCEDURE `find_values`() 2 | BEGIN 3 | DECLARE done INT DEFAULT 0; 4 | DECLARE tablename VARCHAR(30); 5 | DECLARE columnname VARCHAR(30); 6 | DECLARE cur1 CURSOR FOR 7 | SELECT TABLE_NAME, COLUMN_NAME FROM AttributeColumns; 8 | DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; 9 | OPEN cur1; 10 | 11 | DROP TABLE IF EXISTS Attribute_Value; 12 | CREATE TABLE 13 | Attribute_Value ( 14 | COLUMN_NAME VARCHAR(269), 15 | VALUE VARCHAR(30)); 16 | 17 | LOOP1: LOOP 18 | FETCH cur1 INTO tablename, columnname; 19 | IF done = 1 THEN 20 | LEAVE LOOP1; 21 | END IF; 22 | SET @SQLQUERY = 'INSERT INTO Attribute_Value ('; 23 | SET @SQLQUERY = CONCAT(@SQLQUERY, 'SELECT distinct "', columnname); 24 | SET @SQLQUERY = CONCAT(@SQLQUERY, '", ', columnname); 25 | SET @SQLQUERY = CONCAT(@SQLQUERY, ' FROM @database@.', tablename, ')'); 26 | 27 | PREPARE stmt1 FROM @SQLQUERY; 28 | EXECUTE stmt1; 29 | END LOOP LOOP1; 30 | 31 | CLOSE cur1; 32 | 33 | END// -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/metaqueries_initialize 3.sql: -------------------------------------------------------------------------------- 1 | /* Create the table and view necessary for storing metaquery information. */ 2 | 3 | /*SET storage_engine=MEMORY;*/ 4 | 5 | CREATE TABLE MetaQueries ( 6 | Lattice_Point varchar(398), /* e.g. pvid, rchain, prof0, a */ 7 | TableType varchar(100), /* e.g. star, flat, counts */ 8 | ClauseType varchar(10), /* FROM, WHERE, SELECT, GROUPBY */ 9 | EntryType varchar(100), /* e.g. 1node, aggregate like count */ 10 | Entries varchar(150) 11 | ); 12 | 13 | 14 | CREATE VIEW RChain_pvars AS 15 | SELECT DISTINCT 16 | M.name AS rchain, 17 | pvid 18 | FROM 19 | lattice_membership M, 20 | RNodes_pvars R 21 | WHERE 22 | R.rnid = M.member; -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/metaqueries_initialize.sql: -------------------------------------------------------------------------------- 1 | /* Create the table and view necessary for storing metaquery information. */ 2 | 3 | /*SET storage_engine=MEMORY;*/ 4 | 5 | CREATE TABLE MetaQueries ( 6 | Lattice_Point varchar(398), /* e.g. pvid, rchain, prof0, a */ 7 | TableType varchar(100), /* e.g. star, flat, counts */ 8 | ClauseType varchar(10), /* FROM, WHERE, SELECT, GROUPBY */ 9 | EntryType varchar(100), /* e.g. 1node, aggregate like count */ 10 | Entries varchar(150) 11 | ); 12 | 13 | 14 | CREATE VIEW RChain_pvars AS 15 | SELECT DISTINCT 16 | M.name AS rchain, 17 | pvid 18 | FROM 19 | lattice_membership M, 20 | RNodes_pvars R 21 | WHERE 22 | R.rnid = M.member; -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/transfer_cascade 2.sql: -------------------------------------------------------------------------------- 1 | /* Cascade the information (based on the FunctorSet table) into the tables created by the transfer_initialize.sql script. */ 2 | 3 | CREATE PROCEDURE cascadeFS() 4 | BEGIN 5 | 6 | TRUNCATE 1Nodes; 7 | INSERT INTO 1Nodes 8 | SELECT 9 | N.1nid, 10 | N.COLUMN_NAME, 11 | N.pvid, 12 | N.main 13 | FROM 14 | @database@_setup.1Nodes N, 15 | @database@_setup.FunctorSet F 16 | WHERE 17 | N.1nid = F.fid; 18 | 19 | 20 | TRUNCATE 2Nodes; 21 | INSERT INTO 2Nodes 22 | SELECT 23 | N.2nid, 24 | N.COLUMN_NAME, 25 | N.pvid1, 26 | N.pvid2, 27 | N.TABLE_NAME, 28 | N.main 29 | FROM 30 | @database@_setup.2Nodes N, 31 | @database@_setup.FunctorSet F 32 | WHERE 33 | N.2nid = F.Fid; 34 | 35 | 36 | /* Map the 2nodes to rnodes for the given 2Nodes in the functor set. */ 37 | TRUNCATE RNodes_2Nodes; 38 | INSERT INTO RNodes_2Nodes 39 | SELECT 40 | N.rnid, 41 | N.2nid, 42 | N.main 43 | FROM 44 | @database@_setup.RNodes_2Nodes N, 45 | 2Nodes F 46 | WHERE 47 | N.2nid = F.2nid; 48 | 49 | 50 | /* Copy the rnodes for the functor set. */ 51 | TRUNCATE RNodes; 52 | INSERT INTO RNodes 53 | SELECT 54 | N.rnid, 55 | N.TABLE_NAME, 56 | N.pvid1, 57 | N.pvid2, 58 | N.COLUMN_NAME1, 59 | N.COLUMN_NAME2, 60 | N.main 61 | FROM 62 | @database@_setup.RNodes N, 63 | @database@_setup.FunctorSet F 64 | WHERE 65 | N.rnid = F.Fid 66 | 67 | /* For each 2node that's included in the FunctorSet, copy its rnode as well in case the user missed it. */ 68 | UNION DISTINCT 69 | 70 | SELECT 71 | N.rnid, 72 | N.TABLE_NAME, 73 | N.pvid1, 74 | N.pvid2, 75 | N.COLUMN_NAME1, 76 | N.COLUMN_NAME2, 77 | N.main 78 | FROM 79 | @database@_setup.RNodes N, 80 | RNodes_2Nodes F 81 | WHERE 82 | N.rnid = F.rnid; 83 | 84 | 85 | TRUNCATE RNodes_pvars; 86 | INSERT INTO RNodes_pvars 87 | SELECT 88 | N.rnid, 89 | N.pvid, 90 | N.TABLE_NAME, 91 | N.COLUMN_NAME, 92 | N.REFERENCED_COLUMN_NAME 93 | FROM 94 | @database@_setup.RNodes_pvars N, 95 | RNodes F 96 | WHERE 97 | N.rnid = F.rnid; 98 | 99 | 100 | /* Transfer pvariables. Only those that occur in the functor set. */ 101 | TRUNCATE PVariables; 102 | INSERT INTO PVariables 103 | SELECT DISTINCT 104 | P.pvid, 105 | P.ID_COLUMN_NAME, 106 | P.TABLE_NAME, 107 | P.index_number 108 | FROM 109 | @database@_setup.PVariables P, 110 | @database@_setup.FNodes_pvars FP, 111 | FNodes F 112 | WHERE 113 | P.pvid = FP.pvid 114 | AND 115 | FP.Fid = F.Fid; 116 | 117 | 118 | /** 119 | * Prepare lattice generator by copying information from LatticeRNodes in the "_setup" database, restricted to the 120 | * FunctorSet. 121 | */ 122 | TRUNCATE LatticeRNodes; 123 | INSERT INTO LatticeRNodes 124 | SELECT 125 | LR.orig_rnid, 126 | LR.short_rnid 127 | FROM 128 | @database@_setup.LatticeRNodes LR, 129 | RNodes R 130 | WHERE 131 | LR.orig_rnid = R.rnid; 132 | 133 | END// -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/transfer_cascade.sql: -------------------------------------------------------------------------------- 1 | /* Cascade the information (based on the FunctorSet table) into the tables created by the transfer_initialize.sql script. */ 2 | 3 | CREATE PROCEDURE cascadeFS() 4 | BEGIN 5 | 6 | TRUNCATE 1Nodes; 7 | INSERT INTO 1Nodes 8 | SELECT 9 | N.1nid, 10 | N.COLUMN_NAME, 11 | N.pvid, 12 | N.main 13 | FROM 14 | @database@_setup.1Nodes N, 15 | @database@_setup.FunctorSet F 16 | WHERE 17 | N.1nid = F.fid; 18 | 19 | 20 | TRUNCATE 2Nodes; 21 | INSERT INTO 2Nodes 22 | SELECT 23 | N.2nid, 24 | N.COLUMN_NAME, 25 | N.pvid1, 26 | N.pvid2, 27 | N.TABLE_NAME, 28 | N.main 29 | FROM 30 | @database@_setup.2Nodes N, 31 | @database@_setup.FunctorSet F 32 | WHERE 33 | N.2nid = F.Fid; 34 | 35 | 36 | /* Map the 2nodes to rnodes for the given 2Nodes in the functor set. */ 37 | TRUNCATE RNodes_2Nodes; 38 | INSERT INTO RNodes_2Nodes 39 | SELECT 40 | N.rnid, 41 | N.2nid, 42 | N.main 43 | FROM 44 | @database@_setup.RNodes_2Nodes N, 45 | 2Nodes F 46 | WHERE 47 | N.2nid = F.2nid; 48 | 49 | 50 | /* Copy the rnodes for the functor set. */ 51 | TRUNCATE RNodes; 52 | INSERT INTO RNodes 53 | SELECT 54 | N.rnid, 55 | N.TABLE_NAME, 56 | N.pvid1, 57 | N.pvid2, 58 | N.COLUMN_NAME1, 59 | N.COLUMN_NAME2, 60 | N.main 61 | FROM 62 | @database@_setup.RNodes N, 63 | @database@_setup.FunctorSet F 64 | WHERE 65 | N.rnid = F.Fid 66 | 67 | /* For each 2node that's included in the FunctorSet, copy its rnode as well in case the user missed it. */ 68 | UNION DISTINCT 69 | 70 | SELECT 71 | N.rnid, 72 | N.TABLE_NAME, 73 | N.pvid1, 74 | N.pvid2, 75 | N.COLUMN_NAME1, 76 | N.COLUMN_NAME2, 77 | N.main 78 | FROM 79 | @database@_setup.RNodes N, 80 | RNodes_2Nodes F 81 | WHERE 82 | N.rnid = F.rnid; 83 | 84 | 85 | TRUNCATE RNodes_pvars; 86 | INSERT INTO RNodes_pvars 87 | SELECT 88 | N.rnid, 89 | N.pvid, 90 | N.TABLE_NAME, 91 | N.COLUMN_NAME, 92 | N.REFERENCED_COLUMN_NAME 93 | FROM 94 | @database@_setup.RNodes_pvars N, 95 | RNodes F 96 | WHERE 97 | N.rnid = F.rnid; 98 | 99 | 100 | /* Transfer pvariables. Only those that occur in the functor set. */ 101 | TRUNCATE PVariables; 102 | INSERT INTO PVariables 103 | SELECT DISTINCT 104 | P.pvid, 105 | P.ID_COLUMN_NAME, 106 | P.TABLE_NAME, 107 | P.index_number 108 | FROM 109 | @database@_setup.PVariables P, 110 | @database@_setup.FNodes_pvars FP, 111 | FNodes F 112 | WHERE 113 | P.pvid = FP.pvid 114 | AND 115 | FP.Fid = F.Fid; 116 | 117 | 118 | /** 119 | * Prepare lattice generator by copying information from LatticeRNodes in the "_setup" database, restricted to the 120 | * FunctorSet. 121 | */ 122 | TRUNCATE LatticeRNodes; 123 | INSERT INTO LatticeRNodes 124 | SELECT 125 | LR.orig_rnid, 126 | LR.short_rnid 127 | FROM 128 | @database@_setup.LatticeRNodes LR, 129 | RNodes R 130 | WHERE 131 | LR.orig_rnid = R.rnid; 132 | 133 | END// -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/transfer_initialize 2.sql: -------------------------------------------------------------------------------- 1 | /* Create the tables necessary for cascading information based on the FunctorSet table. */ 2 | SET storage_engine=MEMORY; 3 | 4 | CREATE TABLE 1Nodes AS 5 | SELECT 6 | N.1nid, 7 | N.COLUMN_NAME, 8 | N.pvid, 9 | N.main 10 | FROM 11 | @database@_setup.1Nodes N 12 | LIMIT 13 | 0; 14 | 15 | 16 | CREATE TABLE 2Nodes AS 17 | SELECT 18 | N.2nid, 19 | N.COLUMN_NAME, 20 | N.pvid1, 21 | N.pvid2, 22 | N.TABLE_NAME, 23 | N.main 24 | FROM 25 | @database@_setup.2Nodes N 26 | LIMIT 27 | 0; 28 | 29 | 30 | CREATE TABLE RNodes_2Nodes AS 31 | SELECT 32 | N.rnid, 33 | N.2nid, 34 | N.main 35 | FROM 36 | @database@_setup.RNodes_2Nodes N 37 | LIMIT 38 | 0; 39 | 40 | 41 | CREATE TABLE RNodes AS 42 | SELECT 43 | N.rnid, 44 | N.TABLE_NAME, 45 | N.pvid1, 46 | N.pvid2, 47 | N.COLUMN_NAME1, 48 | N.COLUMN_NAME2, 49 | N.main 50 | FROM 51 | @database@_setup.RNodes N 52 | LIMIT 53 | 0; 54 | 55 | 56 | /* Make comprehensive view for all functor nodes but restricted to the functor set. */ 57 | CREATE VIEW FNodes AS 58 | SELECT 59 | 1nid AS Fid, 60 | COLUMN_NAME AS FunctorName, 61 | '1Node' AS Type, 62 | main 63 | FROM 64 | 1Nodes 65 | 66 | UNION ALL 67 | 68 | SELECT 69 | 2nid AS Fid, 70 | COLUMN_NAME AS FunctorName, 71 | '2Node' AS Type, 72 | main 73 | FROM 74 | 2Nodes 75 | 76 | UNION ALL 77 | 78 | SELECT 79 | rnid AS Fid, 80 | TABLE_NAME AS FunctorName, 81 | 'Rnode' AS Type, 82 | main 83 | FROM 84 | RNodes; 85 | 86 | 87 | CREATE TABLE RNodes_pvars AS 88 | SELECT 89 | N.rnid, 90 | N.pvid, 91 | N.TABLE_NAME, 92 | N.COLUMN_NAME, 93 | N.REFERENCED_COLUMN_NAME 94 | FROM 95 | @database@_setup.RNodes_pvars N 96 | LIMIT 97 | 0; 98 | 99 | 100 | CREATE TABLE PVariables AS 101 | SELECT 102 | N.pvid, 103 | N.ID_COLUMN_NAME, 104 | N.TABLE_NAME, 105 | N.index_number 106 | FROM 107 | @database@_setup.PVariables N 108 | LIMIT 109 | 0; 110 | 111 | 112 | CREATE TABLE LatticeRNodes AS 113 | SELECT 114 | orig_rnid, 115 | short_rnid 116 | FROM 117 | @database@_setup.LatticeRNodes 118 | LIMIT 119 | 0; 120 | 121 | 122 | ALTER TABLE LatticeRNodes 123 | ADD UNIQUE INDEX rnid_UNIQUE (short_rnid ASC); -------------------------------------------------------------------------------- /code/factorbase/target/classes/scripts/transfer_initialize.sql: -------------------------------------------------------------------------------- 1 | /* Create the tables necessary for cascading information based on the FunctorSet table. */ 2 | SET storage_engine=MEMORY; 3 | 4 | CREATE TABLE 1Nodes AS 5 | SELECT 6 | N.1nid, 7 | N.COLUMN_NAME, 8 | N.pvid, 9 | N.main 10 | FROM 11 | @database@_setup.1Nodes N 12 | LIMIT 13 | 0; 14 | 15 | 16 | CREATE TABLE 2Nodes AS 17 | SELECT 18 | N.2nid, 19 | N.COLUMN_NAME, 20 | N.pvid1, 21 | N.pvid2, 22 | N.TABLE_NAME, 23 | N.main 24 | FROM 25 | @database@_setup.2Nodes N 26 | LIMIT 27 | 0; 28 | 29 | 30 | CREATE TABLE RNodes_2Nodes AS 31 | SELECT 32 | N.rnid, 33 | N.2nid, 34 | N.main 35 | FROM 36 | @database@_setup.RNodes_2Nodes N 37 | LIMIT 38 | 0; 39 | 40 | 41 | CREATE TABLE RNodes AS 42 | SELECT 43 | N.rnid, 44 | N.TABLE_NAME, 45 | N.pvid1, 46 | N.pvid2, 47 | N.COLUMN_NAME1, 48 | N.COLUMN_NAME2, 49 | N.main 50 | FROM 51 | @database@_setup.RNodes N 52 | LIMIT 53 | 0; 54 | 55 | 56 | /* Make comprehensive view for all functor nodes but restricted to the functor set. */ 57 | CREATE VIEW FNodes AS 58 | SELECT 59 | 1nid AS Fid, 60 | COLUMN_NAME AS FunctorName, 61 | '1Node' AS Type, 62 | main 63 | FROM 64 | 1Nodes 65 | 66 | UNION ALL 67 | 68 | SELECT 69 | 2nid AS Fid, 70 | COLUMN_NAME AS FunctorName, 71 | '2Node' AS Type, 72 | main 73 | FROM 74 | 2Nodes 75 | 76 | UNION ALL 77 | 78 | SELECT 79 | rnid AS Fid, 80 | TABLE_NAME AS FunctorName, 81 | 'Rnode' AS Type, 82 | main 83 | FROM 84 | RNodes; 85 | 86 | 87 | CREATE TABLE RNodes_pvars AS 88 | SELECT 89 | N.rnid, 90 | N.pvid, 91 | N.TABLE_NAME, 92 | N.COLUMN_NAME, 93 | N.REFERENCED_COLUMN_NAME 94 | FROM 95 | @database@_setup.RNodes_pvars N 96 | LIMIT 97 | 0; 98 | 99 | 100 | CREATE TABLE PVariables AS 101 | SELECT 102 | N.pvid, 103 | N.ID_COLUMN_NAME, 104 | N.TABLE_NAME, 105 | N.index_number 106 | FROM 107 | @database@_setup.PVariables N 108 | LIMIT 109 | 0; 110 | 111 | 112 | CREATE TABLE LatticeRNodes AS 113 | SELECT 114 | orig_rnid, 115 | short_rnid 116 | FROM 117 | @database@_setup.LatticeRNodes 118 | LIMIT 119 | 0; 120 | 121 | 122 | ALTER TABLE LatticeRNodes 123 | ADD UNIQUE INDEX rnid_UNIQUE (short_rnid ASC); -------------------------------------------------------------------------------- /code/factorbase/target/factorbase-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/factorbase/target/factorbase-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /code/factorbase/target/maven-archiver/pom.properties: -------------------------------------------------------------------------------- 1 | artifactId=factorbase 2 | groupId=ca.sfu.cs 3 | version=1.0-SNAPSHOT 4 | -------------------------------------------------------------------------------- /code/factorbase/target/original-factorbase-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/factorbase/target/original-factorbase-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /code/mlnexporter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | ca.sfu.cs 6 | mlnexporter 7 | 1.0-SNAPSHOT 8 | mlnexporter 9 | https://github.com/sfu-cl-lab/FactorBase/mlnexporter 10 | 11 | 12 | UTF-8 13 | 1.8 14 | 1.8 15 | 16 | 17 | 18 | 19 | 20 | org.apache.maven.plugins 21 | maven-shade-plugin 22 | 3.1.1 23 | 24 | 25 | package 26 | 27 | shade 28 | 29 | 30 | false 31 | 32 | 33 | ca.sfu.cs.mlnexporter.app.Exporter 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | ca.sfu.cs 46 | common 47 | 1.0-SNAPSHOT 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /code/mlnexporter/src/main/java/ca/sfu/cs/mlnexporter/graph/BNNode.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.mlnexporter.graph; 2 | /* 3 | * Description: This class is BNNode. 4 | * It allows the users to store the node information of Bayesian network 5 | * 6 | * Function: getName - get the value of node name 7 | * getID - return the value of node ID (shows in the database) 8 | * getMLNStr - get the value of MLNStr 9 | * BNNode - create a new node 10 | * isR - give True if it is relationship, otherwise, give False 11 | * 12 | * Bugs: None 13 | * 14 | * Version: 1.0 15 | * 16 | */ 17 | 18 | public class BNNode { 19 | private String name; 20 | private String ID; 21 | private String MLNStr; 22 | private boolean isR; 23 | /* 24 | * create a new BNNode 25 | * @param name the name of the node 26 | * @param ID the ID of the node 27 | * @param MLNStr the MLNStr of this node 28 | * @param isR a boolean value 29 | */ 30 | public BNNode(String name, String ID, String MLNStr, boolean isR){ 31 | this.name = name; 32 | this.ID = ID; 33 | this.MLNStr = MLNStr; 34 | this.isR = isR; 35 | } 36 | /* 37 | * get the value of node name 38 | */ 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | /* 44 | * get the value of node ID (shows in the database) 45 | */ 46 | public String getID() { 47 | return ID; 48 | } 49 | /* 50 | * get the value of MLNStr 51 | */ 52 | public String getMLNStr() { 53 | return MLNStr; 54 | } 55 | 56 | /* 57 | * give True if it is a relationship, otherwise, give False 58 | */ 59 | public boolean isR() { 60 | return isR; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /code/mlnexporter/src/main/java/ca/sfu/cs/mlnexporter/util/MergeSort.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.mlnexporter.util; 2 | /* 3 | * Description: This class is MergeSort. 4 | * It allows the users sort the array of string in alphabetical order 5 | * 6 | * Function: Merge - merge the sub-array with the order from small to large 7 | * mSort - divided string array with recursive function and then merge them together 8 | * 9 | * Bugs: None 10 | * 11 | * Version: 1.0 12 | * 13 | */ 14 | public class MergeSort { 15 | /* 16 | * divided string array with recursive function and then merge them back 17 | * @param array of strings the non-sorted string array 18 | * @param low the lower position index (start point) in the array 19 | * @param high the higher position index (start point) in the array 20 | */ 21 | public static void mSort(String[] array, int low, int high){ 22 | if(low < high){ 23 | int mid = (low + high) / 2; 24 | mSort(array, low, mid); 25 | mSort(array, mid + 1, high); 26 | merge(array, low, mid, mid + 1, high); 27 | } 28 | else 29 | return; 30 | } 31 | 32 | /* 33 | * merge the sub-array with the order from small to large 34 | * @param array of strings the string array which need to be merged 35 | * @param first1 the starting position of the first array which need to be merged 36 | * @param last1 the ending position of the first array which need to be merged 37 | * @param first2 the starting position of the second array which need to be merged 38 | * @param last2 the ending position of the second array which need to be merged 39 | */ 40 | public static void merge(String[] array, int first1, int last1, int first2, int last2){ 41 | String[] temp = new String[last2 - first1 + 1]; 42 | int low = first1; 43 | int high = last2; 44 | int index = 0; 45 | for(; (first1 <= last1) && (first2 <= last2) ; index++){ 46 | if(array[first1].toLowerCase().compareTo(array[first2].toLowerCase()) < 0){ 47 | temp[index] = array[first1]; 48 | first1 ++; 49 | } 50 | else{ 51 | temp[index] = array[first2]; 52 | first2 ++; 53 | } 54 | } 55 | 56 | for(;first1 <= last1; ++first1, ++index){ 57 | temp[index] = array[first1]; 58 | } 59 | for(;first2 <= last2; ++first2, ++index){ 60 | temp[index] = array[first2]; 61 | } 62 | 63 | index = 0; 64 | for(int i = low; i <= high; i++, index++){ 65 | array[i] = temp[index]; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /code/mlnexporter/target/maven-archiver/pom 2.properties: -------------------------------------------------------------------------------- 1 | artifactId=mlnexporter 2 | groupId=ca.sfu.cs 3 | version=1.0-SNAPSHOT 4 | -------------------------------------------------------------------------------- /code/mlnexporter/target/maven-archiver/pom.properties: -------------------------------------------------------------------------------- 1 | artifactId=mlnexporter 2 | groupId=ca.sfu.cs 3 | version=1.0-SNAPSHOT 4 | -------------------------------------------------------------------------------- /code/mlnexporter/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles 2.lst: -------------------------------------------------------------------------------- 1 | ca/sfu/cs/mlnexporter/app/Exporter.class 2 | ca/sfu/cs/mlnexporter/util/MergeSort.class 3 | ca/sfu/cs/mlnexporter/graph/BNNode.class 4 | -------------------------------------------------------------------------------- /code/mlnexporter/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst: -------------------------------------------------------------------------------- 1 | ca/sfu/cs/mlnexporter/app/Exporter.class 2 | ca/sfu/cs/mlnexporter/util/MergeSort.class 3 | ca/sfu/cs/mlnexporter/graph/BNNode.class 4 | -------------------------------------------------------------------------------- /code/mlnexporter/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles 2.lst: -------------------------------------------------------------------------------- 1 | /Users/parmis/Desktop/FactorBase/code/mlnexporter/src/main/java/ca/sfu/cs/mlnexporter/graph/BNNode.java 2 | /Users/parmis/Desktop/FactorBase/code/mlnexporter/src/main/java/ca/sfu/cs/mlnexporter/util/MergeSort.java 3 | /Users/parmis/Desktop/FactorBase/code/mlnexporter/src/main/java/ca/sfu/cs/mlnexporter/app/Exporter.java 4 | -------------------------------------------------------------------------------- /code/mlnexporter/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst: -------------------------------------------------------------------------------- 1 | /Users/parmis/Desktop/FactorBase/code/mlnexporter/src/main/java/ca/sfu/cs/mlnexporter/graph/BNNode.java 2 | /Users/parmis/Desktop/FactorBase/code/mlnexporter/src/main/java/ca/sfu/cs/mlnexporter/util/MergeSort.java 3 | /Users/parmis/Desktop/FactorBase/code/mlnexporter/src/main/java/ca/sfu/cs/mlnexporter/app/Exporter.java 4 | -------------------------------------------------------------------------------- /code/mlnexporter/target/mlnexporter-1.0-SNAPSHOT 2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/mlnexporter/target/mlnexporter-1.0-SNAPSHOT 2.jar -------------------------------------------------------------------------------- /code/mlnexporter/target/mlnexporter-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/mlnexporter/target/mlnexporter-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /code/mlnexporter/target/original-mlnexporter-1.0-SNAPSHOT 2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/mlnexporter/target/original-mlnexporter-1.0-SNAPSHOT 2.jar -------------------------------------------------------------------------------- /code/mlnexporter/target/original-mlnexporter-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/mlnexporter/target/original-mlnexporter-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /code/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ca.sfu.cs 5 | factorbase-aggregator 6 | pom 7 | 1.0-SNAPSHOT 8 | factorbase-aggregator 9 | https://github.com/sfu-cl-lab/FactorBase 10 | 11 | thirdparty 12 | common 13 | componentsrunner 14 | factorbase 15 | mlnexporter 16 | 17 | 18 | -------------------------------------------------------------------------------- /code/thirdparty/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | ca.sfu.cs 6 | thirdparty 7 | pom 8 | 1.0-SNAPSHOT 9 | thirdparty 10 | https://github.com/sfu-cl-lab/FactorBase/code/thirdparty 11 | 12 | 13 | UTF-8 14 | 1.8 15 | 1.8 16 | 17 | 18 | 19 | 20 | 21 | org.apache.maven.plugins 22 | maven-install-plugin 23 | 2.4 24 | 25 | 26 | tetrad-pom 27 | install 28 | 29 | install-file 30 | 31 | 32 | tetrad/tetrad-6.5.3.pom 33 | edu.cmu 34 | tetrad 35 | 6.5.3 36 | pom 37 | 38 | 39 | 40 | tetrad-lib-jar 41 | install 42 | 43 | install-file 44 | 45 | 46 | tetrad/tetrad-lib-6.5.3.jar 47 | edu.cmu 48 | tetrad-lib 49 | 6.5.3 50 | jar 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /code/thirdparty/tetrad/tetrad-lib-6.5.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/code/thirdparty/tetrad/tetrad-lib-6.5.3.jar -------------------------------------------------------------------------------- /config.cfg: -------------------------------------------------------------------------------- 1 | # Database Configurations 2 | dbaddress = mysql://127.0.0.1 3 | dbname = name_of_databases 4 | dbusername = database_username 5 | dbpassword = database_password 6 | dbtemporarytablesize = 4 7 | dbcollation = latin1_swedish_ci 8 | 9 | # FactorBase Configurations 10 | AutomaticSetup = 1 11 | ComputeKLD = 0 12 | Continuous = 0 13 | LinkAnalysis = 1 14 | LinkCorrelations = 1 15 | UseLocal_CT = 0 16 | SkipParameterLearning = 0 17 | 18 | # Counting strategy for generating the contingency tables. 19 | # 0 - Precount 20 | # 1 - Ondemand 21 | # 2 - Hybrid 22 | CountingStrategy = 0 23 | 24 | # Logging levels for console output. 25 | # off - No console output. 26 | # info - Basic console output. 27 | # runtimeDetails - Additional runtime information. 28 | # debug - Detailed information. 29 | LoggingLevel = info 30 | -------------------------------------------------------------------------------- /documentation/FACTORBASE DOCUMENTATION.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/documentation/FACTORBASE DOCUMENTATION.docx -------------------------------------------------------------------------------- /documentation/RandomGenerator.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/documentation/RandomGenerator.docx -------------------------------------------------------------------------------- /documentation/flow_diagram_for_CP.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/documentation/flow_diagram_for_CP.tif -------------------------------------------------------------------------------- /documentation/flow_diagram_for_CP.vsd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/documentation/flow_diagram_for_CP.vsd -------------------------------------------------------------------------------- /documentation/kurt-comment.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf210 2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Calibri;\f2\froman\fcharset0 TimesNewRomanPSMT; 3 | \f3\fswiss\fcharset0 ArialMT;} 4 | {\colortbl;\red255\green255\blue255;\red0\green0\blue0;} 5 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural 6 | 7 | \f0\fs36 \cf2 From: Kurt Routley \ 8 | Subject: RE: New scoring method\ 9 | Date: February 14, 2014 at 13:24:28 PST\ 10 | To: Zhensong Qian \ 11 | Cc: XiaoQian Yin , Nicole Li , Oliver Schulte , "sunyans@sfu.ca" , Fatemeh Riahi \ 12 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural 13 | 14 | \fs24 \cf2 \ 15 | \pard\pardeftab720 16 | 17 | \f1\fs32 \cf2 Hi all,\ 18 | \ 19 | Initial checkin for score computation is completed:\ 20 | join-bayes/laj-implement/branches/BayesBaseNew/cfg/scorecomputation.cfg\ 21 | join-bayes/laj-implement/branches/BayesBaseNew/src/ScoreComputation.java\ 22 | join-bayes/laj-implement/branches/BayesBaseNew/src/TestScoreComputation.java\ 23 | \ 24 | TestScoreComputation can be used to test all three steps (CT, CP, LL)\ 25 | \ 26 | Outstanding issues:\ 27 | -No parameters and AIC/BIC scores for RNodes in FID__Scores table\ 28 | \ 29 | Let me know if you have any questions.\ 30 | -Kurt Routley\ 31 | \ 32 | \pard\pardeftab720\sa160 33 | \cf2 \ 34 | \pard\pardeftab720 35 | \cf2 Date: Fri, 14 Feb 2014 11:20:26 -0800\ 36 | From: zqian@sfu.ca\ 37 | To: kurtroutley@hotmail.com\ 38 | CC: xya46@sfu.ca; nicoleli0606@gmail.com; oschulte@cs.sfu.ca; sunyans@sfu.ca; friahi65@gmail.com\ 39 | Subject: Re: New scoring method\ 40 | \ 41 | \pard\pardeftab720 42 | 43 | \f2\fs28 \cf2 Hi Kurt, 44 | \fs38 \ 45 | \pard\pardeftab720 46 | 47 | \f3\fs28 \cf2 \ 48 | Currently for the scoring part, we only need the\'a0 \'a0 CP tables for the largest rchain. 49 | \f2\fs38 \ 50 | 51 | \f3\fs28 If we want to compute the scores for BayesNet of each lattice point,\'a0 52 | \f2\fs38 \ 53 | 54 | \f3\fs28 all the other CP tables could also be computed with Yan's code very easily. 55 | \f2\fs38 \ 56 | \ 57 | 58 | \f3\fs28 \ 59 | Best,\ 60 | Zhensong\ 61 | \pard\pardeftab720 62 | 63 | \f2\fs38 \cf2 \ 64 | \pard\pardeftab720\sa186 65 | \cf2 \ 66 | \pard\pardeftab720 67 | 68 | \f0\b\fs32 \cf2 \uc0\u21457 \u20214 \u20154 : 69 | \b0 "Kurt Routley" \ 70 | 71 | \b \uc0\u25910 \u20214 \u20154 : 72 | \b0 sunyans@sfu.ca, "Fatemeh Riahi" \ 73 | 74 | \b \uc0\u25220 \u36865 : 75 | \b0 "Zhensong Qian" , "XiaoQian Yin" , "Nicole Li" , "Oliver Schulte" \ 76 | 77 | \b \uc0\u21457 \u36865 \u26102 \u38388 : 78 | \b0 \uc0\u26143 \u26399 \u20116 , 2014\u24180 2 \u26376 14\u26085 \u19978 \u21320 11:10:29\ 79 | 80 | \b \uc0\u20027 \u39064 : 81 | \b0 RE: New scoring method\ 82 | \ 83 | Hi all,\ 84 | \ 85 | Have we finalized a naming convention for the tables? I'm currently seeing for the CT tables and \'a0for the CP tables. Should these be ? The CP tables appear to only be created with respect to the largest rchain.\ 86 | \ 87 | -Kurt Routley\ 88 | \ 89 | > Date: Thu, 13 Feb 2014 14:35:57 -0800\ 90 | \ 91 | \pard\pardeftab720 92 | 93 | \f2\fs38 \cf2 \ 94 | } -------------------------------------------------------------------------------- /documentation/manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/documentation/manual.pdf -------------------------------------------------------------------------------- /documentation/readme.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf210 2 | {\fonttbl\f0\fswiss\fcharset0 ArialMT;\f1\froman\fcharset0 TimesNewRomanPSMT;} 3 | {\colortbl;\red255\green255\blue255;\red0\green0\blue255;} 4 | \margl1440\margr1440\vieww12600\viewh10200\viewkind0 5 | \deftab720 6 | \pard\pardeftab720 7 | 8 | \f0\fs36 \cf2 For running within an IDE like Eclipse.\ 9 | \ 10 | check the config file config1.cfg\'a0(all configuration are read from this file)\ 11 | 12 | \f1\fs38 \cf0 \uc0\u8232 13 | \f0\fs36 \cf2 The main routine for learning the bayesian network is 14 | \f1\fs38 \cf0 15 | \f0\fs36 \cf2 RunBB.java\ 16 | \ 17 | 18 | \f1\fs38 \cf0 \ 19 | If you want to score the learned graph structure, using inference e.g. for getting CLL, the main classes are:\ 20 | \uc0\u8232 21 | \f0\fs36 \cf2 MakeTargetSetup.java 22 | \f1\fs38 \cf0 \uc0\u8232 23 | \f0\fs36 \cf2 FunctorWrapper.java\ 24 | \ 25 | } -------------------------------------------------------------------------------- /examples/Hepatitis/Hepatitis_std_Bio.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `Hepatitis_std` /*!40100 DEFAULT CHARACTER SET latin1 */; 2 | USE `Hepatitis_std`; 3 | -- MySQL dump 10.13 Distrib 5.1.69, for redhat-linux-gnu (x86_64) 4 | -- 5 | -- Host: cs-oschulte-01.cs.sfu.ca Database: Hepatitis_std 6 | -- ------------------------------------------------------ 7 | -- Server version 5.5.32 8 | 9 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 10 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 11 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 12 | /*!40101 SET NAMES utf8 */; 13 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 14 | /*!40103 SET TIME_ZONE='+00:00' */; 15 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 16 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 17 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 18 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 19 | 20 | -- 21 | -- Table structure for table `Bio` 22 | -- 23 | 24 | DROP TABLE IF EXISTS `Bio`; 25 | /*!40101 SET @saved_cs_client = @@character_set_client */; 26 | /*!40101 SET character_set_client = utf8 */; 27 | CREATE TABLE `Bio` ( 28 | `fibros` varchar(45) NOT NULL, 29 | `activity` varchar(45) NOT NULL, 30 | `b_id` int(10) unsigned NOT NULL AUTO_INCREMENT, 31 | PRIMARY KEY (`b_id`), 32 | KEY `Hepatitis_fibros` (`fibros`), 33 | KEY `Hepatitis_activity` (`activity`) 34 | ) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=latin1 AVG_ROW_LENGTH=512; 35 | /*!40101 SET character_set_client = @saved_cs_client */; 36 | 37 | -- 38 | -- Dumping data for table `Bio` 39 | -- 40 | 41 | LOCK TABLES `Bio` WRITE; 42 | /*!40000 ALTER TABLE `Bio` DISABLE KEYS */; 43 | INSERT INTO `Bio` VALUES ('1','1',1),('2','2',2),('3','3',3),('1','0',4),('1','1',5),('1','2',6),('4','3',7),('1','2',8),('3','2',9),('2','2',10),('4','1',11),('3','3',12),('4','2',13),('3','2',14),('4','2',15),('2','1',16),('4','3',17),('2','3',18),('0','1',19),('0','0',20),('2','1',21),('3','4',22),('4','4',23),('1','4',24),('4','1',25),('2','4',26),('3','1',27),('3','1',28),('2','3',29),('1','3',30),('0','4',31),('1','3',32); 44 | /*!40000 ALTER TABLE `Bio` ENABLE KEYS */; 45 | UNLOCK TABLES; 46 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 47 | 48 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 49 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 50 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 51 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 52 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 53 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 54 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 55 | 56 | -- Dump completed on 2013-08-30 14:59:47 57 | -------------------------------------------------------------------------------- /examples/MovieLens_TQ/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/examples/MovieLens_TQ/.DS_Store -------------------------------------------------------------------------------- /factorbase-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/factorbase-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /images/configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/images/configuration.png -------------------------------------------------------------------------------- /images/univschema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/images/univschema.png -------------------------------------------------------------------------------- /make_xml_sum_to_one.py: -------------------------------------------------------------------------------- 1 | """ 2 | This script takes an xml_file and makes all the probabilities sum to 1. 3 | You need to install bs4 library first (pip install bs4) 4 | 5 | """ 6 | 7 | 8 | from bs4 import BeautifulSoup 9 | 10 | # Reading the data inside the XML file to a variable 11 | xml_file = '/Users/parmis/Desktop/Bif_functor_road_scene_2.xml' # change the path to your xml path 12 | 13 | with open(xml_file, 'r') as f: 14 | data = f.read() 15 | 16 | # Parsing the XML using BeautifulSoup 17 | Bs_data = BeautifulSoup(data, "xml") 18 | 19 | # Finding all instances of the 'VARIABLE' tag 20 | all_vars = Bs_data.find_all('VARIABLE') 21 | 22 | 23 | 24 | # Counting all the possible values for a variable 25 | 26 | print("Counting all the possible values for a variable") 27 | var_to_num_values = {} 28 | for var in all_vars: 29 | name = var.find('NAME') 30 | outcome_elements = var.find_all('OUTCOME') 31 | var_to_num_values[name.text] = len(outcome_elements) 32 | 33 | 34 | 35 | 36 | all_defs = Bs_data.find_all('DEFINITION') 37 | 38 | 39 | 40 | print("Making all the conditional probablities sum to 1") 41 | for defin in all_defs: 42 | name = defin.find('FOR').text 43 | count_possible_values = var_to_num_values[name] 44 | 45 | table = defin.find('TABLE').get_text().split() 46 | table = list(map(float, table)) 47 | new_table = [] 48 | for i in range(0,len(table), count_possible_values): 49 | current_values = table[i: i + count_possible_values ] 50 | summ = sum(current_values) 51 | for i in range(len(current_values)): 52 | current_values[i] = current_values[i] / summ 53 | new_table.extend(current_values) 54 | 55 | defin.find('TABLE').string = ' '.join([str(item) for item in new_table]) 56 | 57 | # Save the updated XML 58 | with open(xml_file, 'w') as f: 59 | f.write(Bs_data.prettify()) 60 | print("File is updated!") 61 | -------------------------------------------------------------------------------- /obsolete/.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | dist: trusty 3 | addons: 4 | mariadb: '10.3' 5 | jdk: 6 | - oraclejdk8 7 | before_script: 8 | - mysql -e "use mysql; update user set password=PASSWORD('123456') where User='root'; flush privileges;" -uroot 9 | - mysql -uroot -p123456 < travis-resources/unielwin_course.sql 10 | - mysql -uroot -p123456 < travis-resources/unielwin_prof.sql 11 | - mysql -uroot -p123456 < travis-resources/unielwin_RA.sql 12 | - mysql -uroot -p123456 < travis-resources/unielwin_registration.sql 13 | - mysql -uroot -p123456 < travis-resources/unielwin_student.sql 14 | - mysql -uroot -p123456 < travis-resources/tests-database.sql 15 | script: 16 | - cd code 17 | - mvn install -DtestDBUserName=root -DtestDBPassword=123456 18 | - java -Dconfig=../travis-resources/config.cfg -jar factorbase/target/factorbase*SNAPSHOT.jar 19 | - ls -lh 20 | - tail dag_.txt 21 | # Compare the structure of the graphs in the BIF files. 22 | - python3 ../travis-resources/bifchecker.py --compare Bif_unielwin.xml ../travis-resources/expected-output/Bif_unielwin.xml 23 | # Check for any differences in the BIF files. 24 | - diff Bif_unielwin.xml ../travis-resources/expected-output/Bif_unielwin.xml 25 | - bash ../travis-resources/dbdump.sh -n unielwin -p 123456 26 | - diff mysql-extraction.txt ../travis-resources/expected-output/mysql-extraction.txt 27 | - java -Dconfig=../travis-resources/config.cfg -jar mlnexporter/target/mlnexporter*SNAPSHOT.jar > mln_jar.txt 28 | - tail mln_jar.txt 29 | 30 | after_script: 31 | - mysql -e "show databases;" -uroot -p123456 32 | - mysql -e "use unielwin_BN; show tables;" -uroot -p123456 33 | - mysql -e "use unielwin_CT; show tables;" -uroot -p123456 -------------------------------------------------------------------------------- /obsolete/BIFReader.java: -------------------------------------------------------------------------------- 1 | package bif; 2 | 3 | import java.util.ArrayList; 4 | import java.io.*; 5 | 6 | public class BIFReader { 7 | 8 | public static ArrayList getLinks(String filePath) throws IOException { 9 | FileReader file = new FileReader(filePath); 10 | BufferedReader in = new BufferedReader(file); 11 | String curLine = ""; 12 | Boolean inDef = false; 13 | ArrayList givens = new ArrayList(); 14 | String forNode = ""; 15 | ArrayList toReturn = new ArrayList(); 16 | 17 | while((curLine = in.readLine()) != null){ 18 | if (inDef) { 19 | if (curLine.contains("")) { 20 | curLine = curLine.trim(); 21 | forNode = curLine.substring(5, curLine.length() - 6); 22 | } 23 | if (curLine.contains("")) { 24 | curLine = curLine.trim(); 25 | givens.add(curLine.substring(7, curLine.length() - 8)); 26 | } 27 | } 28 | if (curLine.equals("")) { 29 | inDef = true; 30 | givens = new ArrayList(); 31 | forNode = ""; 32 | } 33 | if (curLine.equals("")) { 34 | inDef = false; 35 | for (String given : givens) { 36 | String[] val = {given, forNode}; 37 | toReturn.add(val); 38 | } 39 | } 40 | } 41 | in.close(); 42 | file.close(); 43 | return toReturn; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /obsolete/columnstore/counts_storedprocedures.sql: -------------------------------------------------------------------------------- 1 | CREATE PROCEDURE `getColumnsInfo`(tableNames TEXT) 2 | BEGIN 3 | SELECT 4 | column_name, 5 | CASE WHEN 6 | data_type = 'enum' 7 | THEN 8 | CONCAT("VARCHAR(", CHARACTER_MAXIMUM_LENGTH, ")") 9 | ELSE 10 | column_type 11 | END AS DataType 12 | FROM 13 | information_schema.columns 14 | WHERE 15 | table_schema = '@database@' 16 | AND 17 | find_in_set(table_name, tableNames); 18 | END// -------------------------------------------------------------------------------- /obsolete/commented-out/BIFImport.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.exporter.bifexporter.bif; 2 | 3 | import java.io.IOException; 4 | import java.sql.Connection; 5 | import java.sql.SQLException; 6 | import java.sql.Statement; 7 | import java.util.ArrayList; 8 | import java.util.logging.Logger; 9 | 10 | import nu.xom.ParsingException; 11 | 12 | public class BIFImport { 13 | 14 | /* 15 | * Arguments: 16 | * 1st: filename: The name of the file to import (include directory information if appropriate) 17 | * 2nd: database name: The name of the database to access. It is assumed that the we wish to insert into the 18 | * Entity_BayesNets table 19 | */ 20 | /*public static void main(String[] args) { 21 | if (args.length != 2) { 22 | logger.fine("Arguments incorrect"); 23 | logger.fine("Expected filename database_name"); 24 | return; 25 | } 26 | try { 27 | Import(args[0], args[1]); 28 | } catch (IOException e) { 29 | // TODO Auto-generated catch block 30 | e.printStackTrace(); 31 | } catch (SQLException e) { 32 | // TODO Auto-generated catch block 33 | e.printStackTrace(); 34 | } catch (ParsingException e) { 35 | e.printStackTrace(); 36 | } 37 | 38 | logger.fine("Exited Normally"); 39 | }*/ 40 | 41 | /* 42 | * Import a file into the database by getting all the pairs of links in the file and then writing them out 43 | * Links in the file showing no parent are written with an emtpy string parent to the database 44 | */ 45 | private static Logger logger = Logger.getLogger(BIFImport.class.getName()); 46 | 47 | public static void Import(String filename, String id, String tableName, Connection con) throws IOException, SQLException, ParsingException { 48 | ArrayList pairs = BIF_IO.getLinksFromFile(filename); 49 | 50 | //System.out.print(id); 51 | for (String[] pair : pairs) { 52 | Statement st = con.createStatement(); 53 | 54 | logger.fine("INSERT ignore INTO " + tableName + " VALUES (\'" + id + "\', \'" + pair[1] + "\', \'" + pair[0] + "\');"); 55 | st.execute("INSERT ignore INTO " + tableName + " VALUES (\'" + id + "\', \'" + pair[1] + "\', \'" + pair[0] + "\');"); 56 | 57 | } 58 | } 59 | } 60 | 61 | 62 | /* 63 | *BIFImport.Import("output" + File.separator + "xml" + File.separator + id.replace("`","") + ".xml", id, "Entity_BayesNets", con2); 64 | */ -------------------------------------------------------------------------------- /obsolete/jars/Jama-1.0.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/jars/Jama-1.0.3.jar -------------------------------------------------------------------------------- /obsolete/jars/colt.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/jars/colt.jar -------------------------------------------------------------------------------- /obsolete/jars/commons-collections-3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/jars/commons-collections-3.1.jar -------------------------------------------------------------------------------- /obsolete/jars/commons-lang-2.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/jars/commons-lang-2.6.jar -------------------------------------------------------------------------------- /obsolete/jars/ibatis-common-2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/jars/ibatis-common-2.jar -------------------------------------------------------------------------------- /obsolete/jars/mtj.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/jars/mtj.jar -------------------------------------------------------------------------------- /obsolete/jars/mysql-connector-java-5.1.22-bin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/jars/mysql-connector-java-5.1.22-bin.jar -------------------------------------------------------------------------------- /obsolete/jars/unreferenced/junit.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/jars/unreferenced/junit.jar -------------------------------------------------------------------------------- /obsolete/jars/unreferenced/opt77.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/jars/unreferenced/opt77.jar -------------------------------------------------------------------------------- /obsolete/jars/unreferenced/pal-1.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/jars/unreferenced/pal-1.4.jar -------------------------------------------------------------------------------- /obsolete/jars/weka.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/jars/weka.jar -------------------------------------------------------------------------------- /obsolete/jars/xom-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/jars/xom-1.1.jar -------------------------------------------------------------------------------- /obsolete/old-factorbase/FactorBase.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/old-factorbase/FactorBase.jar -------------------------------------------------------------------------------- /obsolete/old-factorbase/src/config.cfg: -------------------------------------------------------------------------------- 1 | dbaddress = mysql://127.0.0.1 2 | dbusername = root 3 | dbpassword = 123456 4 | dbBNschema = unielwin_BN 5 | dbDataSchema = unielwin 6 | dbOutputSchema = unielwin_db 7 | pathBayesNet = Path_BayesNets 8 | 9 | LinkAnalysis = 1 10 | 11 | Continuous = 0 12 | Grounded = 0 13 | 14 | dbname = unielwin 15 | AutomaticSetup = 1 16 | LinkCorrelations = 1 17 | ComputeKLD = 0 18 | 19 | dbschema = unielwin_BN 20 | dbcounts = unielwin_db 21 | dbcondprob = unielwin_db 22 | 23 | UseLocal_CT = 0 24 | 25 | CrossValidation = 0 26 | 27 | -------------------------------------------------------------------------------- /obsolete/old-factorbase/src/scripts/storedprocs.sql: -------------------------------------------------------------------------------- 1 | CREATE PROCEDURE `find_values`() 2 | BEGIN 3 | DECLARE done INT DEFAULT 0; 4 | DECLARE tablename VARCHAR(30); 5 | DECLARE columnname VARCHAR(30); 6 | DECLARE cur1 CURSOR FOR 7 | SELECT TABLE_NAME, COLUMN_NAME FROM AttributeColumns; 8 | DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; 9 | OPEN cur1; 10 | 11 | DROP TABLE IF EXISTS Attribute_Value; 12 | CREATE TABLE 13 | Attribute_Value ( 14 | COLUMN_NAME VARCHAR(30), 15 | VALUE VARCHAR(30)); 16 | 17 | LOOP1: LOOP 18 | FETCH cur1 INTO tablename, columnname; 19 | IF done = 1 THEN 20 | LEAVE LOOP1; 21 | END IF; 22 | SET @SQLQUERY = 'INSERT INTO Attribute_Value ('; 23 | SET @SQLQUERY = CONCAT(@SQLQUERY, 'SELECT distinct "', columnname); 24 | SET @SQLQUERY = CONCAT(@SQLQUERY, '", ', columnname); 25 | SET @SQLQUERY = CONCAT(@SQLQUERY, ' FROM @database@.', tablename, ')'); 26 | 27 | PREPARE stmt1 FROM @SQLQUERY; 28 | EXECUTE stmt1; 29 | END LOOP LOOP1; 30 | 31 | CLOSE cur1; 32 | 33 | END -------------------------------------------------------------------------------- /obsolete/old-factorbase/src/scripts/transfer.sql: -------------------------------------------------------------------------------- 1 | DROP SCHEMA IF EXISTS @database@_BN; 2 | create schema @database@_BN; 3 | 4 | DROP SCHEMA IF EXISTS @database@_CT; 5 | create schema @database@_CT; 6 | 7 | USE @database@_BN; 8 | SET storage_engine=INNODB; 9 | 10 | 11 | /*copy tables from setup database */ 12 | 13 | 14 | create table 1Nodes as select * from @database@_setup.1Nodes; 15 | create table 2Nodes as select * from @database@_setup.2Nodes; 16 | create table RNodes as select * from @database@_setup.RNodes; 17 | create table PVariables as select * from @database@_setup.PVariables; 18 | create table EntityTables as select * from @database@_setup.EntityTables; 19 | create table AttributeColumns as select * from @database@_setup.AttributeColumns; 20 | create table TernaryRelations as select * from @database@_setup.TernaryRelations; 21 | create table RelationTables as select * from @database@_setup.RelationTables; 22 | create table NoPKeys as select * from @database@_setup.NoPKeys; 23 | create table ForeignKeyColumns as select * from @database@_setup.ForeignKeyColumns; 24 | create table ForeignKeys_pvars as select * from @database@_setup.ForeignKeys_pvars; 25 | create table InputColumns as select * from @database@_setup.InputColumns; 26 | create table Attribute_Value as select * from @database@_setup.Attribute_Value; 27 | /* 28 | create table Groundings like @database@_setup.Groundings; 29 | insert into Groundings select * from @database@_setup.Groundings; 30 | */ 31 | 32 | /* 33 | create table Path_BN_nodes as select * from @database@_setup.Path_BN_nodes; 34 | create table lattice_membership as select * from @database@_setup.lattice_membership; 35 | create table lattice_set as select * from @database@_setup.lattice_set; 36 | create table Path_Aux_Edges as select * from @database@_setup.Path_Aux_Edges; 37 | create table SchemaEdges as select * from @database@_setup.SchemaEdges; 38 | */ 39 | 40 | 41 | -------------------------------------------------------------------------------- /obsolete/old-factorbase/src/unused-scripts/markov_blanket.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: Kurt Routley 3 | * Date: Sept 18, 2013 4 | */ 5 | 6 | use @database@_BN; 7 | 8 | /* 9 | * Create Markov Blanket 10 | * For each entry in 1Nodes, 2Nodes, and RNodes, get 11 | * 1. Parents 12 | * 2. Children 13 | * 3. Children's Parents 14 | */ 15 | 16 | /* Create Parents Table */ 17 | drop table if exists TargetParents; 18 | 19 | create table TargetParents as 20 | select child as TargetNode, parent as TargetParent 21 | from Path_BayesNets 22 | where rchain='@largestrchain@' 23 | and ( child in ( select 1nid from 1Nodes ) or 24 | child in ( select 2nid from 2Nodes ) or 25 | child in ( select rnid from RNodes ) ) 26 | and parent <> ''; 27 | 28 | 29 | /* Create Children Table */ 30 | drop table if exists TargetChildren; 31 | 32 | create table TargetChildren as 33 | select parent as TargetNode, child as TargetChild 34 | from Path_BayesNets 35 | where rchain='@largestrchain@' 36 | and ( parent in ( select 1nid from 1Nodes ) or 37 | parent in ( select 2nid from 2Nodes ) or 38 | parent in ( select rnid from RNodes ) ) 39 | and child <> ''; 40 | 41 | 42 | /* Create Children's Parents Table */ 43 | drop table if exists TargetChildrensParents; 44 | 45 | create table TargetChildrensParents as 46 | select Path_BayesNets.parent as TargetNode, 47 | TargetParents.TargetParent as TargetChildParent 48 | from TargetParents, Path_BayesNets 49 | where TargetParents.TargetNode in 50 | ( select TargetChildren.TargetChild 51 | from TargetChildren 52 | where TargetChildren.TargetNode = Path_BayesNets.Parent ) 53 | and TargetParents.TargetParent <> Path_BayesNets.Parent 54 | group by Path_BayesNets.parent, TargetParents.TargetParent; 55 | 56 | 57 | 58 | /* Create Markov Blanket Table */ 59 | drop table if exists TargetMB; 60 | 61 | create table TargetMB as 62 | ( select TargetNode, TargetParent as TargetMBNode 63 | from TargetParents ) 64 | union distinct 65 | ( select TargetNode, TargetChild as TargetMBNode 66 | from TargetChildren ) /*zqian, only use children and parent of the target node, April 8th, 2014*/ 67 | union distinct 68 | ( select TargetNode, TargetChildParent as TargetMBNode 69 | from TargetChildrensParents ) 70 | ORDER BY TargetNode; 71 | -------------------------------------------------------------------------------- /obsolete/old-factorbase/src/unused-scripts/transfer2.sql: -------------------------------------------------------------------------------- 1 | DROP SCHEMA IF EXISTS @database@_BN; 2 | create schema @database@_BN; 3 | 4 | DROP SCHEMA IF EXISTS @database@_CT; 5 | create schema @database@_CT; 6 | 7 | USE @database@_BN; 8 | SET storage_engine=INNODB; 9 | 10 | 11 | /*copy tables from setup database */ 12 | 13 | 14 | create table 1Nodes as select * from @database@_setup.1Nodes; 15 | create table 2Nodes as select * from @database@_setup.2Nodes; 16 | create table RNodes as select * from @database@_setup.RNodes; 17 | create table PVariables as select * from @database@_setup.PVariables; 18 | create table EntityTables as select * from @database@_setup.EntityTables; 19 | create table AttributeColumns as select * from @database@_setup.AttributeColumns; 20 | create table TernaryRelations as select * from @database@_setup.TernaryRelations; 21 | create table RelationTables as select * from @database@_setup.RelationTables; 22 | create table NoPKeys as select * from @database@_setup.NoPKeys; 23 | create table ForeignKeyColumns as select * from @database@_setup.ForeignKeyColumns; 24 | create table ForeignKeys_pvars as select * from @database@_setup.ForeignKeys_pvars; 25 | create table InputColumns as select * from @database@_setup.InputColumns; 26 | create table Attribute_Value as select * from @database@_setup.Attribute_Value; 27 | /*June 19, 2014, for testing database*/ 28 | create table FNodes_pvars_UNION_RNodes_pvars as select * from @database@_setup.FNodes_pvars_UNION_RNodes_pvars ; 29 | create table Test_Node like @database@_setup.Test_Node; 30 | insert into Test_Node select * from @database@_setup.Test_Node; 31 | 32 | insert into 1Nodes 33 | SELECT 34 | CONCAT('`', COLUMN_NAME, '(', pvid, ')', '`') AS 1nid, 35 | COLUMN_NAME, 36 | pvid, 37 | index_number = 0 AS main 38 | FROM 39 | EntityTables 40 | natural join 41 | PVariables 42 | natural join 43 | FNodes_pvars_UNION_RNodes_pvars 44 | natural join 45 | Test_Node; 46 | 47 | /*June 24, 2014, prepare the primary key list for testing data*/ 48 | Drop table if exists Test_1nid ; 49 | create table Test_1nid as 50 | SELECT 51 | CONCAT('`', COLUMN_NAME, '(', pvid, ')', '`') AS 1nid, 52 | COLUMN_NAME, 53 | pvid, 54 | index_number = 0 AS main 55 | FROM 56 | EntityTables 57 | natural join 58 | PVariables 59 | natural join 60 | FNodes_pvars_UNION_RNodes_pvars 61 | natural join 62 | Test_Node; 63 | 64 | 65 | 66 | 67 | /* 68 | create table lattice_mapping as select * from @databasebase@_BN.lattice_mapping; 69 | create table lattice_membership as select * from @databasebase@_BN.lattice_membership; 70 | create table lattice_rel as select * from @databasebase@_BN.lattice_rel; 71 | create table lattice_set as select * from @databasebase@_BN.lattice_set; 72 | */ 73 | 74 | /* 75 | create table Path_BN_nodes as select * from @database@_setup.Path_BN_nodes; 76 | create table lattice_membership as select * from @database@_setup.lattice_membership; 77 | create table lattice_set as select * from @database@_setup.lattice_set; 78 | create table Path_Aux_Edges as select * from @database@_setup.Path_Aux_Edges; 79 | create table SchemaEdges as select * from @database@_setup.SchemaEdges; 80 | */ 81 | 82 | 83 | -------------------------------------------------------------------------------- /obsolete/old-factorbase/src/unused-scripts/transfer_to_target.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * transfer_to_target.sql 3 | * - Creates @database@_target_setup schema 4 | * - Gets Markov Blanket for Functors 5 | * Author: Kurt Routley 6 | * Date: September 23, 2013 7 | */ 8 | 9 | DROP SCHEMA IF EXISTS @database@_target_setup; 10 | create schema @database@_target_setup; 11 | 12 | USE @database@_target_setup; 13 | SET storage_engine=INNODB; 14 | 15 | /*copy tables from setup database */ 16 | create table FNodes as select * from @database@_BN.FNodes; 17 | create table FNodes_pvars as select * from @database@_BN.FNodes_pvars; 18 | create table PVariables as select * from @database@_BN.PVariables; 19 | create table EntityTables as select * from @database@_BN.EntityTables; 20 | create table AttributeColumns as select * from @database@_BN.AttributeColumns; 21 | create table TernaryRelations as select * from @database@_BN.TernaryRelations; 22 | create table RelationTables as select * from @database@_BN.RelationTables; 23 | create table NoPKeys as select * from @database@_BN.NoPKeys; 24 | create table ForeignKeyColumns as select * from @database@_BN.ForeignKeyColumns; 25 | create table ForeignKeys_pvars as select * from @database@_BN.ForeignKeys_pvars; 26 | create table InputColumns as select * from @database@_BN.InputColumns; 27 | create table Attribute_Value as select * from @database@_BN.Attribute_Value; 28 | create table RNodes_pvars as select * from @database@_BN.RNodes_pvars; 29 | 30 | 31 | /*June 19, 2014, for testing database*/ 32 | create table FNodes_pvars_UNION_RNodes_pvars as select * from @database@_BN.FNodes_pvars_UNION_RNodes_pvars ; 33 | 34 | 35 | DROP SCHEMA IF EXISTS @database@_target; 36 | create schema @database@_target; 37 | 38 | -------------------------------------------------------------------------------- /obsolete/old-mlnexporter/MLNExporter.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/old-mlnexporter/MLNExporter.jar -------------------------------------------------------------------------------- /obsolete/refactored/MakeSetup.java: -------------------------------------------------------------------------------- 1 | package ca.sfu.cs.factorbase.tables; 2 | 3 | /*analyze schema data to create setup database. This can be edited by the user before learning. 4 | If setup = 0, we skip this step and use the existing setup database 5 | Yan Sept 10th*/ 6 | 7 | 8 | //Assumption: 9 | // No suffix or *_std refers to the original database provided to FactorBase 10 | // *_setup is the setup database 11 | 12 | 13 | 14 | import java.sql.DriverManager; 15 | import java.sql.SQLException; 16 | 17 | import ca.sfu.cs.common.Configuration.Config; 18 | import ca.sfu.cs.factorbase.util.BZScriptRunner; 19 | 20 | import com.mysql.jdbc.Connection; 21 | 22 | 23 | public class MakeSetup { 24 | 25 | static Connection con; 26 | 27 | // to be read from config.cfg. 28 | // The config.cfg file should be the working directory. 29 | static String databaseName, databaseName_setup; 30 | static String dbUsername; 31 | static String dbPassword; 32 | static String dbaddress; 33 | 34 | public static void main(String args[]) throws Exception { 35 | runMS(); 36 | } 37 | 38 | public static void runMS() throws Exception { 39 | setVarsFromConfig(); 40 | connectDB(); 41 | //analyze schema data to create setup database. This can be edited by the user before learning. 42 | //If setup = 0, we skip this step and use the existing setup database 43 | 44 | BZScriptRunner bzsr = new BZScriptRunner(databaseName,con); 45 | 46 | bzsr.runScript(Config.SCRIPTS_DIRECTORY + "setup.sql"); 47 | bzsr.createSP(Config.SCRIPTS_DIRECTORY + "storedprocs.sql"); 48 | bzsr.callSP("find_values"); 49 | 50 | disconnectDB(); 51 | } 52 | 53 | 54 | public static void setVarsFromConfig(){ 55 | Config conf = new Config(); 56 | databaseName = conf.getProperty("dbname"); 57 | databaseName_setup = databaseName + "_setup"; 58 | dbUsername = conf.getProperty("dbusername"); 59 | dbPassword = conf.getProperty("dbpassword"); 60 | dbaddress = conf.getProperty("dbaddress"); 61 | } 62 | 63 | public static void connectDB() throws SQLException { 64 | //open database connections to the original database 65 | String CONN_STR = "jdbc:" + dbaddress + "/" + databaseName; 66 | try { 67 | java.lang.Class.forName("com.mysql.jdbc.Driver"); 68 | } catch (Exception ex) { 69 | System.err.println("Unable to load MySQL JDBC driver"); 70 | } 71 | con = (Connection) DriverManager.getConnection(CONN_STR, dbUsername, dbPassword); 72 | } 73 | 74 | public static void disconnectDB() throws SQLException { 75 | con.close(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /obsolete/scripts/add_orig_rnid.sql: -------------------------------------------------------------------------------- 1 | USE @database@_BN; 2 | SET storage_engine=INNODB; 3 | 4 | UPDATE `lattice_membership` 5 | JOIN 6 | `LatticeRNodes` ON `lattice_membership`.member = `LatticeRNodes`.short_rnid 7 | SET 8 | `lattice_membership`.rnid = `LatticeRNodes`.orig_rnid 9 | WHERE 10 | `lattice_membership`.member = `LatticeRNodes`.short_rnid; 11 | 12 | UPDATE `lattice_rel` 13 | JOIN 14 | `LatticeRNodes` ON `lattice_rel`.removed = `LatticeRNodes`.short_rnid 15 | SET 16 | `lattice_rel`.orig_rnid = `LatticeRNodes`.orig_rnid 17 | WHERE 18 | `lattice_rel`.removed = `LatticeRNodes`.short_rnid; -------------------------------------------------------------------------------- /obsolete/scripts/drop_tmpProc.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfu-cl-lab/FactorBase/e0833fd2b30577dfa7222de86edad6b4b5deb8a5/obsolete/scripts/drop_tmpProc.sql -------------------------------------------------------------------------------- /obsolete/scripts/markov_blanket.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: Kurt Routley 3 | * Date: Sept 18, 2013 4 | */ 5 | 6 | use @database@_BN; 7 | 8 | /* 9 | * Create Markov Blanket 10 | * For each entry in 1Nodes, 2Nodes, and RNodes, get 11 | * 1. Parents 12 | * 2. Children 13 | * 3. Children's Parents 14 | */ 15 | 16 | /* Create Parents Table */ 17 | drop table if exists TargetParents; 18 | 19 | create table TargetParents as 20 | select child as TargetNode, parent as TargetParent 21 | from Path_BayesNets 22 | where rchain='@largestrchain@' 23 | and ( child in ( select 1nid from 1Nodes ) or 24 | child in ( select 2nid from 2Nodes ) or 25 | child in ( select rnid from RNodes ) ) 26 | and parent <> ''; 27 | 28 | 29 | /* Create Children Table */ 30 | drop table if exists TargetChildren; 31 | 32 | create table TargetChildren as 33 | select parent as TargetNode, child as TargetChild 34 | from Path_BayesNets 35 | where rchain='@largestrchain@' 36 | and ( parent in ( select 1nid from 1Nodes ) or 37 | parent in ( select 2nid from 2Nodes ) or 38 | parent in ( select rnid from RNodes ) ) 39 | and child <> ''; 40 | 41 | 42 | /* Create Children's Parents Table */ 43 | drop table if exists TargetChildrensParents; 44 | 45 | create table TargetChildrensParents as 46 | select Path_BayesNets.parent as TargetNode, 47 | TargetParents.TargetParent as TargetChildParent 48 | from TargetParents, Path_BayesNets 49 | where TargetParents.TargetNode in 50 | ( select TargetChildren.TargetChild 51 | from TargetChildren 52 | where TargetChildren.TargetNode = Path_BayesNets.Parent ) 53 | and TargetParents.TargetParent <> Path_BayesNets.Parent 54 | group by Path_BayesNets.parent, TargetParents.TargetParent; 55 | 56 | 57 | 58 | /* Create Markov Blanket Table */ 59 | drop table if exists TargetMB; 60 | 61 | create table TargetMB as 62 | ( select TargetNode, TargetParent as TargetMBNode 63 | from TargetParents ) 64 | union distinct 65 | ( select TargetNode, TargetChild as TargetMBNode 66 | from TargetChildren ) /*zqian, only use children and parent of the target node, April 8th, 2014*/ 67 | union distinct 68 | ( select TargetNode, TargetChildParent as TargetMBNode 69 | from TargetChildrensParents ) 70 | ORDER BY TargetNode; 71 | -------------------------------------------------------------------------------- /obsolete/scripts/metadata.sql: -------------------------------------------------------------------------------- 1 | /******* extracting more metadata to support learning ***/ 2 | /* should be superseded */ 3 | 4 | /*adding covering index to speed up the query, however hash index does not support this technique, so replace it with default index, ie. B_Tree @ zqian May 22nd*/ 5 | USE @database@_BN; 6 | SET storage_engine=INNODB; 7 | 8 | /* Set up a table that contains all functor nodes of any arity, useful for Bayes net learning later. */ 9 | CREATE TABLE FNodes ( /*May 10th */ 10 | `Fid` varchar(199) , 11 | `FunctorName` varchar(64) , 12 | `Type` varchar(5) , 13 | `main` int(11) , 14 | PRIMARY KEY (`Fid`) 15 | ); 16 | 17 | /******* make comprehensive table for all functor nodes *****/ 18 | 19 | insert into FNodes 20 | SELECT 21 | 1nid AS Fid, 22 | COLUMN_NAME as FunctorName, 23 | '1Node' as Type, 24 | main 25 | FROM 26 | 1Nodes 27 | UNION SELECT 28 | 2nid AS Fid, 29 | COLUMN_NAME as FunctorName, 30 | '2Node' as Type, 31 | main 32 | FROM 33 | 2Nodes 34 | union select 35 | orig_rnid as FID, 36 | /* was rnid as FID */ 37 | TABLE_NAME as FunctorName, 38 | 'Rnode' as Type, 39 | main 40 | from 41 | RNodes; 42 | 43 | /*** for each functor node, record which population variables appear in it ***/ 44 | /* this should be superseded by transfer script August 16, 2017 */ 45 | 46 | create table FNodes_pvars as 47 | SELECT FNodes.Fid, PVariables.pvid FROM 48 | FNodes, 49 | 2Nodes, 50 | PVariables 51 | where 52 | FNodes.Type = '2Node' 53 | and FNodes.Fid = 2Nodes.2nid 54 | and PVariables.pvid = 2Nodes.pvid1 55 | union 56 | SELECT 57 | FNodes.Fid, PVariables.pvid 58 | FROM 59 | FNodes, 60 | 2Nodes, 61 | PVariables 62 | where 63 | FNodes.Type = '2Node' 64 | and FNodes.Fid = 2Nodes.2nid 65 | and PVariables.pvid = 2Nodes.pvid2 66 | union 67 | SELECT 68 | FNodes.Fid, PVariables.pvid 69 | FROM 70 | FNodes, 71 | 1Nodes, 72 | PVariables 73 | where 74 | FNodes.Type = '1Node' 75 | and FNodes.Fid = 1Nodes.1nid 76 | and PVariables.pvid = 1Nodes.pvid; 77 | 78 | 79 | /*** for each relationship node, record which population variables appear in it. 80 | Plus metadata about those variable, e.g. the name of the id column associated with them. 81 | /* this should be superseded by transfer script August 16, 2017 */ 82 | ***************/ 83 | 84 | CREATE TABLE RNodes_pvars AS SELECT DISTINCT orig_rnid, 85 | pvid, 86 | PVariables.TABLE_NAME, 87 | ForeignKeyColumns.COLUMN_NAME, 88 | ForeignKeyColumns.REFERENCED_COLUMN_NAME 89 | FROM 90 | ForeignKeyColumns, 91 | RNodes, 92 | PVariables 93 | WHERE 94 | pvid1 = pvid 95 | AND ForeignKeyColumns.TABLE_NAME = RNodes.TABLE_NAME 96 | AND ForeignKeyColumns.COLUMN_NAME = RNodes.COLUMN_NAME1 97 | AND ForeignKeyColumns.REFERENCED_TABLE_NAME = PVariables.TABLE_NAME 98 | UNION 99 | SELECT DISTINCT 100 | orig_rnid, 101 | pvid, 102 | PVariables.TABLE_NAME, 103 | ForeignKeyColumns.COLUMN_NAME, 104 | ForeignKeyColumns.REFERENCED_COLUMN_NAME 105 | FROM 106 | ForeignKeyColumns, 107 | RNodes, 108 | PVariables 109 | WHERE 110 | pvid2 = pvid 111 | AND ForeignKeyColumns.TABLE_NAME = RNodes.TABLE_NAME 112 | AND ForeignKeyColumns.COLUMN_NAME = RNodes.COLUMN_NAME2 113 | AND ForeignKeyColumns.REFERENCED_TABLE_NAME = PVariables.TABLE_NAME; 114 | -------------------------------------------------------------------------------- /obsolete/scripts/transfer2.sql: -------------------------------------------------------------------------------- 1 | DROP SCHEMA IF EXISTS @database@_BN; 2 | create schema @database@_BN; 3 | 4 | DROP SCHEMA IF EXISTS @database@_CT; 5 | create schema @database@_CT; 6 | 7 | USE @database@_BN; 8 | SET storage_engine=INNODB; 9 | 10 | 11 | /*copy tables from setup database */ 12 | 13 | 14 | create table 1Nodes as select * from @database@_setup.1Nodes; 15 | create table 2Nodes as select * from @database@_setup.2Nodes; 16 | create table RNodes as select * from @database@_setup.RNodes; 17 | create table PVariables as select * from @database@_setup.PVariables; 18 | create table EntityTables as select * from @database@_setup.EntityTables; 19 | create table AttributeColumns as select * from @database@_setup.AttributeColumns; 20 | create table TernaryRelations as select * from @database@_setup.TernaryRelations; 21 | create table RelationTables as select * from @database@_setup.RelationTables; 22 | create table NoPKeys as select * from @database@_setup.NoPKeys; 23 | create table ForeignKeyColumns as select * from @database@_setup.ForeignKeyColumns; 24 | create table ForeignKeys_pvars as select * from @database@_setup.ForeignKeys_pvars; 25 | create table InputColumns as select * from @database@_setup.InputColumns; 26 | create table Attribute_Value as select * from @database@_setup.Attribute_Value; 27 | /*June 19, 2014, for testing database*/ 28 | create table FNodes_pvars_UNION_RNodes_pvars as select * from @database@_setup.FNodes_pvars_UNION_RNodes_pvars ; 29 | create table Test_Node like @database@_setup.Test_Node; 30 | insert into Test_Node select * from @database@_setup.Test_Node; 31 | 32 | insert into 1Nodes 33 | SELECT 34 | CONCAT('`', COLUMN_NAME, '(', pvid, ')', '`') AS 1nid, 35 | COLUMN_NAME, 36 | pvid, 37 | index_number = 0 AS main 38 | FROM 39 | EntityTables 40 | natural join 41 | PVariables 42 | natural join 43 | FNodes_pvars_UNION_RNodes_pvars 44 | natural join 45 | Test_Node; 46 | 47 | /*June 24, 2014, prepare the primary key list for testing data*/ 48 | Drop table if exists Test_1nid ; 49 | create table Test_1nid as 50 | SELECT 51 | CONCAT('`', COLUMN_NAME, '(', pvid, ')', '`') AS 1nid, 52 | COLUMN_NAME, 53 | pvid, 54 | index_number = 0 AS main 55 | FROM 56 | EntityTables 57 | natural join 58 | PVariables 59 | natural join 60 | FNodes_pvars_UNION_RNodes_pvars 61 | natural join 62 | Test_Node; 63 | 64 | 65 | 66 | 67 | /* 68 | create table lattice_mapping as select * from @databasebase@_BN.lattice_mapping; 69 | create table lattice_membership as select * from @databasebase@_BN.lattice_membership; 70 | create table lattice_rel as select * from @databasebase@_BN.lattice_rel; 71 | create table lattice_set as select * from @databasebase@_BN.lattice_set; 72 | */ 73 | 74 | /* 75 | create table Path_BN_nodes as select * from @database@_setup.Path_BN_nodes; 76 | create table lattice_membership as select * from @database@_setup.lattice_membership; 77 | create table lattice_set as select * from @database@_setup.lattice_set; 78 | create table Path_Aux_Edges as select * from @database@_setup.Path_Aux_Edges; 79 | create table SchemaEdges as select * from @database@_setup.SchemaEdges; 80 | */ 81 | 82 | 83 | -------------------------------------------------------------------------------- /obsolete/scripts/transfer_to_target.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * transfer_to_target.sql 3 | * - Creates @database@_target_setup schema 4 | * - Gets Markov Blanket for Functors 5 | * Author: Kurt Routley 6 | * Date: September 23, 2013 7 | */ 8 | 9 | DROP SCHEMA IF EXISTS @database@_target_setup; 10 | create schema @database@_target_setup; 11 | 12 | USE @database@_target_setup; 13 | SET storage_engine=INNODB; 14 | 15 | /*copy tables from setup database */ 16 | create table FNodes as select * from @database@_BN.FNodes; 17 | create table FNodes_pvars as select * from @database@_BN.FNodes_pvars; 18 | create table PVariables as select * from @database@_BN.PVariables; 19 | create table EntityTables as select * from @database@_BN.EntityTables; 20 | create table AttributeColumns as select * from @database@_BN.AttributeColumns; 21 | create table TernaryRelations as select * from @database@_setup.TernaryRelations; 22 | create table RelationTables as select * from @database@_BN.RelationTables; 23 | create table NoPKeys as select * from @database@_setup.NoPKeys; 24 | create table ForeignKeyColumns as select * from @database@_BN.ForeignKeyColumns; 25 | create table ForeignKeys_pvars as select * from @database@_BN.ForeignKeys_pvars; 26 | create table InputColumns as select * from @database@_BN.InputColumns; 27 | create table Attribute_Value as select * from @database@_BN.Attribute_Value; 28 | create table RNodes_pvars as select * from @database@_BN.RNodes_pvars; 29 | 30 | 31 | /*June 19, 2014, for testing database*/ 32 | create table FNodes_pvars_UNION_RNodes_pvars as select * from @database@_BN.FNodes_pvars_UNION_RNodes_pvars ; 33 | 34 | 35 | DROP SCHEMA IF EXISTS @database@_target; 36 | create schema @database@_target; 37 | 38 | -------------------------------------------------------------------------------- /obsolete/tetrad/data/DataFilter.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.data; 23 | 24 | 25 | /** 26 | * Interface implemented by classes whose purpose is to generate modifications 27 | * of data sets. See implementations for details. 28 | * 29 | * @author Joseph Ramsey 30 | */ 31 | public interface DataFilter { 32 | 33 | /** 34 | * Interpolates the given data set, producing a data set with no missing 35 | * values. 36 | */ 37 | DataSet filter(DataSet dataSet); 38 | } 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /obsolete/tetrad/data/DataModel.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.data; 23 | 24 | import edu.cmu.tetrad.util.TetradSerializable; 25 | 26 | /** 27 | *

Interface implemented by classes, instantiations of which can serve as 28 | * data models in Tetrad. Data models may be named if desired; if provided, 29 | * these names will be used for display purposes.

This interface is 30 | * relatively free of methods, mainly because classes that can serve as data 31 | * models in Tetrad are diverse, including continuous and discrete data sets, 32 | * covariance and correlation matrices, graphs, and lists of other data models. 33 | * So this is primarily a taqging interface.

34 | * 35 | * @author Joseph Ramsey jdramsey@andrew.cmu.edu 36 | */ 37 | public interface DataModel 38 | extends KnowledgeTransferable, VariableSource, TetradSerializable { 39 | static final long serialVersionUID = 23L; 40 | 41 | /** 42 | * Returns the name of the data model (may be null). 43 | */ 44 | String getName(); 45 | 46 | /** 47 | * Sets the name of the data model (may be null). 48 | */ 49 | void setName(String name); 50 | 51 | /** 52 | * Renders the data model as as String. 53 | */ 54 | @Override 55 | String toString(); 56 | } 57 | 58 | 59 | -------------------------------------------------------------------------------- /obsolete/tetrad/data/DiscretizationSpec.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.data; 23 | 24 | /** 25 | * Created by IntelliJ IDEA. 26 | * User: josephramsey 27 | * Date: Jul 10, 2010 28 | * Time: 4:28:50 PM 29 | * To change this template use File | Settings | File Templates. 30 | */ 31 | public interface DiscretizationSpec { 32 | } 33 | 34 | -------------------------------------------------------------------------------- /obsolete/tetrad/data/ICovarianceMatrix.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.data; 23 | 24 | import edu.cmu.tetrad.util.TetradSerializable; 25 | import edu.cmu.tetrad.graph.Node; 26 | 27 | import java.util.List; 28 | 29 | import cern.colt.matrix.DoubleMatrix2D; 30 | 31 | /** 32 | * Created by IntelliJ IDEA. 33 | * User: jdramsey 34 | * Date: Jun 22, 2010 35 | * Time: 4:07:19 PM 36 | * To change this template use File | Settings | File Templates. 37 | */ 38 | public interface ICovarianceMatrix extends DataModel, TetradSerializable { 39 | @Override 40 | List getVariables(); 41 | 42 | @Override 43 | List getVariableNames(); 44 | 45 | String getVariableName(int index); 46 | 47 | int getDimension(); 48 | 49 | int getSampleSize(); 50 | 51 | @Override 52 | String getName(); 53 | 54 | @Override 55 | void setName(String name); 56 | 57 | @Override 58 | Knowledge getKnowledge(); 59 | 60 | @Override 61 | void setKnowledge(Knowledge knowledge); 62 | 63 | ICovarianceMatrix getSubmatrix(int[] indices); 64 | 65 | ICovarianceMatrix getSubmatrix(List submatrixVarNames); 66 | 67 | ICovarianceMatrix getSubmatrix(String[] submatrixVarNames); 68 | 69 | double getValue(int i, int j); 70 | 71 | void setMatrix(DoubleMatrix2D matrix); 72 | 73 | void setSampleSize(int sampleSize); 74 | 75 | int getSize(); 76 | 77 | DoubleMatrix2D getMatrix(); 78 | 79 | void select(Node variable); 80 | 81 | void clearSelection(); 82 | 83 | boolean isSelected(Node variable); 84 | 85 | List getSelectedVariableNames(); 86 | 87 | @Override 88 | String toString(); 89 | 90 | Node getVariable(String name); 91 | } 92 | 93 | -------------------------------------------------------------------------------- /obsolete/tetrad/data/VariableSource.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.data; 23 | 24 | import edu.cmu.tetrad.graph.Node; 25 | import edu.cmu.tetrad.util.TetradSerializable; 26 | 27 | import java.util.List; 28 | 29 | /** 30 | * Inteface implemented by classes, instantiations of which are associated with 31 | * lists of variables. Such lists of variables are used for a number of 32 | * purposes--creating data sets, creating graphs, comparing one data to another, 33 | * and so on. 34 | * 35 | * @author Joseph Ramsey 36 | */ 37 | public interface VariableSource extends TetradSerializable { 38 | static final long serialVersionUID = 23L; 39 | 40 | /** 41 | * Returns the list of variables associated with this object. 42 | */ 43 | List getVariables(); 44 | 45 | /** 46 | * Returns the variable names associated with this getVariableNames. 47 | */ 48 | List getVariableNames(); 49 | } 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /obsolete/tetrad/graph/DirectedEdgesOnly.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.graph; 23 | 24 | 25 | /** 26 | * A graph constraint permitting only directed edges to be added to the graph. 27 | * 28 | * @author Joseph Ramsey 29 | */ 30 | public final class DirectedEdgesOnly implements GraphConstraint { 31 | static final long serialVersionUID = 23L; 32 | 33 | //=============================CONSTRUCTORS===========================// 34 | 35 | public DirectedEdgesOnly() { 36 | 37 | } 38 | 39 | /** 40 | * Generates a simple exemplar of this class to test serialization. 41 | * 42 | * @see edu.cmu.TestSerialization 43 | * @see edu.cmu.tetradapp.util.TetradSerializableUtils 44 | */ 45 | public static DirectedEdgesOnly serializableInstance() { 46 | return new DirectedEdgesOnly(); 47 | } 48 | 49 | //=============================PUBLIC METHODS=========================// 50 | 51 | 52 | /** 53 | * Returns true iff the given edge is a directed edge. 54 | */ 55 | @Override 56 | public boolean isEdgeAddable(Edge edge, Graph graph) { 57 | return Edges.isDirectedEdge(edge); 58 | } 59 | 60 | /** 61 | * Returns true; 62 | */ 63 | @Override 64 | public boolean isNodeAddable(Node node, Graph graph) { 65 | return true; 66 | } 67 | 68 | /** 69 | * Returns true; 70 | */ 71 | @Override 72 | public boolean isEdgeRemovable(Edge edge, Graph graph) { 73 | return true; 74 | } 75 | 76 | /** 77 | * Returns true; 78 | */ 79 | @Override 80 | public boolean isNodeRemovable(Node node, Graph graph) { 81 | return true; 82 | } 83 | 84 | /** 85 | * Returns a string representation of the constraint. 86 | */ 87 | @Override 88 | public String toString() { 89 | return ""; 90 | } 91 | } 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /obsolete/tetrad/graph/NodePair.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.graph; 23 | 24 | /** 25 | * An unordered pair of nodes. 26 | * 27 | * @author Tyler Gibson 28 | */ 29 | public class NodePair { 30 | 31 | 32 | /** 33 | * The "First" node. 34 | */ 35 | private Node first; 36 | 37 | 38 | /** 39 | * The "second" node. 40 | */ 41 | private Node second; 42 | 43 | 44 | public NodePair(Node first, Node second){ 45 | if(first == null){ 46 | throw new NullPointerException("First node must not be null."); 47 | } 48 | if(second == null){ 49 | throw new NullPointerException("Second node must not be null."); 50 | } 51 | this.first = first; 52 | this.second = second; 53 | } 54 | 55 | //============================== Public methods =============================// 56 | 57 | public Node getFirst(){ 58 | return this.first; 59 | } 60 | 61 | public Node getSecond(){ 62 | return this.second; 63 | } 64 | 65 | @Override 66 | public int hashCode(){ 67 | return this.first.hashCode() + this.second.hashCode(); 68 | } 69 | 70 | 71 | @Override 72 | public boolean equals(Object o){ 73 | if(o == this){ 74 | return true; 75 | } 76 | if(!(o instanceof NodePair)){ 77 | return false; 78 | } 79 | NodePair thatPair = (NodePair)o; 80 | if(this.first.equals(thatPair.first) && this.second.equals(thatPair.second)){ 81 | return true; 82 | } 83 | return this.first.equals(thatPair.second) && this.second.equals(thatPair.first); 84 | } 85 | 86 | @Override 87 | public String toString(){ 88 | return "{" + this.first + ", " + this.second + "}"; 89 | } 90 | 91 | } 92 | 93 | -------------------------------------------------------------------------------- /obsolete/tetrad/regression/Regression.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.regression; 23 | 24 | import edu.cmu.tetrad.graph.Graph; 25 | import edu.cmu.tetrad.graph.Node; 26 | 27 | import java.util.List; 28 | 29 | /** 30 | * Implements a multiple regression model, allowing data to be specified 31 | * either as a tabular data set or as a covariance matrix plus list of means. 32 | * 33 | * @author Joseph Ramsey 34 | */ 35 | public interface Regression { 36 | 37 | /** 38 | * Sets the significance level at which coefficients are judged to be 39 | * significant. 40 | * @param alpha the significance level. 41 | */ 42 | void setAlpha(double alpha); 43 | 44 | /** 45 | * Returns the graph of significant regressors into the target. 46 | * @return This graph. 47 | */ 48 | Graph getGraph(); 49 | 50 | /** 51 | * Retresses target on the regressors, yielding 52 | * a regression plane. 53 | * @param target the target variable, being regressed. 54 | * @param regressors the list of variables being regressed on. 55 | * @return the regression plane. 56 | */ 57 | RegressionResult regress(Node target, List regressors); 58 | 59 | /** 60 | * Retresses target on the regressors, yielding 61 | * a regression plane. 62 | * @param target the target variable, being regressed. 63 | * @param regressors the list of variables being regressed on. 64 | * @return the regression plane. 65 | */ 66 | RegressionResult regress(Node target, Node...regressors); 67 | } 68 | 69 | -------------------------------------------------------------------------------- /obsolete/tetrad/search/GraphSearch.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.search; 23 | 24 | import java.util.Map; 25 | import java.util.Set; 26 | 27 | import edu.cmu.tetrad.graph.Graph; 28 | import edu.cmu.tetrad.graph.Node; 29 | 30 | /** 31 | * Created by IntelliJ IDEA. User: jdramsey Date: Jan 27, 2006 Time: 10:15:26 AM To change this template use File | 32 | * Settings | File Templates. 33 | */ 34 | public interface GraphSearch { 35 | Graph search(); 36 | Graph search(Map, Double>> globalScoreHash); 37 | 38 | long getElapsedTime(); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /obsolete/tetrad/search/ImpliedOrientation.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.search; 23 | 24 | import edu.cmu.tetrad.data.IKnowledge; 25 | import edu.cmu.tetrad.graph.Graph; 26 | 27 | /** 28 | * Adds any orientations implied by the given orientation. 29 | * 30 | * @author Joseph Ramsey 31 | */ 32 | public interface ImpliedOrientation { 33 | 34 | /** 35 | * Sets knowledge. 36 | */ 37 | void setKnowledge(IKnowledge knowledge); 38 | 39 | /** 40 | * Adds implied orientations. 41 | */ 42 | void orientImplied(Graph graph); 43 | } 44 | 45 | -------------------------------------------------------------------------------- /obsolete/tetrad/search/LegalPairs.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.search; 23 | 24 | import edu.cmu.tetrad.graph.Node; 25 | 26 | import java.util.List; 27 | 28 | /** 29 | * Determines whether nodes indexed as (n1, center, n2) form a legal pair of edges in a graph for purposes of some 30 | * algorithm that uses this information. The pair would be n1---center---n2. 31 | * 32 | * @author Joseph Ramsey 33 | */ 34 | public interface LegalPairs { 35 | 36 | /** 37 | * Returns true iff x*-*y is a legal first edge for the base case. 38 | */ 39 | boolean isLegalFirstEdge(Node x, Node y); 40 | 41 | /** 42 | * Returns true iff n1---center---n2 is a legal pair. 43 | */ 44 | boolean isLegalPair(Node x, Node y, Node z, List c, List d); 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /obsolete/tetrad/search/LocalDiscreteScore.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.search; 23 | 24 | import edu.cmu.tetrad.data.DataSet; 25 | 26 | /** 27 | * Created by IntelliJ IDEA. User: jdramsey Date: Jul 6, 2009 Time: 3:58:26 PM To change this template use File | 28 | * Settings | File Templates. 29 | */ 30 | public interface LocalDiscreteScore { 31 | void setStructurePrior(double structurePrior); 32 | 33 | void setSamplePrior(double samplePrior); 34 | 35 | double localScore(int i, int[] parents); 36 | 37 | DataSet getDataSet(); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /obsolete/tetrad/search/LocalScoreCache.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.search; 23 | 24 | import org.apache.commons.collections.map.MultiKeyMap; 25 | 26 | import java.util.HashSet; 27 | import java.util.Set; 28 | 29 | /** 30 | * Stores a map from (variable, parents) to score. 31 | * 32 | * @author Joseph Ramsey 33 | */ 34 | public class LocalScoreCache { 35 | private MultiKeyMap map; 36 | 37 | public LocalScoreCache() { 38 | map = new MultiKeyMap(); 39 | } 40 | 41 | public void add(int variable, int[] parents, double score) { 42 | Set _parents = new HashSet(parents.length); 43 | 44 | for (int parent : parents) { 45 | _parents.add(parent); 46 | } 47 | 48 | map.put(variable, _parents, score); 49 | } 50 | 51 | public double get(int variable, int[] parents) { 52 | Set _parents = new HashSet(parents.length); 53 | 54 | for (int parent : parents) { 55 | _parents.add(parent); 56 | } 57 | 58 | Double _score = (Double) map.get(variable, _parents); 59 | return _score == null ? Double.NaN : (_score); 60 | } 61 | 62 | public void clear() { 63 | map.clear(); 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /obsolete/tetrad/search/ScoredGraph.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.search; 23 | 24 | import edu.cmu.tetrad.graph.Graph; 25 | import edu.cmu.tetrad.graph.EdgeListGraph; 26 | import edu.cmu.tetrad.util.TetradSerializable; 27 | 28 | /** 29 | * Stores a graph with a score. 30 | * 31 | * @author Joseph Ramsey 32 | */ 33 | public class ScoredGraph implements Comparable, TetradSerializable { 34 | static final long serialVersionUID = 23L; 35 | private Graph graph; 36 | private Double score; 37 | 38 | public ScoredGraph(Graph graph, Double score) { 39 | this.graph = graph; 40 | this.score = score; 41 | } 42 | 43 | public static ScoredGraph serializableInstance() { 44 | return new ScoredGraph(new EdgeListGraph(), 0.0); 45 | } 46 | 47 | public Graph getGraph() { 48 | return graph; 49 | } 50 | 51 | public Double getScore() { 52 | return score; 53 | } 54 | 55 | @Override 56 | public int hashCode() { 57 | return score.hashCode(); 58 | } 59 | 60 | @Override 61 | public boolean equals(Object o) { 62 | ScoredGraph _scoredGraph = (ScoredGraph) o; 63 | 64 | if (!score.equals(_scoredGraph.getScore())) { 65 | return false; 66 | } 67 | 68 | if (!graph.equals(_scoredGraph.getGraph())) { 69 | return false; 70 | } 71 | 72 | return true; 73 | } 74 | 75 | @Override 76 | public int compareTo(Object o) { 77 | Double thisScore = getScore(); 78 | Double otherScore = ((ScoredGraph) o).getScore(); 79 | return thisScore.compareTo(otherScore); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /obsolete/tetrad/test/search/BDeuScoreTest.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.tetrad.search; 2 | 3 | import static org.hamcrest.MatcherAssert.assertThat; 4 | import static org.hamcrest.Matchers.equalTo; 5 | 6 | import java.io.File; 7 | import java.net.URL; 8 | import java.sql.SQLException; 9 | 10 | import org.junit.AfterClass; 11 | import org.junit.BeforeClass; 12 | import org.junit.Test; 13 | 14 | import edu.cmu.tetrad.data.DataReader; 15 | import edu.cmu.tetrad.data.DataSet; 16 | import edu.cmu.tetrad.data.DelimiterType; 17 | 18 | 19 | /** 20 | * Tests for the file BDeuScore.java. 21 | */ 22 | public class BDeuScoreTest { 23 | public static final double SAMPLE_PRIOR = 10.0000; 24 | public static final double STRUCTURE_PRIOR = 1.0000; 25 | public static final int POPULARITY = 0; 26 | public static final int TEACHINGABILITY = 1; 27 | 28 | private static DataSet dataset; 29 | 30 | 31 | @BeforeClass 32 | public static void setUpBeforeClass() throws Exception { 33 | URL url = BDeuScoreTest.class.getClassLoader().getResource("inputfiles/prof0.tsv"); 34 | DataReader parser = new DataReader(); 35 | parser.setDelimiter(DelimiterType.TAB); 36 | dataset = parser.parseTabular(new File(url.getFile())); 37 | } 38 | 39 | @AfterClass 40 | public static void tearDownAfterClass() throws Exception { 41 | dataset = null; 42 | } 43 | 44 | @Test 45 | public void localScore_ReturnsCorrectResults_WhenNoParents() throws SQLException { 46 | BDeuScore score = new BDeuScore(dataset, SAMPLE_PRIOR, STRUCTURE_PRIOR); 47 | Double scoreValue = score.localScore(POPULARITY, new int[] {}); 48 | assertThat(scoreValue, equalTo(-4.269697449704091)); 49 | } 50 | 51 | @Test 52 | public void localScore_ReturnsCorrectResults_WhenSingleParent() throws SQLException { 53 | BDeuScore score = new BDeuScore(dataset, SAMPLE_PRIOR, STRUCTURE_PRIOR); 54 | Double scoreValue = score.localScore(POPULARITY, new int[] {TEACHINGABILITY}); 55 | assertThat(scoreValue, equalTo(-3.935739532045626)); 56 | } 57 | } -------------------------------------------------------------------------------- /obsolete/tetrad/util/NamingProtocol.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.util; 23 | 24 | /** 25 | * Specifies the protocol used in Tetrad for variable names. This protocol 26 | * should be used throughout Tetrad. 27 | * 28 | * @author Joseph Ramsey 29 | */ 30 | public class NamingProtocol { 31 | 32 | /** 33 | * Returns true iff the given name is a legal variable name for Tetrad. 34 | * 35 | * @param name Ibid. 36 | * @return Ibid. 37 | */ 38 | public static boolean isLegalName(String name) { 39 | return name.matches("[^0-9]?[^ \t]*"); 40 | } 41 | 42 | /** 43 | * Returns a description of the protocol being used in Tetrad that can be 44 | * displayed to the user when they enter illegal variable names. 45 | * 46 | * @return Ibid. 47 | */ 48 | public static String getProtocolDescription() { 49 | return "Names must begin with non-numeric characters and may not contain " + 50 | "\nspaces or tabs."; 51 | } 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /obsolete/tetrad/util/NumberFormatUtil.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.util; 23 | 24 | import java.text.DecimalFormat; 25 | import java.text.NumberFormat; 26 | import java.util.prefs.Preferences; 27 | 28 | /** 29 | * Provides an application-wide "memory" of the number format to be used. 30 | * 31 | * @author Joseph Ramsey 32 | */ 33 | public class NumberFormatUtil { 34 | private static final NumberFormatUtil INSTANCE = new NumberFormatUtil(); 35 | // private NumberFormat nf = new DecimalFormat(Preferences.userRoot() 36 | // .get("numberFormat", "0.0000")); 37 | private NumberFormat nf; 38 | 39 | private NumberFormatUtil() { 40 | 41 | try { 42 | nf = new DecimalFormat(Preferences.userRoot().get("numberFormat", "0.0000")); 43 | } 44 | catch (Exception e) { 45 | nf = new DecimalFormat("0.0000"); 46 | } 47 | 48 | } 49 | 50 | /** 51 | * Returns the singleton instance of this class. 52 | * 53 | * @return Ibid. 54 | */ 55 | public static NumberFormatUtil getInstance() { 56 | return INSTANCE; 57 | } 58 | 59 | /** 60 | * Sets the number format, nf. 61 | * 62 | * @param nf Ibid. 63 | * @throws NullPointerException if nf is null. 64 | */ 65 | public void setNumberFormat(NumberFormat nf) { 66 | if (nf == null) { 67 | throw new NullPointerException(); 68 | } 69 | 70 | this.nf = nf; 71 | } 72 | 73 | /** 74 | * Returns the stored number format. 75 | * 76 | * @return Ibid. 77 | */ 78 | public NumberFormat getNumberFormat() { 79 | return nf; 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /obsolete/tetrad/util/TetradLoggerEvent.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.util; 23 | 24 | import java.util.EventObject; 25 | 26 | /** 27 | * An event associated with the TetradLoggerListener. 28 | * 29 | * @author Tyler Gibson 30 | */ 31 | public class TetradLoggerEvent extends EventObject { 32 | 33 | 34 | private final TetradLoggerConfig config; 35 | 36 | 37 | /** 38 | * Constructs the event given the source and the TetradLoggerConfig 39 | * associated with the event if there is one 40 | * 41 | * @param source - The source 42 | * @param config - The config, may be null. 43 | */ 44 | public TetradLoggerEvent(Object source, TetradLoggerConfig config){ 45 | super(source); 46 | this.config = config; 47 | } 48 | 49 | 50 | 51 | public TetradLoggerConfig getTetradLoggerConfig(){ 52 | return this.config; 53 | } 54 | 55 | 56 | 57 | 58 | } 59 | 60 | -------------------------------------------------------------------------------- /obsolete/tetrad/util/TetradLoggerListener.java: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // For information as to what this class does, see the Javadoc, below. // 3 | // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // 4 | // 2007, 2008, 2009, 2010 by Peter Spirtes, Richard Scheines, Joseph Ramsey, // 5 | // and Clark Glymour. // 6 | // // 7 | // This program is free software; you can redistribute it and/or modify // 8 | // it under the terms of the GNU General Public License as published by // 9 | // the Free Software Foundation; either version 2 of the License, or // 10 | // (at your option) any later version. // 11 | // // 12 | // This program is distributed in the hope that it will be useful, // 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 15 | // GNU General Public License for more details. // 16 | // // 17 | // You should have received a copy of the GNU General Public License // 18 | // along with this program; if not, write to the Free Software // 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | package edu.cmu.tetrad.util; 23 | 24 | /** 25 | * A listener for tetrad's logger. 26 | * 27 | * @author Tyler Gibson 28 | */ 29 | public interface TetradLoggerListener { 30 | 31 | 32 | /** 33 | * Invoked whenever a logger configuration is set on the TetradLogger and 34 | * the logger is active (i.e., logging isn't turned off etc). 35 | * 36 | * @param evt 37 | */ 38 | public void configurationActived(TetradLoggerEvent evt); 39 | 40 | 41 | /** 42 | * Invoked whenever a previously set logger config is resert or set to null and 43 | * the logger is active (i.e., logging isn't turned off etc). 44 | * 45 | * @param evt 46 | */ 47 | public void configurationDeactived(TetradLoggerEvent evt); 48 | 49 | 50 | 51 | 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /obsolete/unreferenced/Compute_Local_CT.java: -------------------------------------------------------------------------------- 1 | import java.sql.Connection; 2 | import java.sql.DriverManager; 3 | import java.sql.SQLException; 4 | 5 | 6 | public class Compute_Local_CT { 7 | static String databaseName; 8 | static Connection con4; 9 | static String dbUsername; 10 | static String dbPassword; 11 | static String dbaddress; 12 | static String databaseName1="PPLRuleDetectionJan23Movies"; 13 | static String databaseName2="PPLRuleDetectionJan23Movies"; 14 | 15 | public static void setVarsFromConfig(){ 16 | Config conf = new Config(); 17 | databaseName = conf.getProperty("dbname"); 18 | dbUsername = conf.getProperty("dbusername"); 19 | dbPassword = conf.getProperty("dbpassword"); 20 | dbaddress = conf.getProperty("dbaddress"); 21 | } 22 | 23 | public static void connectDB1() throws SQLException { 24 | 25 | String CONN_STR2 = "jdbc:" + dbaddress + "/" + databaseName1; 26 | try { 27 | java.lang.Class.forName("com.mysql.jdbc.Driver"); 28 | } catch (Exception ex) { 29 | System.err.println("Unable to load MySQL JDBC driver"); 30 | } 31 | con4 = (Connection) DriverManager.getConnection(CONN_STR2, dbUsername, dbPassword); 32 | } 33 | 34 | public static void connectDB2() throws SQLException { 35 | 36 | String CONN_STR2 = "jdbc:" + dbaddress + "/" + databaseName2; 37 | try { 38 | java.lang.Class.forName("com.mysql.jdbc.Driver"); 39 | } catch (Exception ex) { 40 | System.err.println("Unable to load MySQL JDBC driver"); 41 | } 42 | con4 = (Connection) DriverManager.getConnection(CONN_STR2, dbUsername, dbPassword); 43 | } 44 | 45 | /* 46 | public static void KeepTablesOnly(Connection con,String dbname,String tablename) throws SQLException { 47 | //drop temporary CT tables 48 | //1.0 keep one table 49 | String CONN_tmp = "jdbc:" + dbaddress + "/" + dbname; 50 | try { 51 | java.lang.Class.forName("com.mysql.jdbc.Driver"); 52 | } catch (Exception ex) { 53 | System.err.println("Unable to load MySQL JDBC driver"); 54 | } 55 | 56 | con = (Connection) DriverManager.getConnection(CONN_tmp, dbUsername, dbPassword); 57 | Statement st = con.createStatement(); 58 | 59 | //select the delete tablenames,return a strinng 60 | st.execute("select concat('drop table ',table_name,';') as result FROM information_schema.tables where table_schema = " +dbname+ " and table_name != " +tablename+ ";" ); 61 | 62 | Statement tmp = con.createStatement(); 63 | for(int i = 0; i< result.length();i++){ 64 | system.out.print(result[i]+"\n"); 65 | //tmp.execute(result[i]); 66 | } 67 | 68 | 69 | }*/ 70 | 71 | } 72 | 73 | 74 | -------------------------------------------------------------------------------- /obsolete/unreferenced/RelationalClassification.java: -------------------------------------------------------------------------------- 1 | //package relationalClassification; 2 | 3 | import com.mysql.jdbc.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.SQLException; 6 | 7 | public class RelationalClassification { 8 | 9 | private static Connection con_std; 10 | private static Connection con_BN; 11 | private static Connection con_CT; 12 | private static Connection con_setup; 13 | private static String databaseName_std; 14 | private static String databaseName_BN; 15 | private static String databaseName_CT; 16 | private static String databaseName_setup; 17 | private static String dbbase; 18 | private static String dbUsername; 19 | private static String dbPassword; 20 | private static String dbaddress; 21 | private static String linkCorrelation; 22 | private static String continuous; 23 | private static String functorid; 24 | 25 | public static void main(String args[]) throws Exception { 26 | 27 | //computeRelationalClassification(); 28 | computeGroundedCT(); 29 | } 30 | 31 | public static void computeGroundedCT() throws Exception{ 32 | setVarsFromConfig(); 33 | System.out.println("Set variables"); 34 | 35 | con_std = connectDB(databaseName_std); 36 | con_setup = connectDB(databaseName_setup); 37 | con_BN = connectDB(databaseName_BN); 38 | con_CT = connectDB(databaseName_CT); 39 | System.out.println("DBs connected"); 40 | 41 | //create a new setup copy corresponding to Markov Chain of the targetNode 42 | 43 | BayesBaseCT_SortMerge.buildCT(con_std, con_setup, con_BN, con_CT, databaseName_std, linkCorrelation, continuous); 44 | } 45 | 46 | /** 47 | * Connects to database via MySQL JDBC driver 48 | * @throws SQLException 49 | */ 50 | public static void setVarsFromConfig(){ 51 | Config conf = new Config(); 52 | databaseName_std = conf.getProperty("dbname"); 53 | //dbbase = conf.getProperty("dbbase"); 54 | databaseName_BN = databaseName_std + "_BN"; 55 | databaseName_CT = databaseName_std + "_CT"; 56 | databaseName_setup = databaseName_std + "_setup"; 57 | dbUsername = conf.getProperty("dbusername"); 58 | dbPassword = conf.getProperty("dbpassword"); 59 | dbaddress = conf.getProperty("dbaddress"); 60 | linkCorrelation = conf.getProperty("LinkCorrelations"); 61 | continuous = conf.getProperty("Continuous"); 62 | //ToDo: Move to separate config?? 63 | //functorid = conf.getProperty("functorid"); 64 | } 65 | 66 | public static Connection connectDB(String database) throws Exception{ 67 | 68 | String CONN_STR= "jdbc:" + dbaddress + "/" + database; 69 | try { 70 | java.lang.Class.forName("com.mysql.jdbc.Driver"); 71 | } catch (Exception ex) { 72 | System.err.println("Unable to load MySQL JDBC driver"); 73 | } 74 | try{ 75 | 76 | return ((Connection) DriverManager.getConnection(CONN_STR, dbUsername, dbPassword)); 77 | 78 | } 79 | catch(Exception e){ 80 | System.out.println("Could not conenct to the Database " + database); 81 | } 82 | return null; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /obsolete/unreferenced/callLocal_CT.java: -------------------------------------------------------------------------------- 1 | import java.sql.DriverManager; 2 | import java.sql.ResultSet; 3 | import java.sql.SQLException; 4 | import java.sql.Statement; 5 | import java.util.ArrayList; 6 | 7 | import com.mysql.jdbc.Connection; 8 | public class callLocal_CT { 9 | static String dbUsername; 10 | static String dbPassword; 11 | static String dbaddress; 12 | static String CT_databaseName = "unielwin_copy_CT"; 13 | static String PB_databaseName = "unielwin_copy_BN"; 14 | static String output_databaseName = "unielwin_db"; 15 | static Connection con_CT; 16 | static Connection con_PB; 17 | static Connection con_output; 18 | 19 | static int maxNumberOfMembers = 0; 20 | public static void main(String[] args) throws Exception { 21 | setVarsFromConfig(); 22 | connectDB(); 23 | //Statement initst = con4.createStatement(); 24 | Local_CT test = new Local_CT(CT_databaseName,PB_databaseName,output_databaseName ,con_CT,con_PB,con_output); 25 | test.big_CT_table="`a,b_CT`"; 26 | //test.Rchain="`a`"; 27 | Statement st_PB = con_PB.createStatement(); 28 | ResultSet rs_chain = st_PB.executeQuery("select distinct rchain from RChain_pvars;"); 29 | ArrayList chainlist = new ArrayList(); 30 | while(rs_chain.next()){ 31 | System.out.println("hasparent node: " + rs_chain.getString(1)); 32 | chainlist.add(rs_chain.getString(1)); 33 | } 34 | int size_chain = chainlist.size(); 35 | for(int i = 0; i parlist = new ArrayList(); 40 | 41 | while(rs_par.next()){ 42 | System.out.println("hasparent node: " + rs_par.getString(1)); 43 | parlist.add(rs_par.getString(1)); 44 | } 45 | int size_par = parlist.size(); 46 | for(int j = 0; j$output 41 | 42 | any_failure=0 43 | 44 | for database in "${name}_BN" "${name}_CT" "${name}_setup" 45 | do 46 | extractionFailed=0 47 | echo "Now extracting tables in database: $database..." 48 | 49 | tables=$($mysqlCommand "use $database; show tables;" | tail -n +2) 50 | 51 | if [[ $? -ne 0 ]] 52 | then 53 | extractionFailed=1 54 | any_failure=1 55 | fi 56 | 57 | for table in $tables 58 | do 59 | if [[ $table == "CallLogs" ]] 60 | then 61 | continue 62 | fi 63 | 64 | echo " Extracting table: $table" 65 | echo "Table: $table" >> $output 66 | $mysqlCommand "use $database; select * from \`$table\`;" | sort -f >> $output 67 | if [[ $? -ne 0 ]] 68 | then 69 | extractionFailed=1 70 | any_failure=1 71 | fi 72 | done 73 | 74 | if [[ $extractionFailed -eq 0 ]] 75 | then 76 | echo -e "\n ${GREEN}Extraction Complete!${CLEAR}\n" 77 | else 78 | echo -e "\n ${RED}Extraction Failed!${CLEAR}\n" 79 | fi 80 | done 81 | 82 | if [[ $any_failure -eq 1 ]] 83 | then 84 | echo -e "${RED}Failed to extract data!${CLEAR}" 85 | exit 1 86 | else 87 | echo -e " ${GREEN}ALL GOOD!${CLEAR}\n" 88 | echo -e " The extracted data can be found in $output.\n" 89 | fi -------------------------------------------------------------------------------- /travis-resources/unielwin_RA.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `unielwin` /*!40100 DEFAULT CHARACTER SET latin1 */; 2 | USE `unielwin`; 3 | -- MySQL dump 10.13 Distrib 5.1.69, for redhat-linux-gnu (x86_64) 4 | -- 5 | -- Host: kripke.cs.sfu.ca Database: unielwin 6 | -- ------------------------------------------------------ 7 | -- Server version 5.0.95 8 | 9 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 10 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 11 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 12 | /*!40101 SET NAMES utf8 */; 13 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 14 | /*!40103 SET TIME_ZONE='+00:00' */; 15 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 16 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 17 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 18 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 19 | 20 | -- 21 | -- Not dumping tablespaces as no INFORMATION_SCHEMA.FILES table on this server 22 | -- 23 | 24 | -- 25 | -- Table structure for table `RA` 26 | -- 27 | 28 | DROP TABLE IF EXISTS `RA`; 29 | /*!40101 SET @saved_cs_client = @@character_set_client */; 30 | /*!40101 SET character_set_client = utf8 */; 31 | CREATE TABLE `RA` ( 32 | `capability` varchar(45) default NULL, 33 | `prof_id` int(11) NOT NULL default '0', 34 | `student_id` int(11) NOT NULL default '0', 35 | `salary` varchar(45) default NULL, 36 | PRIMARY KEY (`prof_id`,`student_id`), 37 | KEY `FK_u2base_1` (`student_id`), 38 | KEY `FK_u2base_2` (`prof_id`), 39 | KEY `RA_capability` USING HASH (`capability`), 40 | KEY `RA_salary` USING HASH (`salary`), 41 | CONSTRAINT `FK_RA_1` FOREIGN KEY (`student_id`) REFERENCES `student` (`student_id`) ON DELETE CASCADE ON UPDATE CASCADE, 42 | CONSTRAINT `FK_RA_2` FOREIGN KEY (`prof_id`) REFERENCES `prof` (`prof_id`) ON DELETE CASCADE ON UPDATE CASCADE 43 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 44 | /*!40101 SET character_set_client = @saved_cs_client */; 45 | 46 | -- 47 | -- Dumping data for table `RA` 48 | -- 49 | 50 | LOCK TABLES `RA` WRITE; 51 | /*!40000 ALTER TABLE `RA` DISABLE KEYS */; 52 | INSERT INTO `RA` VALUES ('3',4,17,'med'),('1',5,5,'low'),('2',5,14,'low'),('3',5,18,'high'),('4',5,26,'high'),('3',5,27,'med'),('3',5,28,'med'),('2',6,5,'low'),('4',6,8,'high'),('4',6,9,'high'),('1',6,15,'med'),('2',6,16,'med'),('5',6,23,'high'),('5',6,24,'high'),('5',6,25,'high'),('4',7,7,'high'),('4',7,8,'high'),('1',7,11,'med'),('5',7,19,'high'),('1',7,20,'low'),('3',7,22,'med'),('1',8,12,'med'),('2',8,13,'med'),('3',8,21,'low'),('3',9,10,'high'); 53 | /*!40000 ALTER TABLE `RA` ENABLE KEYS */; 54 | UNLOCK TABLES; 55 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 56 | 57 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 58 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 59 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 60 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 61 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 62 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 63 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 64 | 65 | -- Dump completed on 2013-08-29 15:40:01 66 | -------------------------------------------------------------------------------- /travis-resources/unielwin_course.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `unielwin` /*!40100 DEFAULT CHARACTER SET latin1 */; 2 | USE `unielwin`; 3 | -- MySQL dump 10.13 Distrib 5.1.69, for redhat-linux-gnu (x86_64) 4 | -- 5 | -- Host: kripke.cs.sfu.ca Database: unielwin 6 | -- ------------------------------------------------------ 7 | -- Server version 5.0.95 8 | 9 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 10 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 11 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 12 | /*!40101 SET NAMES utf8 */; 13 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 14 | /*!40103 SET TIME_ZONE='+00:00' */; 15 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 16 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 17 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 18 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 19 | 20 | -- 21 | -- Not dumping tablespaces as no INFORMATION_SCHEMA.FILES table on this server 22 | -- 23 | 24 | -- 25 | -- Table structure for table `course` 26 | -- 27 | 28 | DROP TABLE IF EXISTS `course`; 29 | /*!40101 SET @saved_cs_client = @@character_set_client */; 30 | /*!40101 SET character_set_client = utf8 */; 31 | CREATE TABLE `course` ( 32 | `course_id` int(11) NOT NULL, 33 | `rating` varchar(45) default NULL, 34 | `diff` varchar(45) default NULL, 35 | PRIMARY KEY (`course_id`), 36 | KEY `course_rating` USING HASH (`rating`), 37 | KEY `course_diff` USING HASH (`diff`) 38 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 39 | /*!40101 SET character_set_client = @saved_cs_client */; 40 | 41 | -- 42 | -- Dumping data for table `course` 43 | -- 44 | 45 | LOCK TABLES `course` WRITE; 46 | /*!40000 ALTER TABLE `course` DISABLE KEYS */; 47 | INSERT INTO `course` VALUES (4,'2','1'),(5,'2','2'),(6,'2','1'),(7,'2','2'),(8,'2','1'),(9,'2','2'),(10,'2','1'),(11,'1','2'),(12,'1','1'),(13,'1','2'); 48 | /*!40000 ALTER TABLE `course` ENABLE KEYS */; 49 | UNLOCK TABLES; 50 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 51 | 52 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 53 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 54 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 55 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 56 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 57 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 58 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 59 | 60 | -- Dump completed on 2013-08-29 15:40:01 61 | -------------------------------------------------------------------------------- /travis-resources/unielwin_prof.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `unielwin` /*!40100 DEFAULT CHARACTER SET latin1 */; 2 | USE `unielwin`; 3 | -- MySQL dump 10.13 Distrib 5.1.69, for redhat-linux-gnu (x86_64) 4 | -- 5 | -- Host: kripke.cs.sfu.ca Database: unielwin 6 | -- ------------------------------------------------------ 7 | -- Server version 5.0.95 8 | 9 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 10 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 11 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 12 | /*!40101 SET NAMES utf8 */; 13 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 14 | /*!40103 SET TIME_ZONE='+00:00' */; 15 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 16 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 17 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 18 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 19 | 20 | -- 21 | -- Not dumping tablespaces as no INFORMATION_SCHEMA.FILES table on this server 22 | -- 23 | 24 | -- 25 | -- Table structure for table `prof` 26 | -- 27 | 28 | DROP TABLE IF EXISTS `prof`; 29 | /*!40101 SET @saved_cs_client = @@character_set_client */; 30 | /*!40101 SET character_set_client = utf8 */; 31 | CREATE TABLE `prof` ( 32 | `prof_id` int(11) NOT NULL default '0', 33 | `popularity` varchar(45) default NULL, 34 | `teachingability` varchar(45) default NULL, 35 | PRIMARY KEY (`prof_id`), 36 | KEY `prof_popularity` USING HASH (`popularity`), 37 | KEY `prof_teachingability` USING HASH (`teachingability`) 38 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 39 | /*!40101 SET character_set_client = @saved_cs_client */; 40 | 41 | -- 42 | -- Dumping data for table `prof` 43 | -- 44 | 45 | LOCK TABLES `prof` WRITE; 46 | /*!40000 ALTER TABLE `prof` DISABLE KEYS */; 47 | INSERT INTO `prof` VALUES (4,'2','3'),(5,'2','3'),(6,'2','3'),(7,'2','2'),(8,'1','2'),(9,'1','2'); 48 | /*!40000 ALTER TABLE `prof` ENABLE KEYS */; 49 | UNLOCK TABLES; 50 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 51 | 52 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 53 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 54 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 55 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 56 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 57 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 58 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 59 | 60 | -- Dump completed on 2013-08-29 15:40:01 61 | -------------------------------------------------------------------------------- /travis-resources/unielwin_student.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `unielwin` /*!40100 DEFAULT CHARACTER SET latin1 */; 2 | USE `unielwin`; 3 | -- MySQL dump 10.13 Distrib 5.1.69, for redhat-linux-gnu (x86_64) 4 | -- 5 | -- Host: kripke.cs.sfu.ca Database: unielwin 6 | -- ------------------------------------------------------ 7 | -- Server version 5.0.95 8 | 9 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 10 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 11 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 12 | /*!40101 SET NAMES utf8 */; 13 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 14 | /*!40103 SET TIME_ZONE='+00:00' */; 15 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 16 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 17 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 18 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 19 | 20 | -- 21 | -- Not dumping tablespaces as no INFORMATION_SCHEMA.FILES table on this server 22 | -- 23 | 24 | -- 25 | -- Table structure for table `student` 26 | -- 27 | 28 | DROP TABLE IF EXISTS `student`; 29 | /*!40101 SET @saved_cs_client = @@character_set_client */; 30 | /*!40101 SET character_set_client = utf8 */; 31 | CREATE TABLE `student` ( 32 | `student_id` int(11) NOT NULL default '0', 33 | `intelligence` varchar(45) default NULL, 34 | `ranking` varchar(45) default NULL, 35 | PRIMARY KEY (`student_id`), 36 | KEY `student_intelligence` USING HASH (`intelligence`), 37 | KEY `student_ranking` USING HASH (`ranking`) 38 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 39 | /*!40101 SET character_set_client = @saved_cs_client */; 40 | 41 | -- 42 | -- Dumping data for table `student` 43 | -- 44 | 45 | LOCK TABLES `student` WRITE; 46 | /*!40000 ALTER TABLE `student` DISABLE KEYS */; 47 | INSERT INTO `student` VALUES (4,'3','1'),(5,'3','1'),(6,'3','2'),(7,'3','1'),(8,'3','1'),(9,'3','2'),(10,'3','1'),(11,'3','2'),(12,'2','2'),(13,'2','2'),(14,'2','2'),(15,'2','3'),(16,'2','3'),(17,'2','3'),(18,'2','3'),(19,'2','3'),(20,'2','3'),(21,'2','2'),(22,'2','4'),(23,'2','3'),(24,'2','2'),(25,'1','4'),(26,'1','4'),(27,'1','4'),(28,'1','4'),(29,'1','5'),(30,'1','5'),(31,'1','5'),(32,'1','5'),(33,'1','5'),(34,'1','4'),(35,'1','4'),(36,'1','5'),(37,'1','5'),(38,'1','5'),(39,'3','1'),(40,'3','1'),(41,'3','1'); 48 | /*!40000 ALTER TABLE `student` ENABLE KEYS */; 49 | UNLOCK TABLES; 50 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 51 | 52 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 53 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 54 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 55 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 56 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 57 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 58 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 59 | 60 | -- Dump completed on 2013-08-29 15:40:01 61 | --------------------------------------------------------------------------------