CModel.SetModel: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 26: Line 26:
  {{APIComment|...}}
  {{APIComment|...}}
   
   
  {{APIComment|'Add code to create a new model or get an existing model you want to replace with a new model.}}
{{APIComment|'Create a new model. The following example creates a 2-parameter Weibull reliability model,}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As New}} cModel
{{APIComment|'with beta = 1 and eta = 100. The model name is "MyNewModel."}}
  {{APIComment|...}}
  {{APIPrefix|Dim}} ModelType {{APIPrefix|As}} ModelTypeEnum
  {{APIPrefix|Dim}} ModelCategory {{APIPrefix|As}} ModelCategoryEnum
  {{APIPrefix|Dim}} ModelName {{APIPrefix|As String}}
  {{APIPrefix|Dim}} ModelParams(2) {{APIPrefix|As Double}}
 
  ModelType = ModelTypeEnum_Weibull2
  ModelCategory = ModelCategoryEnum_Reliability
  ModelName = {{APIString|"MyNewModel"}}
  ModelParams(0) = 1
  ModelParams(1) = 100
  {{APIPrefix|Dim}} newModel {{APIPrefix|As New}} cModel
  {{APIPrefix|Call}} newModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)
  {{APIComment|'Add the new model to project #1.}}
  MyRepository.Project.SetCurrentProject(1) 
  {{APIPrefix|Call}} MyRepository.Model.AddModel(newModel)
{{APIComment|'To replace an existing model, first get the model to be replaced.}}
{{APIComment|'The following example assumes that model with ID#47 exists in the repository.}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As New}} cModel
  {{APIPrefix|Set}} AModel = MyRepository.Model.GetModel(47)
  {{APIComment|'Apply the definitions to the model.}}
  {{APIPrefix|Call}} AModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)
   
   
  {{APIComment|'Specify the definitions for the model.}}
  {{APIComment|'Replace the model.}}   
  {{APIPrefix|Dim}} params(1) {{APIPrefix|As Double}}
  {{APIPrefix|Call}} MyRepository.Model.UpdateModel(AModel)
  params(0) = 5
  params(1) = 1
    
{{APIComment|'Apply the definition to the model.}}
  {{APIPrefix|Call}} AModel.SetModel(ModelTypeEnum_Lognormal, ModelCategoryEnum_Reliability, {{APIString|"Model1"}}, params)


  '''VB.NET'''
  '''VB.NET'''
Line 42: Line 61:
  {{APIComment|...}}
  {{APIComment|...}}
   
   
  {{APIComment|'Add code to create a new model or get an existing model you want to replace with a new model.}}
  {{APIComment|'Create a new model. The following code creates a 2-parameter Weibull reliability model,}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As New}} cModel
{{APIComment|'with beta 1 and eta 100. The model name is "MyNewModel."}}
  {{APIComment|...}}
  {{APIPrefix|Dim}} ModelParams(1) {{APIPrefix|As Double}}
  ModelParams(0) = 1
  ModelParams(1) = 100
  {{APIPrefix|Dim}} newModel {{APIPrefix|As New}} cModel(ModelTypeEnum.Weibull2,ModelCategoryEnum.Reliability, {{APIString|"MyNewModel"}}, ModelParams)
{{APIComment|'Add the new model to project #1.}}
  MyRepository.Project.SetCurrentProject(1) 
  MyRepository.Model.AddModel(newModel)
{{APIComment|'To replace an existing model, first get the model to be replaced.}}
{{APIComment|'The following example assumes that model with ID#47 exists in the repository.}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As New}} cModel
  AModel = MyRepository.Model.GetModel(47)
  {{APIComment|'Apply the definitions to the model.}}
  AModel.SetModel(ModelTypeEnum.Weibull2,ModelCategoryEnum.Reliability, {{APIString|"UpdatedModel"}}, ModelParams)
   
   
  {{APIComment|'Specify the definitions for the model. You can use an in-line parameter list to apply the update to the model.}}
  {{APIComment|'Replace the model.}}  
  AModel.SetModel(ModelTypeEnum.Lognormal, ModelCategoryEnum.Reliability, {{APIString|"Model1"}}, {{APIPrefix|New Double}}() {1, 100} )
  MyRepository.Model.UpdateModel(AModel)

Revision as of 22:19, 22 October 2015

APIWiki.png


Member of: SynthesisAPI9.cModel


Sets the model type, category, name and parameters for a new cModel object. Can also be used to replace an existing model.

Syntax

.SetModel(ModelType, ModelCategory, ModelName, ByRef ModelParams())

Parameters

ModelType

Required. The model type (e.g., 2-parameter Weibull). Can be any ModelTypeEnum constant.

ModelCategory

Required. The model category (e.g., reliability model). Can be any ModelCategoryEnum constant.

ModelName

Required. String. The model name.

ModelParams()

Required. Double. An array of the model's parameters.


Example

VBA

 ... 

 'Create a new model. The following example creates a 2-parameter Weibull reliability model, 
 'with beta = 1 and eta = 100. The model name is "MyNewModel." 
  Dim ModelType As ModelTypeEnum
  Dim ModelCategory As ModelCategoryEnum
  Dim ModelName As String
  Dim ModelParams(2) As Double
 
  ModelType = ModelTypeEnum_Weibull2
  ModelCategory = ModelCategoryEnum_Reliability
  ModelName = "MyNewModel"
  ModelParams(0) = 1
  ModelParams(1) = 100

  Dim newModel As New cModel
  Call newModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)

 'Add the new model to project #1. 
  MyRepository.Project.SetCurrentProject(1)   
  Call MyRepository.Model.AddModel(newModel)

 'To replace an existing model, first get the model to be replaced. 
 'The following example assumes that model with ID#47 exists in the repository. 
  Dim AModel As New cModel
  Set AModel = MyRepository.Model.GetModel(47)

 'Apply the definitions to the model. 
  Call AModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)

 'Replace the model.    
  Call MyRepository.Model.UpdateModel(AModel)
VB.NET

 ... 

 'Create a new model. The following code creates a 2-parameter Weibull reliability model, 
 'with beta 1 and eta 100. The model name is "MyNewModel." 
  Dim ModelParams(1) As Double
  ModelParams(0) = 1
  ModelParams(1) = 100
  Dim newModel As New cModel(ModelTypeEnum.Weibull2,ModelCategoryEnum.Reliability, "MyNewModel", ModelParams) 

 'Add the new model to project #1. 
  MyRepository.Project.SetCurrentProject(1)   
  MyRepository.Model.AddModel(newModel)

 'To replace an existing model, first get the model to be replaced. 
 'The following example assumes that model with ID#47 exists in the repository. 
  Dim AModel As New cModel
  AModel = MyRepository.Model.GetModel(47)

 'Apply the definitions to the model. 
  AModel.SetModel(ModelTypeEnum.Weibull2,ModelCategoryEnum.Reliability, "UpdatedModel", ModelParams)

 'Replace the model.    
  MyRepository.Model.UpdateModel(AModel)