doc:batch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:batch [2021/07/16 09:49] thomasdoc:batch [2022/06/08 12:04] (current) – [Batch Optimizations] thomas
Line 1: Line 1:
 ====== Batch Optimization using the Command Line ====== ====== Batch Optimization using the Command Line ======
-If you need to automate multiple optimizations, you can use the ''sconecmd'', the SCONE command line interface. By default, it is located in ''C:\Program Files\SCONE\sconecmd.exe'', and can be used as follows:+==== The SCONE Command-line Interface ==== 
 +If you need to automate multiple optimizations, you can use the ''sconecmd'', the SCONE command-line interface. By default, it is located in ''C:\Program Files\SCONE\sconecmd.exe'', and can be used as follows:
 <code> <code>
-"C:\Program Files\SCONE\sconecmd.exe" -o "path_to_your_scone_file.scone"+"C:\Program Files\SCONE\sconecmd.exe" -o "your_scenario.scone"
 </code> </code>
 +The ''-o'' command line starts an optimization of a scenario. The ''-e'' command line switch can be used to evaluate a ''.scone'' or a ''.par'' file.
  
-You can use it to vary any setting in your .scone scenarioby specifying it in the command:+==== Changing Scenario Parameters ==== 
 +You can change any parameter in your .scone scenario by specifying it in the command line, for example:
 <code> <code>
-"C:\Program Files\SCONE\sconecmd.exe-o "your_scone_file.scone" CmaOptimizer.random_seed=10 +sconecmd.exe -o "scenario.scone" CmaOptimizer.random_seed=10
-"C:\Program Files\SCONE\sconecmd.exe" -o "your_scone_file.scone" CmaOptimizer.SimulationObjective.ModelOpenSim3.model_file=data/test_model.osim+
 </code> </code>
  
 +You can also **access settings by index**, which is useful for settings that are not uniquely identifiable by name:
 +<code>
 +sconecmd.exe -o "scenario.scone" CmaOptimizer.SimulationObjective.CompositeController.#1.value=10
 +</code>
 +This sets the ''value'' parameter for first child of ''CompositeController''. The second, third, etc. element can be accessed via ''#2'', ''#3'', etc.
 +
 +==== Batch Optimizations ====
 +For batch processing, you can create a Windows ''.bat'' file which contains multiple commands:
 +<code>
 +set SCONECMD="C:\Program Files\SCONE\bin\sconecmd.exe"
 +%SCONECMD% -o "scenario.scone" CmaOptimizer.random_seed=10
 +%SCONECMD% -o "scenario.scone" CmaOptimizer.SimulationObjective.ModelOpenSim3.model_file=data/model.osim
 +</code>
 +
 +If you wish to run multiple optimizations in parallel, you can do so by prefixing your command with ''start''. The first argument after start ("SCONE") is the title of the console window that is spawned.
 +<code>
 +set SCONECMD="C:\Program Files\SCONE\bin\sconecmd.exe"
 +start "SCONE" %SCONECMD% -o "scenario.scone" CmaOptimizer.random_seed=10
 +start "SCONE" %SCONECMD% -o "scenario.scone" CmaOptimizer.SimulationObjective.ModelOpenSim3.model_file=data/model.osim
 +</code>
 +
 +If you wish to **optimize all scenarios in a folder**, you can use the following .bat script to optimize all .scone scenarios in the current directory:
 +<code>
 +set SCONECMD="C:\Program Files\SCONE\bin\sconecmd.exe"
 +for %%f in (*.scone) do (
 + start "%%f" %SCONECMD% -o "%%f"
 + timeout 1
 +)
 +</code>