Skip to content

Commit

Permalink
Merge pull request #1413 from virtualcell/dan-ss-random-seed2
Browse files Browse the repository at this point in the history
Dan ss random seed2
  • Loading branch information
danv61 authored Jan 14, 2025
2 parents 49a20b3 + 54968af commit f4621ef
Showing 1 changed file with 49 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.vcell.solver.langevin;

import java.math.BigInteger;
import java.util.*;

import cbit.vcell.geometry.AnalyticSubVolume;
Expand Down Expand Up @@ -73,6 +74,7 @@ public class LangevinLngvWriter {
public final static String SYSTEM_ANNOTATION = "SYSTEM ANNOTATIONS";
public final static String MOLECULE_ANNOTATIONS = "MOLECULE ANNOTATIONS";
public final static String REACTION_ANNOTATIONS = "REACTION ANNOTATIONS";
public final static String SIMULATION_OPTIONS = "SIMULATION OPTIONS";

public final static String DEFAULT_FOLDER = "Default Folder";
private String systemName; // The system name (same as the file name, usually)
Expand Down Expand Up @@ -244,11 +246,16 @@ public static String writeLangevinLngv(Simulation simulation, long randomSeed) t
// writeReactionAnnotations(sb);
sb.append("\n");

/*
TODO: The following are being produced when the simulation is created, and are being updated as simulations run (I think)
from C:\TEMP\springsalad-new\spring3reactions\spring3reactions_SIMULATIONS\Simulation0_SIM_FOLDER\Simulation0_SIM.txt

*** SIMULATION STATE ***
/* ****** WRITE THE SIMULATION OPTIONS *********************/
sb.append("*** " + SIMULATION_OPTIONS + " ***");
sb.append("\n");
sb.append("\n");
writeSimulationOptions(simulation, sb);
sb.append("\n");

/*
// TODO: SIMULATION STATE produced by the solver, will be used in ClusterAnalyzer to postprocess run results
Runs: 6
Parallel: true
Expand All @@ -258,6 +265,9 @@ public static String writeLangevinLngv(Simulation simulation, long randomSeed) t
HasResults: false
RunOnCluster: false
TODO: The following are being produced when the simulation is created, and are being updated as simulations run (I think)
from C:\TEMP\springsalad-new\spring3reactions\spring3reactions_SIMULATIONS\Simulation0_SIM_FOLDER\Simulation0_SIM.txt
*** PROCESSOR FILES ***
MoleculeAverages: 'null'
Expand Down Expand Up @@ -959,6 +969,41 @@ private static void writeSpeciesInfo(StringBuilder sb) {
return;
}

/*
* We provide the SIMULATION OPTIONS block as part of the input to the solver
* The only important field really is the RandomSeed, which is optional, the rest are not needed by the
* current solver implementation
*
* There is a related SIMULATION STATE block which is generated by the solver when it finishes running
* Then the SpringSaLaD client is parsing it and will use the Runs field in the ClusterAnalyzer module
* for analyzing the results (of one or multiple runs). We'll probably do something similar server-side in
* the postprocessing module
*/
public static void writeSimulationOptions(Simulation simulation, StringBuilder sb) {
SolverTaskDescription std = simulation.getSolverTaskDescription();
LangevinSimulationOptions lso = std.getLangevinSimulationOptions();

int numTrials = std.getNumTrials();
BigInteger randomSeed = lso.getRandomSeed();
int simultaneousRuns = lso.getNumOfParallelLocalRuns();

// TODO: do not delete this, until we decide on how much info the solver needs
// These are not needed but may be nice to have in the future, makes the solver instance more aware
// sb.append("Runs: " + numTrials); // the SpringSaLaD client parser expects this to be the first line in block
// sb.append("\n");
// sb.append("Parallel: " + (simultaneousRuns == 1 ? "true" : "false"));
// sb.append("\n");
// sb.append("SimultaneousRuns: " + simultaneousRuns); // this is always 1 on local and quota dependent on server
// sb.append("\n");

// if we don't specify a random seed the solver will do its thing like in the past (use system time in ms)
if(randomSeed != null) {
sb.append("RandomSeed: " + randomSeed);
sb.append("\n");
}

}

public static void writeSpatialInformation(GeometrySpec geometrySpec, Simulation simulation, StringBuilder sb) { // SpringSaLaD exporting the time information
if (geometrySpec.getDimension() != 3) {
throw new RuntimeException("SpringSaLaD requires 3D geometry");
Expand Down

0 comments on commit f4621ef

Please sign in to comment.