FindMinimum challenge
FindMinimum challenge
The problem is the following:Given a symmetric square matrix (1≤i,j≤n) with integer entries and zeros along the main diagonal find (1≤k≤n, 1≤l≤d) such that the following expression is minimized(
a
ij
x
kl
n
∑
i,j=1
2
-
d
∑
l=1
2
(-)
x
il
x
jl
a
ij
An example: n=16, d=2
mat=
;
0 | 1 | 4 | 3 | 1 | 2 | 3 | 2 | 2 | 3 | 4 | 3 | 1 | 2 | 3 | 2 |
1 | 0 | 3 | 4 | 2 | 1 | 2 | 3 | 3 | 2 | 3 | 4 | 2 | 1 | 2 | 3 |
4 | 3 | 0 | 1 | 3 | 2 | 1 | 2 | 4 | 3 | 2 | 3 | 3 | 2 | 1 | 2 |
3 | 4 | 1 | 0 | 2 | 3 | 2 | 1 | 3 | 4 | 3 | 2 | 2 | 3 | 2 | 1 |
1 | 2 | 3 | 2 | 0 | 3 | 4 | 1 | 1 | 2 | 3 | 2 | 2 | 3 | 4 | 3 |
2 | 1 | 2 | 3 | 3 | 0 | 1 | 4 | 2 | 1 | 2 | 3 | 3 | 2 | 3 | 4 |
3 | 2 | 1 | 2 | 4 | 1 | 0 | 3 | 3 | 2 | 1 | 2 | 4 | 3 | 2 | 3 |
2 | 3 | 2 | 1 | 1 | 4 | 3 | 0 | 2 | 3 | 2 | 1 | 3 | 4 | 3 | 2 |
2 | 3 | 4 | 3 | 1 | 2 | 3 | 2 | 0 | 1 | 4 | 3 | 1 | 2 | 3 | 2 |
3 | 2 | 3 | 4 | 2 | 1 | 2 | 3 | 1 | 0 | 3 | 4 | 2 | 1 | 2 | 3 |
4 | 3 | 2 | 3 | 3 | 2 | 1 | 2 | 4 | 3 | 0 | 1 | 3 | 2 | 1 | 2 |
3 | 4 | 3 | 2 | 2 | 3 | 2 | 1 | 3 | 4 | 1 | 0 | 2 | 3 | 2 | 1 |
1 | 2 | 3 | 2 | 2 | 3 | 4 | 3 | 1 | 2 | 3 | 2 | 0 | 3 | 4 | 1 |
2 | 1 | 2 | 3 | 3 | 2 | 3 | 4 | 2 | 1 | 2 | 3 | 3 | 0 | 1 | 4 |
3 | 2 | 1 | 2 | 4 | 3 | 2 | 3 | 3 | 2 | 1 | 2 | 4 | 1 | 0 | 3 |
2 | 3 | 2 | 1 | 3 | 4 | 3 | 2 | 2 | 3 | 2 | 1 | 1 | 4 | 3 | 0 |
mat==Transpose[mat]
True
TrialMatrix[n_,d_]:=Table[Sum[,{k,d}],{i,n},{j,n}]
2
(x[i,k]-x[j,k])
toMinimize=Apply[Plus,Flatten[TrialMatrix[16,2]-mat^2]^2]/. {x[1,1]->0,x[1,2]->0};
vars=Union[Cases[toMinimize,x[_,_],∞]];
FindMinimumEvaluate[toMinimize], Evaluate[Sequence@@({#,Random[]}&/@vars)][[1]]//Timing
{5.22Second,1811.02}
The following crashes the kernel from June 19 (as it
crashed on May 19 when I sent this already):
crashed on May 19 when I sent this already):
FindMinimumEvaluate[toMinimize], Evaluate[Sequence@@({#,Random[]}&/@vars)],Method->Newton[[1]]//Timing
The following too crashes the kernel from June 19 (like
it did on May 19):
it did on May 19):
FindMinimumEvaluate[toMinimize], Evaluate[Sequence@@({#,Random[]}&/@vars)],Method->QuasiNewton[[1]]//Timing
FindMinimumEvaluate[toMinimize], Evaluate[Sequence@@({#,Random[]}&/@vars)],Method->LevenbergMarquardt[[1]]//Timing
{4.84Second,1811.02}