matlab将数扩大为整数,在Matlab中使用遗传算法时如何设置整数约束?(How to set the integer constraints when use the Genetic Algor...

在MATLAB中使用遗传算法解决优化问题时,可以通过设置ga函数的参数LB(下限)、UB(上限)和IntCon(整数约束)来限制变量为整数,例如0或1。例如,对于10个二进制变量的问题,可以设定LB为全零向量,UB为全一向量,IntCon为1到10的向量。这样确保每个变量在迭代过程中保持整数状态。
摘要由CSDN通过智能技术生成

在Matlab中使用遗传算法时如何设置整数约束?(How to set the integer constraints when use the Genetic Algorithm in Matlab?)

如果有人能告诉我如何设置变量的整数约束(即,它们的变量只能是0或1),我将不胜感激。

x = ga(fitnessfcn,nvars);

It would be much appreciated if anybody can tell me how to set the integer constrain for the variables(i.e., they variables can only be either 0 or 1).

x = ga(fitnessfcn,nvars);

原文:https://stackoverflow.com/questions/37394612

更新时间:2020-02-05 07:53

最满意答案

使用可选的ga函数参数LB (下限), UB (上限)和IntCon (整数约束)。 您要使用的MATLAB遗传算法函数的签名是:

x = ga(fitnessfcn,nvars,A,b,[],[],LB,UB,nonlcon,IntCon)

例如,您可以使用MATLAB GA来解决10个二进制变量问题,如下所示:

% Number of variables

nVars = 10

% Lower and upper bounds

LB = zeros(1, nVars);

UB = ones(1, nVars);

% Variables with integer constraints (all

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值