The Analytica Decision Engine Tutorial
ADE User Guide > The Analytica Decision Engine Tutorial
This tutorial shows you how to use the Analytica Decision Engine (ADE) from within a Visual Basic program.
ADE User Guide > The Analytica Decision Engine Tutorial
This tutorial shows you how to use the Analytica Decision Engine (ADE) from within a Visual Basic program.
Your first ADE application
First let’s write a simple ADE application from scratch, just to be sure that everything is set up correctly. Follow these steps:
- Bring up Visual Studio.NET.
- Select New Project, then select the Project Type “Visual Basic Projects” and the template “Console Application.” Select a project name, e.g., “FirstADEtry,” and an appropriate folder location.
- From the Project menu, select Add Reference and select the COM tab in the dialog. Find and select Analytica Decision Engine Local Server 4.6 (Ade.exe) and click OK.
- Note: If you have installed ADE 64-bit and do not have ADE 32-bit installed, Visual Studio may not show Analytica Decision Engine Local Server 4.6, even though it is properly installed. This occurs because Visual Studio itself is a 32-bit application. If this happens, select the Browse tab on the Add Reference dialog, navigate to the ADE install directory (usually C:\Program Files\Lumina\ADE 4.6), and select ADE64.exe.
- Note: If you cannot find this entry in the list of COM servers, then ADE 4.6 is not properly installed. See Installation of ADE for instruction on how to install ADE before reading further.
- Add to the Module1 class as follows:
- Imports ADE
- Module Module1
- Public ADE As CAEngine
- Sub Main()
- Dim FileName, ModelName As String
- FileName = "C:\Program Files\Lumina\Analytica 4.6"
- FileName &= "\Example Models\Tutorial Models\Car Cost.ana"
- ADE = New CAEngine
- ADE.MonitorProcess( System.Diagnostics.Process.GetCurrentProcess().Id )
- ModelName = ADE.OpenModel(FileName)
- If ModelName = "" Then
- Console.Write(FileName & " not found")
- Else
- Console.Write("Congratulations on opening ")
- Console.WriteLine(ModelName)
- Console.WriteLine("Press 'enter' to exit")
- Console.ReadLine()
- End If
- End Sub
- End Module
- Now just run the program. If your program prints “Congratulations on opening Carcosts” you have just successfully written your first ADE program.
This first program did the following:
- Created a CAEngine automation object called ADE (using new CAEngine).
- Opened an Analytica model (using the OpenModel method of CAEngine).
- Displayed the name of the model (the return value of OpenModel).
We go into the details of these and other functions in the next section.
What's next?
We will not attempt to explain all of the features of ADE in this tutorial. These are described in the following chapters of this guide. Here, we give you the background to explore the more advanced features of ADE on your own.
From this point, we use the example model called Txc.ana. You can find Txc.ana in the Risk Analysis folder under the Example Models folder installed with Analytica. If you cannot find it, or if you opted not to install the examples when you originally installed Analytica, there is a copy in the Examples\Tutorial.NET folder in the directory where you installed ADE.
The Txc model demonstrates risk-benefit analysis of reducing the emissions of the fictitious air pollutant TXC. Please open the Txc model with Analytica to see how it works.
The example Visual Basic.NET program called TestTxc in your Ade Examples\Tutorial.NET folder shows many aspects of ADE. This program creates an ADE automation object, opens the Txc.ana model with this object, gets the definition of the Population Exposed variable, evaluates the Total Cost variable, prints out the result of the Total cost variable as a table by getting at the individual components of the table, and changes the definition of the Population Exposed variable. It then gets the result of the Total cost variable again, to see what effect the change of definition for Population Exposed had on the Total Cost variable. If things are set up properly, TestTxc displays the window shown in “Text Txc window”.
The application displays the definition of the Population Exposed variable ("Normal (30M, 3M)"), and the table associated with Total Cost, based on the definition of Population Exposed. You can change the definition of Population Exposed by selecting File > Change Population Exposed from the main menu and seeing the effect this has on the Total Cost table.
Distinguishing title from identifier
Creating an ADE object from within Visual Basic
COM vs. Automation interface
Monitoring the Process
Opening a model with ADE
Retrieving objects from the Analytica model
Getting object attributes
Evaluating objects and retrieving results
Getting the index elements of a table
Getting information from CATable and CAIndex
Controlling formats of atomic values
Other ways to access tables
Modifying objects
Graphing with ADE
Conclusion
| Installation of ADE << Previous | ADE User Guide | Next >> Using the Analytica Decision Engine Server |
Enable comment auto-refresher