### 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^2 - 3*x - 4*y + y^2; subject to c1: x^2 + 2*x <= 4; F1: 2*y + 2*l - 3*l - l = 0; F2: - 5 - l + 4*l - l = 0; F3: x^2 - 2*x + x^2 - 2*y + y + 3 >= 0; F4: x + 3*y - 4*y - 4 >= 0; cmpl1: l * (x^2 - 2*x + x^2 - 2*y + y + 3) = 0; cmpl2: l * (x + 3*y - 4*y - 4) = 0; cmpl3: l * y = 0; cmpl4: l * y = 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^2 - 3*x - 4*y + y^2; subject to c1: x^2 + 2*x <= 4; F1: 2*y + 2*l - 3*l = 0; F2: - 5 - l + 4*l = 0; cmpl1: 0 <= x^2 - 2*x + x^2 - 2*y + y + 3 complements l >= 0; cmpl2: 0 <= x + 3*y - 4*y - 4 complements l >= 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!