Info
This question is closed. Reopen it to edit or answer.
Only generate sorted solutions by constraint using a ga-solver
1 view (last 30 days)
Show older comments
I'm using genetic algorithm to solve an optimization problem. The input is a couple of inrrelevant constants and an 1x21 vector named x.
The ga-solver will give me a function value and a configuration of my x-vector where each entry can have the value from 1 to 7 representing different stations in a manufacturing system.
I need a constraint/rule for the solver, so it only suggest sorted solutions from left to right, where entries not used is given the value 7. Are the however an entry with 6 at some random place between 1 and 7, then it must be allowed to stay e.g.: x=[1 1 1 6 2 2 5 5 5 5 7 7 7 7 7 7 7 7 7 7 7]
I cannot use sort(x) as this would be an evaluation afterwards, and I need the solver to take the constraint into consideration.
0 Comments
Answers (1)
Alan Weiss
on 2 May 2014
I am not sure that I really understand what your constraints are. Do you allow more than one value of 6 to appear?
In general, if you want solutions in increasing order, you can achieve the goal with linear constraints of the form
x(i) <= x(i+1)
for all relevant i. With 21 components this would lead to 20 linear constraints in an A matrix with rows of the form
[0,0,...,0,1,-1,0,...,0]
But for your case I do not know a good formulation, in part because I don't really understand how your "6" variables are constrained.
Alan Weiss
MATLAB mathematical toolbox documentation
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!