Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boss parallel #1682

Merged
merged 16 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions docs/manual/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4548,6 +4548,25 @@ <h3>Zhang-Shen Bound Score</h3>

<div id="parameters"><h2>Search Parameters</h2>

<h3 class="parameter_description"
id="numThreads">numThreads</h3>
<ul
class="parameter_description_list">
<li>Short Description: <span
id="numThreads_short_desc">The number of threads (>= 1) to use for the search</span></li>
<li>Long Description: <span
id="numThreads_long_desc">The number of threads to use for the search.</span>
</li>
<li>Default Value: <span
id="numThreads_default_value">1</span></li>
<li>Lower
Bound: <span id="numThreads_lower_bound">1</span></li>
<li>Upper Bound: <span
id="numThreads_upper_bound">1000000</span></li>
<li>Value Type:
<span id="numThreads_value_type">Integer</span></li>
</ul>

<p>Note: You must specify the "Value Type" of each parameter, and
the value type must be one of the following: Integer, Long, Double, String,
Boolean.</p> <!-- Insert the parameter descriptions here, must follow
Expand Down Expand Up @@ -7435,24 +7454,24 @@ <h3 class="parameter_description" id="useBes">useBes</h3>
</ul>

<h3 class="parameter_description"
id="graspUseDataOrder">graspUseDataOrder</h3>
id="useDataOrder">useDataOrder</h3>
<ul
class="parameter_description_list">
<li>Short Description: <span
id="graspUseDataOrder_short_desc"> Yes just in case data variable
id="useDataOrder_short_desc"> Yes just in case data variable
order should be used for the first initial permutation. </span></li>
<li>Long Description: <span id="graspUseDataOrder_long_desc"> In
<li>Long Description: <span id="useDataOrder_long_desc"> In
either case, if multiple starting points are used, taking the best
scoring model from among these, subsequent starting points will all
be random shuffles. </span></li>
<li>Default Value: <span
id="graspUseDataOrder_default_value">true</span></li>
id="useDataOrder_default_value">true</span></li>
<li>Lower
Bound: <span id="graspUseDataOrder_lower_bound"></span></li>
Bound: <span id="useDataOrder_lower_bound"></span></li>
<li>Upper Bound: <span
id="graspUseDataOrder_upper_bound"></span></li>
id="useDataOrder_upper_bound"></span></li>
<li>Value Type: <span
id="graspUseDataOrder_value_type">Boolean</span></li>
id="useDataOrder_value_type">Boolean</span></li>
</ul>

