Combinations of variables in a minimization problem

22 views
Skip to first unread message

18...@novasbe.pt

unread,
Jan 17, 2018, 9:41:06 AM1/17/18
to AMPL Modeling Language
Dear all,

I need to solve a minimization problem with 300 variables that form 1000 combinations in pairs of two. Not all possible combinations are made and sometimes the variables can combine themselves two times. Additionally: 

1- There are is also a parameter "c" that depends on the variables present in the combination, regardless of the order, 

2- And two parameters "a" and "b" that depend on the order of the variables. 

As an example:

(a*x1+b*x2 - c12 )^2 + (a*x2+b*x2 - c22 )^2 +  (a*x2+b*x1 - c21 )^2

where c21=c12 

 After reading the provided materials my main question is: how can I set up my model and data in such a way that AMPL understands that the second variable appearing corresponds to the first variable in some other combinations? That is, how can I show that a*x1 in the first combination above and b*x1 in the third combination above correspond to the same variable?






ptiwari

unread,
Jan 17, 2018, 4:02:53 PM1/17/18
to AMPL Modeling Language
Are there any conditions on combining these variables? You could specify condition on the sum.  I will give you one example, but it may or may not work depending on your condition.

param n:= 300;
var x{1..n};

sum{i in 1...n, j in 2..n} (a*x[i]+b*x[j]-c[i,j])^2 + sum{i in 2...n, j in 2..n: i = j} (a*x[i]+b*x[j]-c[i,j]) + sum{i in 1..n,j in 1..n: j>i} (a*x[j]+b*x[i]-c[j,i])^2;

In the above formula, the first expression will have all combination of i and j. Do you have any condition on what combination should appear? The second one contains all the sum where i = j. 

Thanks,
Paras

18...@novasbe.pt

unread,
Jan 18, 2018, 5:32:55 AM1/18/18
to AMPL Modeling Language
Thank you for your comment.

Although that is probably a way to start, it does not completely solve my question since there are no conditions on the way how the variables are combined. 

For instance, imagine I have some people that will form groups of two. Person A may combine with B and then with C while C only combines with B. And then there is D that only combines with herself. How can I organize my data and my mod files to solve this issue?

ptiwari

unread,
Jan 18, 2018, 3:42:16 PM1/18/18
to AMPL Modeling Language
Can you express your problem using the mathematical notation? How do you write expression using summation notation ? I recommend you to forget about AMPL and write your formula in the paper using mathematical notation. After writing mathematical formula, It would be easier to translate it into AMPL syntax.
Reply all
Reply to author
Forward
0 new messages