CModel.SetModel: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
mNo edit summary
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:cModel.SetModel}}
{{DISPLAYTITLE:cModel.SetModel}}{{Template:API}}{{Template:APIBreadcrumb|.[[CModel Class|cModel]]}}
{{Template:APIClass|CModel Class|cModel}}  
 
{{Template:CModel.SetModel.Cmt}}
 
<onlyinclude>Sets the model type, category, name and parameters of an associated cModel object.</onlyinclude>


== Syntax ==
== Syntax ==
*SetModel( ModelType {{APIPrefix|As}} [[ModelTypeEnum Enumeration|ModelTypeEnum]], ModelCategory {{APIPrefix|As}} [[ModelCategoryEnum Enumeration|ModelCategoryEnum]], ModelParams(){{APIPrefix|As Double}} )
'''.SetModel'''(''ModelType'', ''ModelCategory'', ''ModelName'', {{APIPrefix|ByRef}} ''ModelParams()'')


Parameters
===Parameters===
:''ModelType'': The [[ModelTypeEnum Enumeration|ModelTypeEnum]] describing the model type (e.g., 2-parameter Weibull).
''ModelType''
:Required. The model type (e.g., 2-parameter Weibull). Can be any [[ModelTypeEnum Enumeration|ModelTypeEnum]] constant.


:''ModelCategory'': The [[ModelCategoryEnum Enumeration|ModelCategoryEnum]] describing the model category (e.g., reliability model).
''ModelCategory''
:Required. The model category (e.g., reliability model). Can be any [[ModelCategoryEnum Enumeration|ModelCategoryEnum]] constant.


:''ModelParams'': An array of the model's parameters.
''ModelName''
:Required. String. The model name.


== Usage Example ==
''ModelParams()''
  {{APIComment|Declare the cModel class using an in-line parameter list.}}
:Required. Double. An array of the model's parameters.
   Dim newModel As New cModel(ModelTypeEnum.Weibull2,
 
    ModelCategoryEnum.Reliability, "NewModel1", 1, 100)
 
== Example ==
'''VBA'''
  {{APIComment|...}}
{{APIComment|'Create a new model. The following example creates a 2-parameter Weibull reliability model,}}
{{APIComment|'with beta &#61; 1 and eta &#61; 100. The model name is "MyNewModel."}}
   {{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}}
    
    
  {{APIComment|Change the model type and parameters.}}
  ModelType = ModelTypeEnum_Weibull2
   newModel.SetModel(ModelTypeEnum.Lognormal, ModelCategoryEnum.Reliability, 200)
  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|'Replace the model.}} 
  {{APIPrefix|Call}} MyRepository.Model.UpdateModel(AModel)
 
'''VB.NET'''
{{APIComment|...}}
{{APIComment|'Create a new model. The following code creates a 2-parameter Weibull reliability model,}}
{{APIComment|'with beta 1 and eta 100. The model name is "MyNewModel."}}
  {{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|'Replace the model.}} 
  MyRepository.Model.UpdateModel(AModel)

Latest revision as of 15:39, 28 April 2016

APIWiki.png


Member of: SynthesisAPI.cModel


Sets the model type, category, name and parameters of an associated cModel object.

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)