Aug 04, 2023

Public workspaceA Simple Exploration of Simulated Annealing: Protocol

  • 1Carnegie Mellon University
Icon indicating open access to content
QR code linking to this content
Protocol CitationChasz Griego 2023. A Simple Exploration of Simulated Annealing: Protocol. protocols.io https://dx.doi.org/10.17504/protocols.io.eq2lyj77plx9/v1
Manuscript citation:
https://doi.org/10.24433/CO.0015684.v1
License: This is an open access protocol distributed under the terms of the Creative Commons Attribution License,  which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited
Protocol status: Working
We use this protocol and it's working
Created: August 03, 2023
Last Modified: August 04, 2023
Protocol Integer ID: 85947
Keywords: algorithm, simulation, model, simulated annealing, monte carlo, boltzmann, python, numpy, reproducibility, open science
Abstract
This protocol describes technical steps to understand the computational environment for A Simple Exploration of Simulated Annealing hosted on Code Ocean.
Safety warnings
Code can take a considerable amount of time. Be cautious when modifying.
Reproducing the Data Analysis
Reproducing the Data Analysis
Access the capsule for this project at Code Ocean. Select "Edit Capsule" to work with your own copy.






The analysis was completed with Python in a Jupyter Notebook. The following notebook is found in the code folder in the file manager:
analysis.ipynb


Details about the computational environment, including the versions of Python, Jupyter, and other libraries are found in the environment section of the file manager, which contains a Dockerfile.
Data for the analysis is found in separate folders in the data folder in the file manager:

  • grid_sample: A .npy file of the sample grid used in simulated annealing
  • separated_grids: Multiple .npy files for every grid resulting from a simulation
  • simulation_data: Multiple .csv files with run details at every iteration of a simulation


To execute analysis.ipynb, select "Reproducible Run"
Computational step
Once the reproducible run is complete, the resulting figures, an HTML copy of the executed analysis.ipynb, and a run output log are stored in the results section found in the file manager.
Running Additional Simulations and Producing New Data
Running Additional Simulations and Producing New Data
Each simulation can be run again, with the same sample grid, by executing the following Jupyter Notebook found in the code folder:

production.ipynb

WARNING: Running production.ipynb will overwrite all of the data in each subdirectory of data.
Critical
Copy each subdirectory in a new folder with a title such as "original" or something that is more descriptive. Do this before each subsequent run of production.ipynb. Update file paths in analysis.ipynb if you wish to analyze data that was moved.
Modify line 10 of the run file inside the code section to select production.ipynb to run in a reproducible run:
    --execute production.ipynb \

Select "Reproducible Run" to run additional simulations and produce new data.
Computational step
To reanalyze the new data, modify line 10 of the run file to select analysis.ipynb.

Note
WARNING: Any files that are in results may be overwritten. Move these files into a new folder before proceeding.

Critical
Select "Reproducible Run" to execute a new analysis.
There are various ways to alter parameters to run additional simulations:
Step case

Changing parameters to create a new sample grid
3 steps

There are several parameters that can be changed in production.ipynb to produce a new sample grid:
  • rows: number of rows in the grid
  • cols: number of columns in the grid
  • percentage: composition of 1's in the randomly generated grid of mixed 1's and 0's
  • seed: defines the random number seed used to generate the random mixture of 1's and 0's
Change any of these parameters (individually or in combination), and after running production.ipynb, a new .npy file will be generated in data/grid_sample.


Note
WARNING: If the seed is not changed, the .npy file for the previous sample will likely be overwritten. Make sure to relocate or rename these files before running.

Critical
Repeat all steps in "Running Additional Simulations and Producing New Data" to produce new data from the new sample.
Protocol references
https://doi.org/10.24433/CO.0015684.v1