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

Miscellaneous fixes for headless legacy #362

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Adds a steps argument for gaml headless mode
  • Loading branch information
lesquoyb committed Oct 30, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 3eff4736550a0c51a1b1b17cbfa951478c500754
12 changes: 9 additions & 3 deletions gama.headless/src/gama/headless/runtime/HeadlessApplication.java
Original file line number Diff line number Diff line change
@@ -121,6 +121,9 @@ private static Injector configureInjector() {
/** The Constant THREAD_PARAMETER. */
final public static String THREAD_PARAMETER = "-hpc";

/** The Constant THREAD_PARAMETER. */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ Getting worse: Overall Code Complexity
The mean cyclomatic complexity increases from 4.79 to 5.00, threshold = 4

final public static String STEPS_PARAMETER = "-steps";

/** The Constant PING_INTERVAL. */
final public static String PING_INTERVAL = "-ping_interval";

@@ -667,14 +670,17 @@ public void runBatchSimulation(final String experimentName, final String pathToM
public void runGamlSimulation(final List<String> args)
throws IOException, GamaCompilationFailedException, InterruptedException {


final String argExperimentName = args.get(args.size() - 3);
final String argGamlFile = args.get(args.size() - 2);
final String argOutDir = args.get(args.size() - 1);
final Integer numberOfSteps = args.contains(STEPS_PARAMETER) ? Integer.parseInt(after(args, STEPS_PARAMETER)) : null;
final Integer numberOfCores = args.contains(THREAD_PARAMETER) ? Integer.parseInt(after(args, THREAD_PARAMETER)) : null;

assertIsAModelFile(argGamlFile);

Integer numberOfCores =
args.contains(THREAD_PARAMETER) ? Integer.parseInt(after(args, THREAD_PARAMETER)) : null;
final List<IExperimentJob> jb = ExperimentationPlanFactory.buildExperiment(argGamlFile, numberOfCores);
final List<IExperimentJob> jb = ExperimentationPlanFactory.buildExperiment(argGamlFile,numberOfSteps, numberOfCores);

ExperimentJob selectedJob = null;
for (final IExperimentJob j : jb) {
if (j.getExperimentName().equals(argExperimentName)) {
Original file line number Diff line number Diff line change
@@ -158,17 +158,17 @@ public class ExperimentationPlanFactory {
* @param modelFileName
* the model file name
* @param numberOfCores
* the number of cores passed throuhg the '-hpc' parameter. If null, means that '-hpc' is not set
* the number of cores passed through the '-hpc' parameter. If null, means that '-hpc' is not set
* @return the list
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws GamaHeadlessException
* the gama headless exception
*/
public static List<IExperimentJob> buildExperiment(final String modelFileName, final Integer numberOfCores)
public static List<IExperimentJob> buildExperiment(final String modelFileName, final Integer numberOfSteps, final Integer numberOfCores)
throws IOException, GamaCompilationFailedException {
final long[] seeds = { DEFAULT_SEED };
return JobListFactory.constructAllJobs(modelFileName, seeds, DEFAULT_FINAL_STEP, numberOfCores);
return JobListFactory.constructAllJobs(modelFileName, seeds, numberOfSteps == null ? DEFAULT_FINAL_STEP : numberOfSteps, numberOfCores);
}

/**
@@ -184,7 +184,7 @@ public static List<IExperimentJob> buildExperiment(final String modelFileName, f
*/
public static List<IExperimentJob> buildExperiment(final String modelFileName)
throws IOException, GamaCompilationFailedException {
return buildExperiment(modelFileName, null);
return buildExperiment(modelFileName,null, null);
}

/**