Main Content

本页的翻译已过时。点击此处可查看最新英文版本。

writebounds

保存变量边界描述

说明

使用 writebounds 保存优化变量的边界描述。

writebounds(var) 将变量边界的描述保存在名为 variable_bounds.txt 的文件中。此处,variablevarName 属性。writebounds 函数会覆盖任何现有文件。

示例

writebounds(var,filename) 将变量边界的描述保存在名为 filename 的文件中。

示例

全部折叠

创建一个优化变量,并将其边界保存到文件中。

x = optimvar('x',10,4,'LowerBound',randi(8,10,4),...
    'UpperBound',10+randi(7,10,4),'Type','integer');
writebounds(x,'BoundFile.txt')

BoundFile.txt 的内容:

		7 <= x(1, 1) <= 14
		8 <= x(2, 1) <= 13
		2 <= x(3, 1) <= 16
		8 <= x(4, 1) <= 16
		6 <= x(5, 1) <= 12
		1 <= x(6, 1) <= 14
		3 <= x(7, 1) <= 14
		5 <= x(8, 1) <= 15
		8 <= x(9, 1) <= 15
		8 <= x(10, 1) <= 16
		2 <= x(1, 2) <= 12
		8 <= x(2, 2) <= 15
		8 <= x(3, 2) <= 15
		4 <= x(4, 2) <= 12
		7 <= x(5, 2) <= 11
		2 <= x(6, 2) <= 14
		4 <= x(7, 2) <= 17
		8 <= x(8, 2) <= 13
		7 <= x(9, 2) <= 15
		8 <= x(10, 2) <= 12
		6 <= x(1, 3) <= 16
		1 <= x(2, 3) <= 12
		7 <= x(3, 3) <= 14
		8 <= x(4, 3) <= 15
		6 <= x(5, 3) <= 17
		7 <= x(6, 3) <= 17
		6 <= x(7, 3) <= 14
		4 <= x(8, 3) <= 11
		6 <= x(9, 3) <= 12
		2 <= x(10, 3) <= 12
		6 <= x(1, 4) <= 16
		1 <= x(2, 4) <= 12
		3 <= x(3, 4) <= 16
		1 <= x(4, 4) <= 12
		1 <= x(5, 4) <= 17
		7 <= x(6, 4) <= 13
		6 <= x(7, 4) <= 12
		3 <= x(8, 4) <= 12
		8 <= x(9, 4) <= 15
		1 <= x(10, 4) <= 14

输入参数

全部折叠

优化变量,指定为 OptimizationVariable 对象。使用 optimvar 创建 var

示例: var = optimvar('var',4,6)

文件的路径,指定为字符串或字符向量。路径是相对于当前文件夹的路径。生成的文件是文本文件,因此文件名通常具有扩展名 .txt

示例: "../Notes/steel_stuff.txt"

数据类型: char | string

提示

  • 要在命令行窗口中获取 writebounds 信息,请使用 showbounds

在 R2017b 中推出