Calculate Results from a Model

In Synthesis applications, models can represent the reliability of a component, the duration of a task, the expected cost of a repair and many other characteristics. In this tutorial, you'll learn how to calculate some useful metrics from models.

Prerequisites
Before you begin:


 * Create a Synthesis repository for testing purposes. Perform a simple analysis (can use Weibull++ or ALTA) and then publish a model of the analysis. You'll want to use a published model with this tutorial so you can perform confidence bounds calculations.


 * Note the published model's object ID number. You will use the ID# to retrieve the model from the database. (To display the object IDs, choose File > Application Setup, then click Other under the Synthesis Settings heading in the navigation panel. Select the Display Object IDs check box. The object ID of the model is displayed in the Resource Manager.)

Tutorial: Calculate Results from a Model
The following example demonstrates how to obtain calculated results from a model resource. A discussion of the example follows.

The VBA version of the code sample is available here.

VB.NET SynthesisAPI Module1 Main MyRepository Repository MyRepository.ConnectToRepository MyRepository.Project.SetCurrentProject(1) AModel cModel AModel = MyRepository.Model.GetModel(21) Result1 Double Result2 Double Result1 = AModel.Reliability(100) Result2 = AModel.MeanTime ErrorMsg String AModel.SetConfidenceLevel(0.9, ConfBoundsSides.TwoSidedBoth, False, ErrorMsg) BResult1 BoundsValues BResult2 BoundsValues BResult1 = AModel.Bounds_Reliability(100) BResult2 = AModel.Bounds_MeanTime MsgBox ( & Result1 & vbNewLine & _              & BResult1.upper & vbNewLine & _               & BResult1.lower & vbNewLine) MsgBox ( & Result2 & vbNewLine & _              & BResult2.upper & vbNewLine & _               & BResult2.lower & vbNewLine)

Discussion
Begin by connecting to a Synthesis repository and project (for details, see this tutorial.) If you're copying this section of code, be sure to replace the inputs with appropriate data for your test repository.

MyRepository Repository MyRepository.ConnectToRepository MyRepository.Project.SetCurrentProject(1)

Once you are connected to the repository, use the Model.GetModel method to retrieve a single model from the repository. The following code assumes that the repository contains a model with ID#21.

AModel cModel AModel = MyRepository.Model.GetModel(21)

We can now obtain some metrics from the model. The cModel Class reference doc lists all available methods for performing calculations on models, but for this example, we'll limit it to the Reliability and MeanTime methods.

Result1 Double Result2 Double Result1 = AModel.Reliability(100) Result2 = AModel.MeanTime

To calculate the confidence bounds, use the SetConfidenceLevel method to specify 90% two-sided confidence bounds.

ErrorMsg String AModel.SetConfidenceLevel(0.9, ConfBoundsSides.TwoSidedBoth, False, ErrorMsg)

And then use any of the bounds calculation methods in the class to perform the commands. Here, we limit the example to the Bounds_Reliability and Bounds_MeanTime methods.

BResult1 BoundsValues BResult2 BoundsValues BResult1 = AModel.Bounds_Reliability(100) BResult2 = AModel.Bounds_MeanTime

The last section of code creates simple message boxes to display the outputs. To verify, you can compare the results returned by the API with the results obtained from the software's Quick Calculation Pad (QCP).

MsgBox ( & Result1 & vbNewLine & _          & BResult1.upper & vbNewLine & _           & BResult1.lower & vbNewLine) MsgBox ( & Result2 & vbNewLine & _          & BResult2.upper & vbNewLine & _           & BResult2.lower & vbNewLine)