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

📄 form1.frm

📁 用VB语言编写的解决运筹学0-1规划的程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "0-1规划 分支定界法"
   ClientHeight    =   5115
   ClientLeft      =   7005
   ClientTop       =   7095
   ClientWidth     =   7935
   BeginProperty Font 
      Name            =   "楷体_GB2312"
      Size            =   12
      Charset         =   134
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   Picture         =   "Form1.frx":0000
   ScaleHeight     =   5115
   ScaleWidth      =   7935
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command2 
      Caption         =   "求解"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   360
      TabIndex        =   9
      Top             =   3960
      Visible         =   0   'False
      Width           =   855
   End
   Begin VB.TextBox Text5 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   0
      Left            =   1920
      TabIndex        =   8
      Top             =   2160
      Visible         =   0   'False
      Width           =   495
   End
   Begin VB.TextBox Text3 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   0
      Left            =   1920
      TabIndex        =   6
      Top             =   1320
      Visible         =   0   'False
      Width           =   495
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4800
      TabIndex        =   4
      Top             =   720
      Width           =   855
   End
   Begin VB.CommandButton Command1 
      Caption         =   "输入问题"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   6120
      TabIndex        =   2
      Top             =   720
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1800
      TabIndex        =   1
      Top             =   720
      Width           =   855
   End
   Begin VB.Label Label4 
      BackStyle       =   0  'Transparent
      Caption         =   "说明:程序仅适用于0-1规划标准型,非标准模型需要转换  "
      Height          =   375
      Left            =   360
      TabIndex        =   10
      Top             =   240
      Width           =   7095
   End
   Begin VB.Label Label5 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "输入约束条件(不等式约束均为<=,各变量取值均为0或1)"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1140
      Left            =   240
      TabIndex        =   7
      Top             =   2160
      Visible         =   0   'False
      Width           =   1530
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "输入价值系数"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   360
      TabIndex        =   5
      Top             =   1320
      Visible         =   0   'False
      Width           =   1350
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "不等式约束个数"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   3000
      TabIndex        =   3
      Top             =   720
      Width           =   1575
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "变量个数"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   360
      TabIndex        =   0
      Top             =   720
      Width           =   900
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Base 1

Private Sub Command1_Click()
    Dim i As Integer, j As Integer, k As Integer
    n = Text1.Text
    m = Text2.Text
    Label3.Visible = True
    For j = 1 To (n + 1)
        Load Text3(j)
        Text3(j).Visible = True
        Text3(j).Top = 1320
        Text3(j).Left = Text3(0).Left + (j - 1) * (Text3(0).Width + 200)
    Next j
    
    Label5.Visible = True
    For i = 1 To m
        For j = 1 To (n + 1)
            k = (i - 1) * (n + 1) + j
            Load Text5(k)
            Text5(k).Visible = True
            Text5(k).Top = Text5(0).Top + (i - 1) * (Text5(0).Height + 200)
            Text5(k).Left = Text5(0).Left + (j - 1) * (Text5(0).Width + 200)
        Next j
    Next i
    Command2.Visible = True
    Command2.Top = Text5(k).Top + Text5(0).Height + 500
    Command2.Left = 1 / 2 * (Form1.Width - Command2.Width)
End Sub

Private Sub Command2_Click()
    Dim i As Integer, j As Integer, s() As Single, z As Single, k As Integer, flag As Boolean
    flag = False
    z = Text3(n + 1).Text
    max = -10000
    ReDim A(m, n)
    ReDim C(n)
    ReDim B(m)
    ReDim s(m)
    ReDim x(n)
    For j = 1 To n
        C(j) = Text3(j).Text
    Next j
    For i = 1 To m
        For j = 1 To (n + 1)
            k = (i - 1) * (n + 1) + j
            If j = n + 1 Then
                B(i) = Text5(k).Text
                If B(i) < 0 Then flag = True
            Else
                A(i, j) = Text5(k).Text
            End If
        Next j
    Next i
    If flag Then
        Branch_Bound1 1, s(), z
        Branch_Bound0 1, s(), z
    Else
        result_num = 1
        ReDim result(n, result_num)
    End If
    Load Form2
    Form2.Show
End Sub

⌨️ 快捷键说明

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