필터 지우기
필터 지우기

'All Different' and 'Is Integer' constraint in Optimization

조회 수: 6 (최근 30일)
Amit
Amit 2012년 11월 5일
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.

답변 (1개)

Alan Weiss
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
Amit
Amit 2012년 11월 6일
Hi Alan, Thanks. Agreed that "all different" constraint would make sense only in case when variables are discrete. So the hirarchy of constraints required would be: Level 1: Is Integer Sub-level 1: All different.
Though I am looking to have a more sounder methodology to enforce all different, because if I embed what you suggest in the overall model to be fitted, it may interfere with the optimization scheme at hand.
Is there anything which, by the nature of it, fundamentally imposes an "all different integers" constraint on a vector?
Thanks.
Alan Weiss
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by