How To: Load CIN files into Vensim
A popular feature in Vensim is the use of Change Input (CIN) files to load initial values and lookup functions. With Epicenter, you may specify CIN files to be automatically loaded when your model is initialized.
CIN files are different than other types of external data that are loaded into Vensim models (e.g. VDF or Excel data files). This is because the list of CIN files is specified dynamically at run time. This approach is in contrast to loading data from Excel, which must be hard-coded into the Vensim model using one of several GET DIRECT functions. (read more about loading data from external files in Vensim).
To use CIN files with your Vensim model:
Step 1: First, upload your model and one or more CIN files into the "Model" folder for your project in Epicenter.
Important. Be sure there are no CIN files listed in the saved Vensim model. Check that the
"Load Changes from..." text box is empty after choosing "Simulate..." and going to the "Changes" tab. Otherwise, this list of CIN files saved with the model will be automatically loaded.
Step 2: If you haven't already, create your interface using the Interface Builder, Flow.js, or Epicenter.js.
Step 3: CIN file support in Epicenter requires the use of Epicenter.js 2.5.0 or later. Look in your interface files and make sure all script tags loading this library use the correct version.
<script src="https://forio.com/tools/js-libs/2.9.1/epicenter.min.js"></script>
Step 4: Specify an array of one or more CIN files in the run configuration. The specifics of how to do this will depend on how your interface is built.
Flow.js: For Flow.js simulations, you will need to add an array with a list of CIN files to the model initialization. Specifically, include an entry "cinFiles" under the "run" property. For example:
Flow.initialize({
channel: {
run: {
model: 'supply-chain-game.vmf',
cinFiles: ['inputs1.cin']
}
}
})
You can also list multiple CIN files.
Flow.initialize({
channel: {
run: {
model: 'supply-chain-game.vmf',
cinFiles: ['inputs1.cin', 'inputs2.cin']
}
}
})
Epicenter.js: For simulations developed with Javascript using Epicenter.js, include a similar "cinFiles" line item under "run" when initializing a RunManager
var rm = new F.manager.RunManager({
run: {
model: 'supply-chain-model.vmf',
cinFiles: ['inputs1.cin']
}
});
You can also specify the cinFiles as a property when creating a run with the RunService. Often, you will be loading the list of cin files dynamically. For example, you might allow the user to choose different model scenarios to run from a drop down list, each loading a different cin file.
var rs = new F.service.Run();
rs.create({model:'supply_chain_game.vmf', cinFiles: ['inputs1.cin']);
Interface Builder: You can also specify an array of CIN files with simulations developed using the Interface Builder. Find the following code in the file "index.html".
window.FLOW_CONFIG = {
channel: {
}
};
Change this as follows to specify the array of CIN files.
window.FLOW_CONFIG = {
channel: {
defaults: {
run: {
cinFiles: ['inputs1.cin']
}
}
}
};