Page MenuHomec4science

simple_LP.html
No OneTemporary

File Metadata

Created
Sun, Jul 13, 00:09

simple_LP.html

<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Builds and solves a simple linear program</title>
<link rel="canonical" href="http://cvxr.com/cvx/examples/html/simple_LP.html">
<link rel="stylesheet" href="../examples.css" type="text/css">
</head>
<body>
<div id="header">
<h1>Builds and solves a simple linear program</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">
echo <span class="string">on</span>
n = 100;
A = randn(0.5*n,n);
b = randn(0.5*n,1);
c = randn(n,1);
d = randn;
cvx_begin
variable <span class="string">x(n)</span>
dual <span class="string">variables</span> <span class="string">y</span> <span class="string">z</span>
minimize( c' * x + d )
subject <span class="string">to</span>
y : A * x == b;
z : x &gt;= 0;
cvx_end
echo <span class="string">off</span>
</pre>
<a id="output"></a>
<pre class="codeoutput">
n = 100;
A = randn(0.5*n,n);
b = randn(0.5*n,1);
c = randn(n,1);
d = randn;
cvx_begin
variable x(n)
dual variables y z
minimize( c' * x + d )
subject to
y : A * x == b;
z : x &gt;= 0;
cvx_end
Calling SDPT3: 100 variables, 50 equality constraints
------------------------------------------------------------
num. of constraints = 50
dim. of linear var = 100
*******************************************************************
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|7.8e+01|1.1e+01|1.2e+04|-2.309348e+01 0.000000e+00| 0:0:00| chol 1 1
1|0.597|0.647|3.2e+01|3.8e+00|5.8e+03|-8.577302e+01 2.271256e+01| 0:0:00| chol 1 1
2|0.589|0.568|1.3e+01|1.7e+00|3.1e+03|-1.687239e+02 3.288953e+01| 0:0:00| chol 1 1
3|0.869|0.468|1.7e+00|8.8e-01|1.9e+03|-4.994737e+02 2.724604e+01| 0:0:00| chol 1 1
4|1.000|0.484|1.0e-04|4.5e-01|1.4e+03|-1.430244e+03 1.184280e+01| 0:0:00| chol 1 1
5|0.267|0.180|7.7e-05|3.7e-01|1.8e+03|-4.863441e+03 9.920809e+00| 0:0:00| chol 1 1
6|0.047|0.050|7.3e-05|3.5e-01|2.6e+03|-1.207280e+04 1.002211e+01| 0:0:00| chol 1 1
7|0.058|0.038|7.0e-05|3.4e-01|6.2e+03|-4.576984e+04 8.830255e+00| 0:0:00| chol 1 1
8|0.017|0.017|6.8e-05|3.3e-01|1.2e+04|-1.136575e+05 8.817247e+00| 0:0:00| chol 1 1
9|0.006|0.008|6.8e-05|3.3e-01|1.8e+04|-1.909380e+05 8.749631e+00| 0:0:00| chol 1 1
10|1.000|0.041|1.8e-07|3.2e-01|1.3e+06|-2.803913e+07 8.194740e+00| 0:0:00| chol 2 2
11|0.034|0.007|7.9e-07|3.2e-01|2.0e+07|-5.379696e+08 8.016508e+00| 0:0:00| chol 2 2
12|1.000|0.024|2.1e-04|3.1e-01|5.4e+09|-4.048675e+11 7.451302e+00| 0:0:00| chol 2 2
stop: primal infeas has deteriorated too much, 1.1e+00
13|1.000|0.011|2.1e-04|3.1e-01|5.4e+09|-4.048675e+11 7.451302e+00| 0:0:00|
prim_inf,dual_inf,relgap = 2.12e-04, 3.08e-01, 1.34e-02
sqlp stop: dual problem is suspected of being infeasible
-------------------------------------------------------------------
number of iterations = 13
residual of dual infeasibility
certificate X = 1.66e-03
reldist to infeas. &lt;= 4.37e-05
Total CPU time (secs) = 0.13
CPU time per iteration = 0.01
termination code = 2
DIMACS: 1.6e-04 0.0e+00 1.2e+00 0.0e+00 -1.0e+00 3.7e-01
-------------------------------------------------------------------
------------------------------------------------------------
Status: Unbounded
Optimal value (cvx_optval): -Inf
echo off
</pre>
</div>
</body>
</html>

Event Timeline