xiaoxiong's Blog

Happy coding

Matlab 0-1规划之bintprog的 用法

xiaoxiong posted @ 2015年1月18日 14:34 in matlab使用 , 2787 阅读

x = bintprog(f)
x = bintprog(f, A, b)
x = bintprog(f, A, b, Aeq, beq)
x = bintprog(f, A, b, Aeq, beq, x0)
x = bintprog(f, A, b, Aeq, Beq, x0, options)
[x, fval] = bintprog(...)
[x,fval, exitflag] = bintprog(...)
[x, fval, exitflag, output] = bintprog(...)


这里x是问题的解向量
f是由目标函数的系数构成的向量
A是一个矩阵,b是一个向量
A,b和变量x={x1,x2,…,xn}一起,表示了线性规划中不等式约束条件
A,b是系数矩阵和右端向量。
Aeq和Beq表示了线性规划中等式约束条件中的系数矩阵和右端向量。
X0是给定的变量的初始值
options为控制规划过程的参数系列。
返回值中fval是优化结束后得到的目标函数值。
exitflag=0表示优化结果已经超过了函数的估计值或者已声明的最大迭代次数;
exitflag>0表示优化过程中变量收敛于解X,
exitflag<0表示计算不收敛。
output有3个分量,
iterations表示优化过程的迭代次数,
cgiterations表示PCG迭代次数,
algorithm表示优化所采用的运算规则。
在使用linprog()命令时,系统默认它的参数至少为1个,
但如果我们需要给定第6个参数,则第2、3、4、5个参数也必须给出,否则系统无法认定给出的是第6个参数。遇到无法给出时,则用空矩阵“[]”替代。



例如

max=193*x1+191*x2+187*x3+186*x4+180*x5+185*x6; %f由这里给出

st.

x5+x6>=1;
x3+x5>=1;
x1+x2<=1;
x2+x6<=1;
x4+x6<=1;
%a、b由不等关系给出,如没有不等关系,a、b取[]

x1+x2+x3+x4+x5+x6=1; aeq beq由等式约束给出

代码如下
f=[-193;-191;-187;-186;-180;-185;];
a=[0 0 0 0 -1 -1;0 -1 0 0 -1 0;1 1 0 0 0 0;0 1 0 0 0 1;0 0 0 1 0 1];
b=[-1,-1,1,1,1]';
aeq=[1 1 1 1 1 1];
beq=[3];
x=bintprog(f,a,b,aeq,beq)

注意
目标值为最大值时应乘以-1化为求最小值;
不等约束为>=时应乘以-1化为<=;

 

转自  http://blog.sina.com.cn/s/blog_687a516d0100x8o3.html

Avatar_small
Emma 说:
2023年1月19日 18:40

It is impressive to note that Matlab's 0-1 planning feature can be enhanced with the use of the bintprog function. This powerful tool allows users to explore a range of discrete optimization problems cbd products with ease. The efficient, user-friendly interface allows for easy manipulation of data and provides quick and accurate results. With the bintprog function, users are able to solve a variety of complex problems with minimal time and effort. This is a great feature for anyone looking for a convenient way to plan their projects.

Avatar_small
civaget 说:
2024年1月17日 21:42

I can't get enough of 오피타임's Swedish massage; it's pure bliss!

Avatar_small
civaget 说:
2024年1月18日 04:56

제주출장마사지 is a hidden treasure on 제주 Island.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter