Add File
When you create a new application in either Python or R Akumen will take you to the code editor screen. There are Five main areas to the Code editor screen:
- Application/Study Actions – Located at the top left-hand side are applications which show property settings.
- Workflow Tabs – Build, Research and Report tabs all help generate and use your application.
- In Build you will construct your application.
- In Research you can create and manage all your scenarios.
- In Report you visualize your results from all scenarios.
- In Data we can view/search output values from the model. (Only present in code editor based applications).
- Code Editor Actions – above the file view, allows you to upload scripts and models.
- File View – On the left-hand side of the screen is a tree structure which gives you a way to organize your scripts and models.
- Code Editor Screen – This is the main build area where you can write your models, or where the code is placed when you upload your models.
When Akumen first creates a Py model, it automatically creates an initial main.py file.
- Click on the main.r file.
- Delete the sample code in main.r.
- A * will appear next to the file.
- Enter the following into the code editor:
akumen <- function(start_day, periods,...) {
# Parameters:
#- Input: start_day [datetime]
#- Input: periods [float]
return ()
}
The above will start our model off by allowing us to set a start date and enter the amount of time periods we will be using in the model.
- Now that we have entered the above code, save the changes to your file.
- Now go to the Research Tab at the top right of the screen.
- The start_day field is a date selector cell, in the row labelled Application Level Parameters select a start date.
Info
Assigning a parameter to the Application Level Parameters applies the assigned value to all scenarios across the entire application. Assigning a value to the Study Level Parameters applies the assigned value to all scenarios within a single study. Any value in either of these cells will not be displayed in the scenarios within the studies.
- The periods field is a numeric field, enter the value 12.
In order for Akumen to execute your R code, we will need to specify the main entry point for Akumen, which means we will need to define an ‘akumen’ function. This function is the main entry point for your code and must exist in the execution file. The akumen function will require the form: akumen <- function(first, second, ...) {}
The readme file contains handy hints on information on syntax for creating the main.r file. This includes how to define variables that are used in the research grid