'All Different' and 'Is Integer' constraint in Optimization
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Sub Question 1 -
In Matlab's optimization toolbox or as a third-party Matlab implementation, is there an in-built 'all different' constraint? By 'all different', I mean that an a constraint on a vector to have all values different from each other.
For reference: 'Excel solver' recently included it.
Details on alldifferent constraint can be understood here - http://www.andrew.cmu.edu/user/vanhoeve/papers/alldiff.pdf
Sub Question 2 - Same query for 'is integer' constraint, i.e. the vector elements are constraint to be integers.
Thanks.
0 Commenti
Risposte (1)
Alan Weiss
il 5 Nov 2012
If you have continuous variables, then I think the "all different" restriction does not make sense. You can perturb an element by a very small amount and end up with a "different" value, but one which does not really change the value of an objective or constraint function, to within numerical tolerances.
As far as integer constraints, the Optimization Toolbox does not handle such constraints except for the bintprog function. The Global Optimization Toolbox ga function does handle integer constraints, and I believe that you could write a nonlinear constraint function that would attempt to enforce "all different" members of a population. For example, if components 1 through 6 are integer-valued, you could make a nonlinear inequality constraint function that is negative if these 6 elements have different values, and is positive if they have an identical value. For example:
function [c,ceq] = checkdifferent(x)
ceq = [];
ll = length(unique(x(1:6)));
c = -ll + 5.5; % negative when first 6 entries are different
Be warned, I have not tested this to see how well it works in practice.
Alan Weiss
MATLAB mathematical toolbox documentation
2 Commenti
Alan Weiss
il 6 Nov 2012
I am not aware of something that "fundamentally imposes an "all different integers" constraint." The nonlinear constraint function I suggested might be worth trying.
Alan Weiss
MATLAB mathematical toolbox documentation
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!