<h3 class="parameter_description"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public Graph search(DataModel dataModel, Parameters parameters) {
edu.cmu.tetrad.search.Boss boss = new edu.cmu.tetrad.search.Boss(score);
boss.setUseBes(parameters.getBoolean(Params.USE_BES));
boss.setNumStarts(parameters.getInt(Params.NUM_STARTS));
boss.setAllowInternalRandomness(parameters.getBoolean(Params.ALLOW_INTERNAL_RANDOMNESS));
boss.setNumThreads(parameters.getInt(Params.NUM_THREADS));
boss.setUseDataOrder(parameters.getBoolean(Params.USE_DATA_ORDER));
PermutationSearch permutationSearch = new PermutationSearch(boss);
permutationSearch.setKnowledge(this.knowledge);

Expand Down Expand Up @@ -111,8 +112,9 @@ public List<String> getParameters() {
// Parameters
params.add(Params.USE_BES);
params.add(Params.NUM_STARTS);
params.add(Params.ALLOW_INTERNAL_RANDOMNESS);
params.add(Params.TIME_LAG);
params.add(Params.NUM_THREADS);
params.add(Params.USE_DATA_ORDER);

return params;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Graph search(DataModel dataModel, Parameters parameters) {
grasp.setOrdered(parameters.getBoolean(Params.GRASP_ORDERED_ALG));
grasp.setUseScore(parameters.getBoolean(Params.GRASP_USE_SCORE));
grasp.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_RASKUTTI_UHLER));
grasp.setUseDataOrder(parameters.getBoolean(Params.GRASP_USE_DATA_ORDER));
grasp.setUseDataOrder(parameters.getBoolean(Params.USE_DATA_ORDER));
grasp.setAllowInternalRandomness(parameters.getBoolean(Params.ALLOW_INTERNAL_RANDOMNESS));
grasp.setVerbose(parameters.getBoolean(Params.VERBOSE));

Expand Down Expand Up @@ -130,7 +130,7 @@ public List<String> getParameters() {
params.add(Params.GRASP_NONSINGULAR_DEPTH);
params.add(Params.GRASP_ORDERED_ALG);
params.add(Params.GRASP_USE_RASKUTTI_UHLER);
params.add(Params.GRASP_USE_DATA_ORDER);
params.add(Params.USE_DATA_ORDER);
params.add(Params.ALLOW_INTERNAL_RANDOMNESS);
params.add(Params.TIME_LAG);
params.add(Params.VERBOSE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public Graph search(DataModel dataModel, Parameters parameters) {
// variables as Tier 2 and the rest as Tier 1, and run BOSS again and return
// the result.

Knowledge knowledge = new Knowledge();;
Knowledge knowledge = new Knowledge();
for (Node node : targets) knowledge.addToTier(2, node.getName());
for (Node node : dataSet.getVariables()) {
if (!targets.contains(node)) knowledge.addToTier(1, node.getName());
Expand All @@ -96,7 +96,6 @@ public Graph search(DataModel dataModel, Parameters parameters) {
edu.cmu.tetrad.search.Boss boss = new edu.cmu.tetrad.search.Boss(score);
boss.setUseBes(parameters.getBoolean(Params.USE_BES));
boss.setNumStarts(parameters.getInt(Params.NUM_STARTS));
boss.setAllowInternalRandomness(parameters.getBoolean(Params.ALLOW_INTERNAL_RANDOMNESS));
PermutationSearch permutationSearch = new PermutationSearch(boss);
permutationSearch.setKnowledge(knowledge);
permutationSearch.search();
Expand Down Expand Up @@ -126,7 +125,6 @@ public Graph search(DataModel dataModel, Parameters parameters) {
boss = new edu.cmu.tetrad.search.Boss(score);
boss.setUseBes(parameters.getBoolean(Params.USE_BES));
boss.setNumStarts(parameters.getInt(Params.NUM_STARTS));
boss.setAllowInternalRandomness(parameters.getBoolean(Params.ALLOW_INTERNAL_RANDOMNESS));
permutationSearch = new PermutationSearch(boss);
permutationSearch.setKnowledge(knowledge);

Expand Down Expand Up @@ -169,7 +167,6 @@ public List<String> getParameters() {
// Parameters
params.add(Params.USE_BES);
params.add(Params.NUM_STARTS);
params.add(Params.ALLOW_INTERNAL_RANDOMNESS);
params.add(Params.TARGETS);
params.add(Params.TRIMMING_STYLE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public Graph search(DataModel dataModel, Parameters parameters) {
search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED));
search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE));
search.setDepth(parameters.getInt(Params.DEPTH));
search.setAllowInternalRandomness(parameters.getBoolean(Params.ALLOW_INTERNAL_RANDOMNESS));
search.setVerbose(parameters.getBoolean(Params.VERBOSE));

search.setKnowledge(knowledge);
Expand Down Expand Up @@ -129,7 +128,6 @@ public List<String> getParameters() {
params.add(Params.COMPLETE_RULE_SET_USED);
params.add(Params.DO_DISCRIMINATING_PATH_RULE);
params.add(Params.DEPTH);
params.add(Params.ALLOW_INTERNAL_RANDOMNESS);
params.add(Params.TIME_LAG);
params.add(Params.VERBOSE);

Expand All @@ -147,7 +145,7 @@ public Knowledge getKnowledge() {

@Override
public void setKnowledge(Knowledge knowledge) {
this.knowledge = new Knowledge((Knowledge) knowledge);
this.knowledge = new Knowledge(knowledge);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public Graph search(DataModel dataModel, Parameters parameters) {
search.setOrdered(parameters.getBoolean(Params.GRASP_ORDERED_ALG));
search.setUseScore(parameters.getBoolean(Params.GRASP_USE_SCORE));
search.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_RASKUTTI_UHLER));
search.setUseDataOrder(parameters.getBoolean(Params.GRASP_USE_DATA_ORDER));
search.setUseDataOrder(parameters.getBoolean(Params.USE_DATA_ORDER));
search.setNumStarts(parameters.getInt(Params.NUM_STARTS));

// FCI
Expand Down Expand Up @@ -143,7 +143,7 @@ public List<String> getParameters() {
params.add(Params.GRASP_NONSINGULAR_DEPTH);
params.add(Params.GRASP_ORDERED_ALG);
params.add(Params.GRASP_USE_RASKUTTI_UHLER);
params.add(Params.GRASP_USE_DATA_ORDER);
params.add(Params.USE_DATA_ORDER);
params.add(Params.NUM_STARTS);

// FCI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import edu.cmu.tetrad.algcomparison.Comparison;
import edu.cmu.tetrad.algcomparison.algorithm.Algorithms;
import edu.cmu.tetrad.algcomparison.algorithm.continuous.dag.Dagma;
import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.Boss;
import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.Fges;
import edu.cmu.tetrad.algcomparison.graph.RandomForward;
Expand All @@ -44,18 +43,22 @@ public static void main(String... args) {
Parameters parameters = new Parameters();
parameters.set(Params.NUM_RUNS, 1);
parameters.set(Params.DIFFERENT_GRAPHS, true);
parameters.set(Params.NUM_MEASURES, 100);
parameters.set(Params.NUM_MEASURES, 1000);
parameters.set(Params.AVG_DEGREE, 10);
parameters.set(Params.SAMPLE_SIZE, 1000);
parameters.set(Params.COEF_LOW, 0);
parameters.set(Params.COEF_HIGH, 1);
parameters.set(Params.VAR_LOW, 1);
parameters.set(Params.VAR_HIGH, 3);

parameters.set(Params.PENALTY_DISCOUNT, 2);
parameters.set(Params.PENALTY_DISCOUNT, 8);
parameters.set(Params.SEM_BIC_STRUCTURE_PRIOR, 0);
parameters.set(Params.ALPHA, 1e-2);

parameters.set(Params.USE_BES, false);
parameters.set(Params.NUM_STARTS, 1);
parameters.set(Params.NUM_THREADS, 400);

parameters.set(Params.VERBOSE, false);

Statistics statistics = new Statistics();
Expand All @@ -67,9 +70,9 @@ public static void main(String... args) {

Algorithms algorithms = new Algorithms();
// algorithms.add(new DirectLingam(new SemBicScore()));
algorithms.add(new Fges(new SemBicScore()));
// algorithms.add(new Fges(new SemBicScore()));
algorithms.add(new Boss(new SemBicScore()));
algorithms.add(new Dagma());
// algorithms.add(new Dagma());

Simulations simulations = new Simulations();
simulations.add(new SemSimulation(new RandomForward()));
Expand Down
5 changes: 0 additions & 5 deletions tetrad-lib/src/main/java/edu/cmu/tetrad/search/BFci.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public final class BFci implements IGraphSearch {
private int depth = -1;
private boolean doDiscriminatingPathRule = true;
private boolean bossUseBes = false;
private boolean allowInternalRandomness = false;


/**
Expand Down Expand Up @@ -119,7 +118,6 @@ public Graph search() {
Boss subAlg = new Boss(this.score);
subAlg.setUseBes(bossUseBes);
subAlg.setNumStarts(this.numStarts);
subAlg.setAllowInternalRandomness(this.allowInternalRandomness);
PermutationSearch alg = new PermutationSearch(subAlg);
alg.setKnowledge(this.knowledge);

Expand Down Expand Up @@ -214,7 +212,4 @@ public void setBossUseBes(boolean useBes) {
this.bossUseBes = useBes;
}

public void setAllowInternalRandomness(boolean allowInternalRandomness) {
this.allowInternalRandomness = allowInternalRandomness;
}
}
Loading