How to define a binary decision variable as upper and lower bond in an optimization function?

2 次查看(过去 30 天)
Hello experts,
I have an optimization problem that i have to solve using improved particle swarm optimization and i want to define the binary variable (x2) in Matlab as constraint.
x2 = 0 for charge of battery
x2 = 1 for discharge of battery
how can i define it thank you in advance.

回答(1 个)

Walter Roberson
Walter Roberson 2021-4-15
编辑:Walter Roberson 2021-4-15
You cannot use integer constraints with the Mathworks provided particle swarm algorithm. You can force the initial positions to match the constraints but the velocity will always be continuous so the first step will move away from the constraints. There is no hook that you can use to confine the range of motion to integers.
  6 个评论
Walter Roberson
Walter Roberson 2021-6-15
As this situation was for the case of user-provided code for doing all of the genetic optimization, instead of using MATLAB Library functions, then it is difficult for us to know what is in the rest of the code.
Also, the velocity might come out to be less than +/- 1/2 in each component, so round() might be returning you to the same position.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Particle Swarm 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by