Reading Parameters row by row from excel for Anylogic Experiment - excel

I want to run an Anylogic Parameter experiment, and I want the parameters to be read continuously from an excel file such that each row of excel data corresponds to parameters of one run. Likewise I want it to run as many times as rows of parameters in excel. I am able to read one row data using ExcelControlName.getCellNumericValue("ExcelSheetName", RowNumber, ColNumber) but how do I set it up such that it automatically runs multiple times by running parameters from all rows.

in your simulation model, create a parameter called row, and this will be the ONLY parameter that changes in your parameter variation experiment... then you will transform your parameters in your simulation to variables, and each variable will read the excel file as follows>
ExcelControlName.getCellNumericValue("ExcelSheetName", row, ColNumber)
where row, is the parameter that changes in your parameter variation experiment, and colNumber is the column representing the particular variable that you want to assess.

A very useful question.
One option is to make use of the Simulation Object and not let the model skip the experiment and run the model.
This will just give you some more control over your model execution and you can use some of the before and after simulation run code.
Image the following super-simple model
I have a single parameter and an event that traces the parameter and then stops the simulation.
Then on Experiment I have an Excel object, and a variable that is linked to the parameters on main, and a button that just calls run()
The excel file has some simple data in
Now on the experiment's Java section you only need to add the following code.
This ensures that the variable is updated with the correct data based on the run count, and that when you stop the model it will call the run function again if there is more values in the Excel sheet to load.
Note that the row index in Excel starts at 1 and that we have a header for our data so we want to start at row 2, hence I added 2 + getExperiment().getRunCount()
If you run this simple model you will see in the Console printed out the values from the Excel file.
10.0
20.0
30.0

Related

How to split a Pandas dataframe into multiple csvs according to when the value of a column changes

So, I have a dataframe with 3D point cloud data (X,Y,Z,Color):
dataframe sample
Basically, I need to group the data according to the color column (which takes values of 0,0.5 and 1). However, I don't need an overall grouping (this is easy). I need it to create new dataframes every time the value changes. That is, I'd like a new dataframe for every set of rows that are followed by and preceded by 5 zeros (because single zeros are sometimes erroneously present in chunks of data that I'm interested in).
Basically, the zero values (black) are meaningless for me; I'm only interested in the 0.5 (red) and 1 values (green). What I want to accomplish is to segment the original point cloud into smaller clusters that I can then visualize. I hope this is clear. I can't seem to find answers to my question anywhere.
First of all, you should understand the for loop well. Python is a great programming language for using the code of any library inside functions and loops. Let's say you have a dataset and you want to navigate and control column a. First, let's start the loop with the "for i in dataset:" code. When you move to the bottom line, you have now specified the criteria you want with the code if "i[a] > 0.5:" in each for loop. Now if the value is greater than 0.5, you can write the necessary codes to create a new dataset with all the data of the row you are in. In terms of personal training, I did not write ready-made code.

VBA Scenario Testing in a financial model

So I'm new to VBA and trying to automate my financial models. I've got this large complex stock valuation model on excel that reads either string bear, bull, or base from a single cell that has a dropdown that has the options of bear, bull, or base. The model will use different inputs depending on if the user chooses the strings bear, bull, or base, and the model will output different values of the stock respectively. In a separate sheet, I'm trying to display, in 3 separate cells, the output of the model (the value of the stock) in the bear, bull, and base case respectively. I could just make 3 models; a bear, bull, and base case, but I thought that might be too bulky, and I just want 1 variable model, instead of 3 fixed models. I'm wondering if VBA allows for a "scenario" type of ability in which it sets a specific cell to a hypothetical value and then takes the value of another cell, without actually modifying my model.
I think I understand what you want -- but it is still unclear. Perhaps provide an example?
One way I'd do it would be to have a fourth dynamic model. This extra model is based on the hypothetical scenarios (e.g. another column for Bear/Bull/Base for each stock -- we can call this extra column BBB2, and the original one with drop down menus for the user BBB1). The fourth model is based only on data from BBB2.
By default when the sheet is opened, BBB2 = BBB1. When a user changes BBB1, BBB2 gets updated. Then, I'd add a function to change everything in BBB2 to bull or base or bear. From there you could manually change a few stocks and see the results in the fourth model.

QBO Task user-defined fields in Excel

I am using pulling existing Task data into an Excel spreadsheet to use with a Score. I have an Excel named range executing ?=ImportForm/ListDeep?TargetObject=Loan&TargetObjectID={LoanID}.
My tasks include several user-defined fields, but the data renders in Excel lumps them together in a single column called XmlData. How can I use these values in Excel formulas?
The ImportForm/ExecuteFlat method will normalize user-defined fields (that that, elements stored in ImportForm.XmlData. ExecuteFlat requires an Operation parameter, which it will execute before normalizing the results.
For your example, call:
?=ImportForm/ExecuteFlat?Operation=ListDeep&TargetObject=Loan&TargetObjectID={LoanID}
More generically, assume that ImportForm/Search?ID=1 returns:
<ImportFormItem>
<ImportFormID>1</ImportFormID>
...
<XmlData>
<ImportFormXml>
<Foo>Bar</Foo>
<Hello>World</Hello>
</ImportFormXml>
</XmlData>
</ImportFormItem>
Calling ImportForm/ExecuteFlat?Operation=Search?ID=1 would return:
<ImportFormItem>
<ImportFormID>1</ImportFormID>
...
<Foo>Bar</Foo>
<Hello>World</Hello>
</ImportFormItem>

Requesting help editing a formula in a TM1 worksheet

The said TM1 worksheet uses the DBRW formula to write values that users enter, to a cube, and also uses the same to fetch the value and display it in the worksheet. The values in the cube consist of movie codes such as 7500023. This movie code can be mapped to a movie title in a dimension DIM. It is to be noted that this movie code and the movie title are both aliases of the principal name used in the dimension, which runs along like 0007500023 (The movie code with zeroes preceding). I'd like the movie titles to be displayed in the worksheet instead of the movie codes.
I tried using the SUBNM function, but it opens up a subset editor and also doesn't write values to the cube like DBRW. So, that's ruled out.
The DBRA function seemed perfect when it came to fetching the movie titles from the dimension DIM. But this doesn't write the values to the cube.
Is there any way I can combine the DBRA and the DBRW function in a formula or is there an alternative function for this purpose?
I will add an extra column which will extract the alias = DBRA.
And then I will base your IF statement on the new column.
Otherwise, if you don't need the code, then why not use the alias in the first place? Export data with the alias on. Then you don't even need to retrieve the alias, because it's already there.
It just doesn't make sense to put them both in one formula.
When you recalculate - excel assess the formula once.
But you're expecting it to assess it multiple times. (hence the circular reference)

Lone reference error when calling INDEX with RANDBETWEEN in Excel

I'm trying to do some bootstrapping with a data set in Excel with the formula =INDEX($H$2:$H$5057,RANDBETWEEN(2,5057)), where my original data set in is column H. It seems to work most of the time, but there is always approximately one cell that outputs a reference error. Does anyone know why this happens, or how to avoid including that one cell? I'm trying to generate a histogram from this data, and FREQUENCY does not play nice with an array with an error in it.
Please try:
=INDEX($H$2:$H$5057,RANDBETWEEN(1,5056))
=RANDBETWEEN(2,5057) returns a reasonably arbitrary value of 2 or any integer up to and including 5057. Used as above this specifies the position in the chosen array (H2:H5057) - that only has 5056 elements, so one problem would be when RANDBETWEEN hits on 5057. Much easier to observe with just H2:H4 and RANDBETWEEN(2,4).

Resources