'All Different' and 'Is Integer' constraint in Optimization
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Alan Weiss
2012년 11월 5일
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
Alan Weiss
2012년 11월 6일
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
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!