Constraint in optimization problem
Ältere Kommentare anzeigen
Hello all,
I would like to kindly ask for your help, if you are familiar with optimization stuff...
Do you know how I can introduce a constraint in order to avoid having a vector solution without consecutive '1s' (either the number of '1' are two, or three etc)? (Let's say the vector is y and takes 6 binary values)
For example: vector1 = [1 0 1 0 0 0]
vector2 = [0 0 1 1 0 1]
vector3 = [1 0 0 0 1 0]
vector4 = [0 0 1 0 0 1]
are not valid solutions, but:
vector5 = [1 0 0 0 0 0]
vector6 = [0 0 1 1 1 0]
vector7 = [0 1 1 0 0 0]
vector8 = [0 0 1 0 0 0]
vector9 = [1 1 1 0 0 0]
are valid. I am really stuck with it!
Best regards, Chris
Akzeptierte Antwort
Weitere Antworten (2)
John D'Errico
am 19 Mär. 2015
Bearbeitet: John D'Errico
am 19 Mär. 2015
You don't say what optimization tool you are working with. But as long as your favorite optimizer (intlinprog maybe) can handle inequality constraints, then just specify
x(1) + x(2) <= 1
x(2) + x(3) <= 1
x(3) + x(4) <= 1
x(4) + x(5) <= 1
x(5) + x(6) <= 1
1 Kommentar
Chris B
am 19 Mär. 2015
Kategorien
Mehr zu Systems of Nonlinear Equations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!