Skip to content

Commit

Permalink
Stricter and better integrator filtering for some application types.
Browse files Browse the repository at this point in the history
  • Loading branch information
danv61 committed Jan 14, 2025
1 parent f4621ef commit 70e0184
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 40 deletions.
57 changes: 23 additions & 34 deletions vcell-core/src/main/java/cbit/vcell/solver/SolverDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,29 +198,28 @@ public final String getName() {
}
}

// useful for debugging, makes easy to know which is the current SolverFeatureSet we're dealing with
public class SolverFeatureSetRegistry {
private static final Map<Object, String> nameRegistry = new LinkedHashMap<>();

public static void registerSolverFeatureSet(Object obj, String name) {
nameRegistry.put(obj, name);
}
public static String getSolverFeatureSetName(Object obj) {
return nameRegistry.get(obj);
}
}
// // useful for debugging, makes easy to know which is the current SolverFeatureSet we're dealing with
// public class SolverFeatureSetRegistry {
// private static final Map<Object, String> nameRegistry = new LinkedHashMap<>();
//
// public static void registerSolverFeatureSet(Object obj, String name) {
// nameRegistry.put(obj, name);
// }
// public static String getSolverFeatureSetName(Object obj) {
// return nameRegistry.get(obj);
// }
// }

/*
* Spatial solvers
*/
public static final SolverFeatureSet SpatialHybridFeatureSet = new SolverFeatureSet (
public static final SolverFeatureSet SpatialHybridFeatureSet = new SolverFeatureSet ("SpatialHybridFeatureSet",
new SolverFeature[] { SolverFeature.Feature_Spatial, SolverFeature.Feature_Hybrid, SolverFeature.Feature_Deterministic },
new SupportedProblemRequirements() { public boolean supports(ProblemRequirements desc) {
return desc.isSpatialHybrid() && !desc.isMovingMembrane(); }},
FiniteVolumeStandalone,50);
static { SolverFeatureSetRegistry.registerSolverFeatureSet(SpatialHybridFeatureSet, "SpatialHybridFeatureSet"); }

public static final SolverFeatureSet SpatialStochasticFeatureSet = new SolverFeatureSet (
public static final SolverFeatureSet SpatialStochasticFeatureSet = new SolverFeatureSet ("SpatialStochasticFeatureSet",
new SolverFeature[] { SolverFeature.Feature_Spatial, SolverFeature.Feature_Stochastic, SolverFeature.Feature_Smoldyn },
new SupportedProblemRequirements() {
public boolean supports(ProblemRequirements desc) {
Expand All @@ -229,30 +228,26 @@ public boolean supports(ProblemRequirements desc) {
}
},
Smoldyn,40);
static { SolverFeatureSetRegistry.registerSolverFeatureSet(SpatialStochasticFeatureSet, "SpatialStochasticFeatureSet"); }

public static final SolverFeatureSet PdeFastSystemFeatureSet = new SolverFeatureSet (
public static final SolverFeatureSet PdeFastSystemFeatureSet = new SolverFeatureSet ("PdeFastSystemFeatureSet",
new SolverFeature[] { SolverFeature.Feature_Spatial, SolverFeature.Feature_Deterministic, SolverFeature.Feature_FastSystem },
new SupportedProblemRequirements() { public boolean supports(ProblemRequirements desc) {
return desc.isSpatial() && !desc.isSpatialHybrid() && desc.hasFastSystems( ) && !desc.isSpatialStoch(); }},
FiniteVolumeStandalone,30);
static { SolverFeatureSetRegistry.registerSolverFeatureSet(PdeFastSystemFeatureSet, "PdeFastSystemFeatureSet"); }

public static final SolverFeatureSet PdeFeatureSetWithDirichletAtMembrane = new SolverFeatureSet(
public static final SolverFeatureSet PdeFeatureSetWithDirichletAtMembrane = new SolverFeatureSet("PdeFeatureSetWithDirichletAtMembrane",
new SolverFeature[] { SolverFeature.Feature_DirichletAtMembraneBoundary },
new SupportedProblemRequirements() { public boolean supports(ProblemRequirements s) {
return s.isSpatial() && !s.isSpatialHybrid( ) && s.hasDirichletAtMembrane() && !s.hasFastSystems() && !s.isSpatialStoch(); }},
Chombo,20);
static { SolverFeatureSetRegistry.registerSolverFeatureSet(PdeFeatureSetWithDirichletAtMembrane, "PdeFeatureSetWithDirichletAtMembrane"); }

public static final SolverFeatureSet PdeFeatureSetWithoutDirichletAtMembrane = new SolverFeatureSet(
public static final SolverFeatureSet PdeFeatureSetWithoutDirichletAtMembrane = new SolverFeatureSet("PdeFeatureSetWithoutDirichletAtMembrane",
new SolverFeature[] { SolverFeature.Feature_Spatial, SolverFeature.Feature_Deterministic },
new SupportedProblemRequirements() { public boolean supports(ProblemRequirements s) {
boolean ret = s.isSpatial() && !s.isSpatialHybrid() && !s.isMovingMembrane() && !s.hasDirichletAtMembrane() && !s.hasFastSystems() && !s.isSpatialStoch() && !s.isLangevin();
return ret;
}},
SundialsPDE,10);
static { SolverFeatureSetRegistry.registerSolverFeatureSet(PdeFeatureSetWithoutDirichletAtMembrane, "PdeFeatureSetWithoutDirichletAtMembrane"); }

// public static final SolverFeatureSet ComsolFeatureSet = new SolverFeatureSet(
// new SolverFeature[] { SolverFeature.Feature_Spatial,SolverFeature.Feature_Deterministic },
Expand All @@ -261,52 +256,46 @@ public boolean supports(ProblemRequirements desc) {
// Comsol,30);
// static { VariableNameRegistry.registerVariable(ComsolFeatureSet, "ComsolFeatureSet"); }

public static final SolverFeatureSet MovingBoundaryFeatureSet = new SolverFeatureSet(
public static final SolverFeatureSet MovingBoundaryFeatureSet = new SolverFeatureSet("MovingBoundaryFeatureSet",
new SolverFeature[] { SolverFeature.Feature_Moving,SolverFeature.Feature_Spatial,SolverFeature.Feature_Deterministic },
new SupportedProblemRequirements() { public boolean supports(ProblemRequirements s) {
boolean ret = s.isSpatial() && !s.isSpatialHybrid() && s.isMovingMembrane() && !s.hasFastSystems() && !s.isSpatialStoch();
return ret; }},
MovingBoundary,30);
static { SolverFeatureSetRegistry.registerSolverFeatureSet(MovingBoundaryFeatureSet, "MovingBoundaryFeatureSet"); }

/*
* rule-based solvers
*/
public static final SolverFeatureSet RulebasedFeatureSet = new SolverFeatureSet (
public static final SolverFeatureSet RulebasedFeatureSet = new SolverFeatureSet ("RulebasedFeatureSet",
new SolverFeature[] { SolverFeature.Feature_NonSpatial, SolverFeature.Feature_Rulebased },
new SupportedProblemRequirements() { public boolean supports(ProblemRequirements desc) { return desc.isRuleBased(); }},
NFSim,100);
static { SolverFeatureSetRegistry.registerSolverFeatureSet(RulebasedFeatureSet, "RulebasedFeatureSet"); }

public static final SolverFeatureSet LangevinFeatureSet = new SolverFeatureSet (
public static final SolverFeatureSet LangevinFeatureSet = new SolverFeatureSet ("LangevinFeatureSet",
new SolverFeature[] { SolverFeature.Feature_Spatial, SolverFeature.Feature_Rulebased, SolverFeature.Feature_Springs },
new SupportedProblemRequirements() { public boolean supports(ProblemRequirements desc) {
return (desc.isLangevin()); }},
Langevin,200);
static { SolverFeatureSetRegistry.registerSolverFeatureSet(LangevinFeatureSet, "LangevinFeatureSet"); }

/*
* Non-spatial solvers
*/
public static final SolverFeatureSet NonSpatialStochasticFeatureSet = new SolverFeatureSet (
public static final SolverFeatureSet NonSpatialStochasticFeatureSet = new SolverFeatureSet ("NonSpatialStochasticFeatureSet",
new SolverFeature[] { SolverFeature.Feature_NonSpatial, SolverFeature.Feature_Stochastic},
new SupportedProblemRequirements() { public boolean supports(ProblemRequirements desc) { return desc.isNonSpatialStoch() && !desc.isRuleBased(); }},
StochGibson,100);
static { SolverFeatureSetRegistry.registerSolverFeatureSet(NonSpatialStochasticFeatureSet, "NonSpatialStochasticFeatureSet"); }

public static final SolverFeatureSet OdeFeatureSet = new SolverFeatureSet(
public static final SolverFeatureSet OdeFeatureSet = new SolverFeatureSet("OdeFeatureSet",
new SolverFeature[] { SolverFeature.Feature_NonSpatial, SolverFeature.Feature_Deterministic},
new SupportedProblemRequirements() { public boolean supports(ProblemRequirements desc) {
return !desc.isSpatial() && !desc.hasFastSystems() && !desc.isNonSpatialStoch() && !desc.isRuleBased(); }},
CombinedSundials,10);
static { SolverFeatureSetRegistry.registerSolverFeatureSet(OdeFeatureSet, "OdeFeatureSet"); }

public static final SolverFeatureSet OdeFastSystemFeatureSet = new SolverFeatureSet(
public static final SolverFeatureSet OdeFastSystemFeatureSet = new SolverFeatureSet("OdeFastSystemFeatureSet",
new SolverFeature[] { SolverFeature.Feature_NonSpatial, SolverFeature.Feature_Deterministic, SolverFeature.Feature_FastSystem},
new SupportedProblemRequirements() { public boolean supports(ProblemRequirements desc) {
return !desc.isSpatial() && desc.hasFastSystems() && !desc.isNonSpatialStoch() && !desc.isRuleBased(); }},
CombinedSundials,10);
static { SolverFeatureSetRegistry.registerSolverFeatureSet(OdeFastSystemFeatureSet, "OdeFastSystemFeatureSet"); }

//this one is not like the others
public static final Collection<SolverFeature> DiscontinutiesFeatures = Arrays.asList(new SolverFeature[]{
Expand Down Expand Up @@ -689,7 +678,7 @@ public static Collection<SolverDescription> getSupportingSolverDescriptions(Prob
ProblemRequirements.Checker.validate(mathDescription);
Collection<SolverDescription> solvers = new HashSet<SolverDescription>( );
for (SolverFeatureSet sfs : SolverFeatureSet.getSets()) {
System.out.println(SolverFeatureSetRegistry.getSolverFeatureSetName(sfs));
System.out.println(sfs.getName());
if (sfs.supports(mathDescription)) {
List<SolverFeature> solverFeatures = sfs.getSolverFeatures();
Collection<SolverDescription> solverDescriptions = getSolverDescriptions(solverFeatures);
Expand Down
15 changes: 10 additions & 5 deletions vcell-core/src/main/java/cbit/vcell/solver/SolverFeatureSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//public class SolverFeatureSet extends ArrayList<SolverFeature> {
public class SolverFeatureSet {

private String name;
private ArrayList<SolverFeature> solverFeatures = new ArrayList<SolverFeature>();
private final SupportedProblemRequirements supportedProblemRequirements;
private final SolverDescription defaultSolver;
Expand All @@ -26,7 +26,8 @@ public static Collection<SolverFeatureSet> getSets( ) {
return sets;
}

private SolverFeatureSet(SupportedProblemRequirements supportedProblemRequirements, SolverDescription defaultExecutable, int priority) {
private SolverFeatureSet(String name, SupportedProblemRequirements supportedProblemRequirements, SolverDescription defaultExecutable, int priority) {
this.name = name;
this.supportedProblemRequirements = supportedProblemRequirements;
this.defaultSolver = defaultExecutable;
this.solverPriority = priority;
Expand All @@ -36,15 +37,19 @@ private SolverFeatureSet(SupportedProblemRequirements supportedProblemRequiremen
/**
* @param defaultExecutable may be null
*/
public SolverFeatureSet(SolverFeature[] solverFeatures,
public SolverFeatureSet(String name, SolverFeature[] solverFeatures,
SupportedProblemRequirements supportedProblemRequirements, SolverDescription defaultExecutable,
int solverPriority) {
this(supportedProblemRequirements,defaultExecutable, solverPriority);
this(name, supportedProblemRequirements,defaultExecutable, solverPriority);
this.solverFeatures.addAll(Arrays.asList(solverFeatures));
}


public List<SolverFeature> getSolverFeatures(){
public String getName() {
return name;
}

public List<SolverFeature> getSolverFeatures() {
return Collections.unmodifiableList(solverFeatures);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,9 @@ public String getVCML(){
buffer.append(movingBoundarySolverOptions.getVCML() + "\n");
}

buffer.append(VCML.SolverTaskDescriptionNumTrials + " " + getNumTrials() + "\n");
if(getNumTrials() == 1) {
buffer.append(VCML.SolverTaskDescriptionNumTrials + " " + getNumTrials() + "\n");
}

buffer.append(VCML.EndBlock + "\n");

Expand Down

0 comments on commit 70e0184

Please sign in to comment.