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

4 ビュー (過去 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

サインインしてコメントする。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by