From 675fe36bf2826df95c606360d26b7a3994e75351 Mon Sep 17 00:00:00 2001 From: Dan Vasilescu Date: Fri, 27 Dec 2024 15:31:52 -0500 Subject: [PATCH 1/2] Provide explicit random seed and other options to the solver. See related code in the langevinNoVis1 project --- .../solver/langevin/LangevinLngvWriter.java | 64 +++++++++++++++---- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/vcell-core/src/main/java/org/vcell/solver/langevin/LangevinLngvWriter.java b/vcell-core/src/main/java/org/vcell/solver/langevin/LangevinLngvWriter.java index a127b75eeb..4a55ba124d 100644 --- a/vcell-core/src/main/java/org/vcell/solver/langevin/LangevinLngvWriter.java +++ b/vcell-core/src/main/java/org/vcell/solver/langevin/LangevinLngvWriter.java @@ -1,5 +1,6 @@ package org.vcell.solver.langevin; +import java.math.BigInteger; import java.util.*; import cbit.vcell.geometry.AnalyticSubVolume; @@ -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) @@ -244,19 +246,26 @@ 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 STATE *********************/ + sb.append("*** " + SIMULATION_OPTIONS + " ***"); + sb.append("\n"); + sb.append("\n"); + writeSimulationOptions(simulation, sb); + sb.append("\n"); + - Runs: 6 - Parallel: true - SimultaneousRuns: 3 - Aborted: false - IsRunning: false - HasResults: false - RunOnCluster: false +// Runs: 6 +// Parallel: true +// SimultaneousRuns: 3 +// Aborted: false +// IsRunning: false +// 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 *** @@ -959,6 +968,39 @@ 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(); + + 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"); + + // we place the (optional) random seed entry at the end of the block + if(randomSeed != null) { // if we don't specify a random seed the solver will do its thing like in the past + 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"); From 75130bdde34737eeb14dc52dcbb09855545de4da Mon Sep 17 00:00:00 2001 From: Dan Vasilescu Date: Mon, 6 Jan 2025 15:33:02 -0500 Subject: [PATCH 2/2] Provide explicit random seed and other options to the solver. See related code in the langevinNoVis1 project --- .../solver/langevin/LangevinLngvWriter.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/vcell-core/src/main/java/org/vcell/solver/langevin/LangevinLngvWriter.java b/vcell-core/src/main/java/org/vcell/solver/langevin/LangevinLngvWriter.java index 4a55ba124d..49366ffb73 100644 --- a/vcell-core/src/main/java/org/vcell/solver/langevin/LangevinLngvWriter.java +++ b/vcell-core/src/main/java/org/vcell/solver/langevin/LangevinLngvWriter.java @@ -247,23 +247,24 @@ public static String writeLangevinLngv(Simulation simulation, long randomSeed) t sb.append("\n"); - /* ****** WRITE THE 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 -// SimultaneousRuns: 3 -// Aborted: false -// IsRunning: false -// HasResults: false -// RunOnCluster: false + Runs: 6 + Parallel: true + SimultaneousRuns: 3 + Aborted: false + IsRunning: false + 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 @@ -986,15 +987,17 @@ public static void writeSimulationOptions(Simulation simulation, StringBuilder s BigInteger randomSeed = lso.getRandomSeed(); int simultaneousRuns = lso.getNumOfParallelLocalRuns(); - 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"); + // 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"); - // we place the (optional) random seed entry at the end of the block - if(randomSeed != null) { // if we don't specify a random seed the solver will do its thing like in the past + // 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"); }