SHARE
TWEET

Untitled

a guest May 22nd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. k = 0
  3. tinit = 1.0
  4. y = 1.5
  5. e = 0.1
  6.  
  7. A = [0.4873 -0.8732;
  8.     0.6072 0.7946;
  9.     0.9880 -0.1546;
  10.     -0.2142 -0.9768;
  11.     -0.9871 -0.1601;
  12.     0.9124 0.4093]
  13.  
  14. b = [1;
  15.     1;
  16.     1;
  17.     1;
  18.     1;
  19.     1]
  20.  
  21. c = [1;
  22.     -1]
  23.  
  24. x0 = [0, 0]
  25.  
  26. V = [0.1562 0.9127 1.0338 0.8086 -1.3895 -0.8782;
  27.     -1.0580 -0.6358 0.1386 0.6406 2.3203 -0.8311]
  28.  
  29. [m, n] = size(A)
  30.  
  31. t = tinit
  32.  
  33. %t*c'*x - sum(log(b-A*x))
  34. %t*c + (A')*(1./(b-A*x))
  35. %((diag(1./(b-A*x))*A)')*(diag(1./(b-A*x))*A)
  36.  
  37.  
  38. %cvx_begin
  39.  
  40. %cT = c'
  41.  
  42. %variable x(n)
  43. %minimize cT*x
  44. %subject to
  45. %    A*x <= b
  46.  
  47. %cvx_end
  48.  
  49. xk = x0
  50. %temp = xk
  51. cT = c'
  52.  
  53. while m/t >= e
  54.     k
  55.     cvx_begin
  56.  
  57.     variable x(n)
  58.     minimize t*cT*x - sum(log(b-A*x))
  59.  
  60.     cvx_end
  61.    
  62.     %temp = xk
  63.     xk = [xk;x']
  64.     %xk = temp
  65.    
  66.     k = k + 1
  67.     t = y*t
  68. end
  69.  
  70. m/t
  71. xk
  72.  
  73. t*cT*xk(2) - sum(log(b-A*xk(2)))
  74.  
  75. %function [f,g,H] = objective_barrier(t,x,A,b,c);
  76. %[m,n] = size(A);
  77. %d = A*x - b; D = diag(1./d);
  78. %f = t*c’*x - log(-d’)*ones(m,1);
  79. %g = t*c - A’*D*ones(m,1);
  80. %H = A’*D^2*A;
  81.  
  82.  
  83.  
  84. figure(1)
  85. %set(gcf,'position',[10,10,560,540])
  86. %fill(V(1,:), V(2,:), 'r')
  87.  
  88. %grid on
  89. %axis([-2.5 2 -1.5 3])
  90. %xticks(-2.5:0.5:2)
  91. %yticks(-1.5:0.5:3)
  92. %axis equal
  93.  
  94. x1 = -2.5:0.01:2.0
  95. x2 = -1.5:0.01:3.0
  96. [X1,X2] = meshgrid(x1,x2);
  97. Z = arrayfun(@fbar,X1,X2)
  98. v = [-0.6,0.12,0.24]
  99. contour(X1,X2,Z,v)
  100.  
  101. function y = fbar(x1,x2)
  102.     A = [0.4873 -0.8732;
  103.     0.6072 0.7946;
  104.     0.9880 -0.1546;
  105.     -0.2142 -0.9768;
  106.     -0.9871 -0.1601;
  107.     0.9124 0.4093];
  108.  
  109.     b = [1;
  110.     1;
  111.     1;
  112.     1;
  113.     1;
  114.     1];
  115.     if sum(b-A*[x1;x2]<0) == 0
  116.         y = -sum(log(b-A*[x1;x2]));
  117.     else
  118.         y = NaN;
  119.     end
  120. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top