⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 murder.frm

📁 用VB和MSBN实现线的一个贝叶斯网络的简单例子
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Murder 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "The Murder Trial"
   ClientHeight    =   720
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5115
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   720
   ScaleWidth      =   5115
   StartUpPosition =   3  'Windows Default
   Begin VB.OptionButton DNAState 
      Caption         =   "yes"
      Height          =   255
      Index           =   0
      Left            =   1200
      TabIndex        =   4
      Top             =   120
      Width           =   615
   End
   Begin VB.OptionButton DNAState 
      Caption         =   "no"
      Height          =   255
      Index           =   1
      Left            =   1200
      TabIndex        =   3
      Top             =   360
      Value           =   -1  'True
      Width           =   615
   End
   Begin VB.Label GuiltyProb 
      Caption         =   "0.00000000%"
      Height          =   255
      Left            =   3720
      TabIndex        =   2
      Top             =   120
      Width           =   1335
   End
   Begin VB.Label Label2 
      Caption         =   "Probability for guilty:"
      Height          =   255
      Left            =   2160
      TabIndex        =   1
      Top             =   120
      Width           =   1815
   End
   Begin VB.Label Label1 
      Caption         =   "DNA-match:"
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   975
   End
End
Attribute VB_Name = "Murder"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const MurderYes = 0
Private Const MurderNo = 1
Private Const DNAMatch = 0
Private Const DNANoMatch = 1
Dim inferMurder As MSBN3Lib.Engine

Private Sub Form_Load()
       Dim aMSBN As New MSBN3Lib.MSBN
    
    'Load the Auto model
    Dim modelMurder As MSBN3Lib.Model
    Set modelMurder = aMSBN.Models.Add("Murder", FileName:="murder.dsc", ErrorFilename:="loaderror.log")
     
    'Call the model's inference engine "inferAuto"
  
    Set inferMurder = modelMurder.Engine
    
    ' Initially the DNANoMatch state is selected - display the probability
   ' Call DNAState_Click(DNANoMatch)
    Exit Sub
End Sub

Private Sub Form_Terminate()
    ' We are done using the domain - explicitly delete it.
    d.Delete
End Sub


Private Sub DNAState_Click(Index As Integer)

    If Index = 0 Then
    inferMurder.Evidence.Set "DNA", "yes"
    Else
    inferMurder.Evidence.Set "DNA", "no"
    End If
    Debug.Print "The probability that this is the murder is "
    Debug.Print inferMurder.Belief("Murder", "yes")
'
  
    ' Fetch "Murderer?" node and display the probability for MurderYes
    GuiltyProb.Caption = Format(inferMurder.Belief("Murder", "yes") * 100, "##0.00000000") & "%"
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -