Commit 026b6cd5 by Gianluca Frison

added solutions to 3.1 and 3.2

parent 013d509f
 reset; var x{1..2} >= 0; var y{1..2} >= 0; var l{1..4} >= 0; # multipliers minimize f: - x[1]^2 - 3*x[2] - 4*y[1] + y[2]^2; subject to c1: x[1]^2 + 2*x[2] <= 4; F1: 2*y[1] + 2*l[1] - 3*l[2] - l[3] = 0; F2: - 5 - l[1] + 4*l[2] - l[4] = 0; F3: x[1]^2 - 2*x[1] + x[2]^2 - 2*y[1] + y[2] + 3 >= 0; F4: x[2] + 3*y[1] - 4*y[2] - 4 >= 0; cmpl1: l[1] * (x[1]^2 - 2*x[1] + x[2]^2 - 2*y[1] + y[2] + 3) = 0; cmpl2: l[2] * (x[2] + 3*y[1] - 4*y[2] - 4) = 0; cmpl3: l[3] * y[1] = 0; cmpl4: l[4] * y[2] = 0; option solver knitro; option knitro_options "ms_enable=1 ms_maxsolves=30 ms_maxbndrange=5 outlev=2"; #option solver couenne; solve; display _varname, _var;
 reset; var x{1..2} >= 0; var y{1..2} >= 0; var l{1..2} >= 0; # multipliers minimize f: - x[1]^2 - 3*x[2] - 4*y[1] + y[2]^2; subject to c1: x[1]^2 + 2*x[2] <= 4; F1: 2*y[1] + 2*l[1] - 3*l[2] = 0; F2: - 5 - l[1] + 4*l[2] = 0; cmpl1: 0 <= x[1]^2 - 2*x[1] + x[2]^2 - 2*y[1] + y[2] + 3 complements l[1] >= 0; cmpl2: 0 <= x[2] + 3*y[1] - 4*y[2] - 4 complements l[2] >= 0; option solver knitro; option knitro_options "ms_enable=1 ms_maxsolves=30 ms_maxbndrange=5 outlev=2"; #option solver couenne; solve; display _varname, _var;
 reset; param n := 2; # dimensions param N := 6; # number of shperes var x{i in 1..N, j in 1..n} >= -1, <= 1 := Uniform(-1,1); var alpha; maximize obj: alpha; s.t. con1{i in 1..N}: sum{j in 1..n} x[i,j]^2 = 1; s.t. con2{i in 1..N, j in 1..N: i= 1; sum{k in 1..n} (x[i,k]-x[j,k])^2 >= alpha; option solver ipopt; solve; display {i in 1..N} sum{j in 1..n} x[i,j]^2; display {i in 1..N, j in 1..N} sum{k in 1..n} (x[i,k]-x[j,k])^2; display alpha;
 reset; param n := 3; # dimensions param N := 12; # number of shperes var x{i in 1..N, j in 1..n} >= -1, <= 1 := Uniform(-1,1); var alpha; maximize obj: alpha; s.t. con1{i in 1..N}: sum{j in 1..n} x[i,j]^2 = 1; s.t. con2{i in 1..N, j in 1..N: i= 1; sum{k in 1..n} (x[i,k]-x[j,k])^2 >= alpha; option solver ipopt; solve; display {i in 1..N} sum{j in 1..n} x[i,j]^2; display {i in 1..N, j in 1..N} sum{k in 1..n} (x[i,k]-x[j,k])^2; display alpha;
 reset; param n := 4; # dimensions param N := 24; # number of shperes var x{i in 1..N, j in 1..n} >= -1, <= 1 := Uniform(-1,1); var alpha; maximize obj: alpha; s.t. con1{i in 1..N}: sum{j in 1..n} x[i,j]^2 = 1; s.t. con2{i in 1..N, j in 1..N: i= 1; sum{k in 1..n} (x[i,k]-x[j,k])^2 >= alpha; #option solver ipopt; option solver knitro; #option knitro_options "ms_enable=1 ms_maxsolves=30"; solve; display {i in 1..N} sum{j in 1..n} x[i,j]^2; display {i in 1..N, j in 1..N} sum{k in 1..n} (x[i,k]-x[j,k])^2; display alpha;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!