Page MenuHomec4science

sparse_infeas.html
No OneTemporary

File Metadata

Created
Sun, Jul 13, 06:34

sparse_infeas.html

<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Finding a point that satisfies many linear inequalities</title>
<link rel="canonical" href="http://cvxr.com/cvx/examples/sparse_heuristics/html/sparse_infeas.html">
<link rel="stylesheet" href="../../examples.css" type="text/css">
</head>
<body>
<div id="header">
<h1>Finding a point that satisfies many linear inequalities</h1>
Jump to:&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#source">Source code</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#output">Text output</a>
&nbsp;&nbsp;&nbsp;&nbsp;
Plots
&nbsp;&nbsp;&nbsp;&nbsp;<a href="../../index.html">Library index</a>
</div>
<div id="content">
<a id="source"></a>
<pre class="codeinput">
<span class="comment">% Section 11.4.1, Boyd &amp; Vandenberghe "Convex Optimization"</span>
<span class="comment">% Written for CVX by Almir Mutapcic - 02/18/06</span>
<span class="comment">%</span>
<span class="comment">% We consider a set of linear inequalities A*x &lt;= b which are</span>
<span class="comment">% infeasible. Here A is a matrix in R^(m-by-n) and b belongs</span>
<span class="comment">% to R^m. We apply a heuristic to find a point x that violates</span>
<span class="comment">% only a small number of inequalities.</span>
<span class="comment">%</span>
<span class="comment">% We use the sum of infeasibilities heuristic:</span>
<span class="comment">%</span>
<span class="comment">% minimize sum( max( Ax - b ) )</span>
<span class="comment">%</span>
<span class="comment">% which is equivalent to the following LP (book pg. 580):</span>
<span class="comment">%</span>
<span class="comment">% minimize sum( s )</span>
<span class="comment">% s.t. Ax &lt;= b + s</span>
<span class="comment">% s &gt;= 0</span>
<span class="comment">%</span>
<span class="comment">% with variables x in R^n and s in R^m.</span>
<span class="comment">% problem dimensions (m inequalities in n-dimensional space)</span>
m = 150;
n = 10;
<span class="comment">% fix random number generator so we can repeat the experiment</span>
seed = 0;
randn(<span class="string">'state'</span>,seed);
<span class="comment">% construct infeasible inequalities</span>
A = randn(m,n);
b = randn(m,1);
fprintf(1, [<span class="string">'Starting with an infeasible set of %d inequalities '</span> <span class="keyword">...</span>
<span class="string">'in %d variables.\n'</span>],m,n);
<span class="comment">% sum of infeasibilities heuristic</span>
cvx_begin
variable <span class="string">x(n)</span>
minimize( sum( max( A*x - b, 0 ) ) )
cvx_end
<span class="comment">% full LP version of the sum of infeasibilities heuristic</span>
<span class="comment">% cvx_begin</span>
<span class="comment">% variables x(n) s(m)</span>
<span class="comment">% minimize( sum( s ) )</span>
<span class="comment">% subject to</span>
<span class="comment">% A*x &lt;= b + s;</span>
<span class="comment">% s &gt;= 0;</span>
<span class="comment">% cvx_end</span>
<span class="comment">% number of satisfied inequalities</span>
nv = length( find( A*x &gt; b ) );
fprintf(1,<span class="string">'\nFound an x that violates %d out of %d inequalities.\n'</span>,nv,m);
</pre>
<a id="output"></a>
<pre class="codeoutput">
Starting with an infeasible set of 150 inequalities in 10 variables.
Calling SDPT3: 310 variables, 150 equality constraints
------------------------------------------------------------
num. of constraints = 150
dim. of linear var = 300
dim. of free var = 10 *** convert ublk to lblk
*******************************************************************
SDPT3: Infeasible path-following algorithms
*******************************************************************
version predcorr gam expon scale_data
NT 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap prim-obj dual-obj cputime
-------------------------------------------------------------------
0|0.000|0.000|9.3e-01|2.5e+01|1.7e+05| 4.383995e+03 0.000000e+00| 0:0:00| chol 1 1
1|1.000|0.987|4.2e-06|6.2e-01|7.6e+03| 3.991454e+03 -1.223258e+01| 0:0:00| chol 1 1
2|1.000|0.798|2.6e-07|1.5e-01|1.5e+03| 1.211162e+03 -1.254138e+01| 0:0:00| chol 1 1
3|1.000|0.402|5.0e-07|9.0e-02|2.8e+02| 2.298041e+02 -1.026791e+01| 0:0:00| chol 1 1
4|1.000|0.633|1.5e-06|3.3e-02|1.1e+02| 1.061195e+02 6.723112e+00| 0:0:00| chol 1 1
5|1.000|0.384|1.4e-07|2.0e-02|5.5e+01| 6.689249e+01 1.531029e+01| 0:0:00| chol 1 1
6|1.000|0.506|1.1e-07|1.0e-02|2.6e+01| 4.976868e+01 2.503358e+01| 0:0:00| chol 1 1
7|1.000|0.447|2.7e-08|5.6e-03|1.3e+01| 4.252463e+01 3.045013e+01| 0:0:00| chol 1 1
8|0.993|0.561|6.1e-09|2.4e-03|5.3e+00| 3.992375e+01 3.486231e+01| 0:0:00| chol 1 1
9|0.870|0.368|9.1e-10|1.5e-03|3.3e+00| 3.942397e+01 3.623530e+01| 0:0:00| chol 1 1
10|1.000|0.375|2.3e-10|9.7e-04|2.0e+00| 3.912697e+01 3.717954e+01| 0:0:00| chol 1 1
11|1.000|0.573|6.7e-11|4.1e-04|8.5e-01| 3.896721e+01 3.815292e+01| 0:0:00| chol 1 1
12|0.918|0.617|4.4e-12|1.6e-04|3.2e-01| 3.892931e+01 3.862021e+01| 0:0:00| chol 1 1
13|1.000|0.270|7.9e-12|1.2e-04|2.4e-01| 3.892402e+01 3.869888e+01| 0:0:00| chol 1 1
14|1.000|0.240|3.0e-12|8.8e-05|1.8e-01| 3.892422e+01 3.874972e+01| 0:0:00| chol 1 1
15|1.000|0.315|1.3e-12|6.0e-05|1.3e-01| 3.892250e+01 3.880094e+01| 0:0:00| chol 1 1
16|1.000|0.386|4.3e-13|3.7e-05|7.9e-02| 3.891986e+01 3.884472e+01| 0:0:00| chol 1 1
17|0.878|0.582|2.0e-13|1.5e-05|3.3e-02| 3.891773e+01 3.888631e+01| 0:0:00| chol 1 1
18|1.000|0.418|1.6e-13|9.0e-06|1.9e-02| 3.891707e+01 3.889892e+01| 0:0:00| chol 1 1
19|1.000|0.552|1.5e-13|1.1e-05|8.5e-03| 3.891683e+01 3.890872e+01| 0:0:00| chol 1 1
20|1.000|0.979|1.6e-14|4.5e-06|2.1e-04| 3.891677e+01 3.891659e+01| 0:0:00| chol 1 1
21|1.000|0.989|7.9e-16|1.1e-07|5.0e-06| 3.891676e+01 3.891676e+01| 0:0:00| chol 1 1
22|1.000|0.989|1.4e-15|2.6e-09|9.8e-08| 3.891676e+01 3.891676e+01| 0:0:00|
stop: max(relative gap, infeasibilities) &lt; 1.49e-08
-------------------------------------------------------------------
number of iterations = 22
primal objective value = 3.89167630e+01
dual objective value = 3.89167629e+01
gap := trace(XZ) = 9.81e-08
relative gap = 1.24e-09
actual relative gap = 1.08e-09
rel. primal infeas = 1.36e-15
rel. dual infeas = 2.61e-09
norm(X), norm(y), norm(Z) = 1.4e+01, 7.4e+00, 1.2e+01
norm(A), norm(b), norm(C) = 5.7e+01, 1.4e+01, 1.3e+01
Total CPU time (secs) = 0.28
CPU time per iteration = 0.01
termination code = 0
DIMACS: 4.7e-15 0.0e+00 1.7e-08 0.0e+00 1.1e-09 1.2e-09
-------------------------------------------------------------------
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +38.9168
Found an x that violates 57 out of 150 inequalities.
</pre>
</div>
</body>
</html>

Event Timeline