simonsnow 发表于 2015-7-23 20:43

matlab优化问题

本帖最后由 simonsnow 于 2015-7-23 22:28 编辑

这个问题用matlab怎么解啊,大神路过麻烦帮下忙,提供一下思路也好,谢谢啦


shengshengchina 发表于 2015-7-23 20:43

再发一遍

lingo程序:

sets:
a/1..4/:x,c;
aa(a,a):  Q;
endsets
data:
c=6 8 4 2;
Q=-1 2 0 0
2 -1 2 0
0 2 -1 2
0 0 2 -1;
enddata
max=@sum(a:c*x)+1/2*@sum(a(j):x(j)*@sum(a(i):x(i)*Q(i,j)));
x(1)*x(2)+x(3)*x(4)>-1;
x(1)*x(2)+x(3)*x(4)<1;
@sum(a:x)>-3;
@sum(a:x)<2;
@for(a :  @free(x);@bnd(-1,x,1));

结果:
  Global optimal solution found.
   Objective value:                              16.33333
   Objective bound:                              16.33334
   Infeasibilities:                              0.000000
   Extended solver steps:                              11
   Total solver iterations:                           706


                        Variable           Value        Reduced Cost
                           X( 1)        1.000000           -3.000000
                           X( 2)        1.000000           -6.333333
                           X( 3)       0.6666667            0.000000
                           X( 4)      -0.6666667            0.000000

shengshengchina 发表于 2015-7-24 16:34

lingo程序:

sets:
a/1..4/:x,c;
aa(a,a):Q;
endsets
data:
c=6 8 4 2;
Q=-1 2 0 0
2 -1 2 0
0 2 -1 2
0 0 2 -1;
enddata
max=@sum(a:c*x)+1/2*@sum(a(j):x(j)*@sum(a(i):x(i)*Q(i,j)));
x(1)*x(2)+x(3)*x(4)>-1;
x(1)*x(2)+x(3)*x(4)<1;
@sum(a:x)>-3;
@sum(a:x)<2;
@for(a:@free(x);@bnd(-1,x,1));

结果:
  Global optimal solution found.
  Objective value:                              16.33333
  Objective bound:                              16.33334
  Infeasibilities:                              0.000000
  Extended solver steps:                              11
  Total solver iterations:                           706


                       Variable           Value        Reduced Cost
                          X( 1)        1.000000           -3.000000
                          X( 2)        1.000000           -6.333333
                          X( 3)       0.6666667            0.000000
                          X( 4)      -0.6666667            0.000000

simonsnow 发表于 2015-7-25 11:05

shengshengchina 发表于 2015-7-24 16:37 static/image/common/back.gif
再发一遍

lingo程序:


x1-x4只能是-1或1,下面有条件限制。。。而且我用lingo解出来了,值是16,不知道怎么用matlab来解,不过还是谢谢你,先给你采纳了,你会用matlab解吗
页: [1]
查看完整版本: matlab优化问题