Guest User

Untitled

a guest
Jan 7th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1.  
  2. % Section 11.4.1, Boyd & Vandenberghe "Convex Optimization"
  3. % Written for CVX by Almir Mutapcic - 02/18/06
  4. %
  5. % We consider a set of linear inequalities A*x <= b which are
  6. % infeasible. Here A is a matrix in R^(m-by-n) and b belongs
  7. % to R^m. We apply a heuristic to find a point x that violates
  8. % only a small number of inequalities.
  9. %
  10. % We use the sum of infeasibilities heuristic:
  11. %
  12. % minimize sum( max( Ax - b ) )
  13. %
  14. % which is equivalent to the following LP (book pg. 580):
  15. %
  16. % minimize sum( s )
  17. % s.t. Ax <= b + s
  18. % s >= 0
  19. %
  20. % with variables x in R^n and s in R^m.
  21.  
  22. % problem dimensions (m inequalities in n-dimensional space)
  23. m = 100;
  24. n = 2;
  25.  
  26. one = ones(m,1);
  27. zero = zeros(m,1);
  28.  
  29. fprintf(1, ['Starting with an infeasible set of %d inequalities ' ...
  30. 'in %d variables.\n'],m,n);
  31.  
  32. %sum of infeasibilities heuristic
  33. cvx_begin
  34. variables a_p(n) b_p(1)
  35. minimize( sum( ( ones(m,1) -(X_train*a_p + b_p).* labels_train ) ) )
  36. cvx_end
  37.  
  38. % number of satisfied inequalities
  39. nv = length( find(( ones(m,1) - (X_train*a_p + b_p).* labels_train )< zero));
  40. fprintf(1,'\nFound an x (%d %d %d) that violates %d out of %d inequalities.\n',a_p, b_p,nv,m);
Advertisement
Add Comment
Please, Sign In to add comment