From 3beb5bd0369a5f2720d1e653a0329404e74c134e Mon Sep 17 00:00:00 2001 From: mhjensen Date: Thu, 26 Nov 2020 07:06:11 +0100 Subject: [PATCH] update week 48 --- doc/pub/week48/html/._week48-bs013.html | 16 ++++++++-------- doc/pub/week48/html/._week48-bs015.html | 2 +- doc/pub/week48/html/week48-reveal.html | 18 +++++++++--------- doc/pub/week48/html/week48-solarized.html | 18 +++++++++--------- doc/pub/week48/html/week48.html | 18 +++++++++--------- doc/pub/week48/ipynb/ipynb-week48-src.tar.gz | Bin 822634 -> 822634 bytes doc/pub/week48/ipynb/week48.ipynb | 17 +++++++++-------- doc/src/week48/week48.do.txt | 19 ++++++++++--------- 8 files changed, 55 insertions(+), 53 deletions(-) diff --git a/doc/pub/week48/html/._week48-bs013.html b/doc/pub/week48/html/._week48-bs013.html index 3c1d564b3..d7c2da315 100644 --- a/doc/pub/week48/html/._week48-bs013.html +++ b/doc/pub/week48/html/._week48-bs013.html @@ -265,11 +265,11 @@ We remind ourselves about the general problem we want to solve $$ \begin{align*} &\mathrm{min}_{x}\hspace{0.2cm} \frac{1}{2}\boldsymbol{x}^T\boldsymbol{P}\boldsymbol{x}+\boldsymbol{q}^T\boldsymbol{x},\\ \nonumber - &\mathrm{subject\hspace{0.1cm} to} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{x} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{x}=f. + &\mathrm{s.t.} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{x} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{x}=f. \end{align*} $$ -

+Note: we use s.t. for subject to. Let us show how to perform the optmization using a simple case. Assume we want to optimize the following problem $$ \begin{align*} @@ -313,15 +313,15 @@ The following code solves the equations for us import numpy from cvxopt import matrix from cvxopt import solvers -P = matrix(numpy.diag([1,0]), tc=’d’) -q = matrix(numpy.array([3,4]), tc=’d’) -G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc=’d’) -h = matrix(numpy.array([0,0,-15,100,80]), tc=’d’) +P = matrix(numpy.diag([1,0]), tc='d') +q = matrix(numpy.array([3,4]), tc='d') +G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc='d') +h = matrix(numpy.array([0,0,-15,100,80]), tc='d') # Construct the QP, invoke solver sol = solvers.qp(P,q,G,h) # Extract optimal value and solution -sol[’x’] -sol[’primal objective’] +sol['x'] +sol['primal objective']

diff --git a/doc/pub/week48/html/._week48-bs015.html b/doc/pub/week48/html/._week48-bs015.html index 2f2a0ee84..dff4b8890 100644 --- a/doc/pub/week48/html/._week48-bs015.html +++ b/doc/pub/week48/html/._week48-bs015.html @@ -265,7 +265,7 @@ We have the general problem $$ \begin{align*} &\mathrm{min}_{\lambda}\hspace{0.2cm} \frac{1}{2}\boldsymbol{\lambda}^T\boldsymbol{P}\boldsymbol{\lambda}+\boldsymbol{q}^T\boldsymbol{\lambda},\\ \nonumber - &\mathrm{subject\hspace{0.1cm}to} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{\lambda} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{\lambda}=f. + &\mathrm{s.t.} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{\lambda} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{\lambda}=f. \end{align*} $$ diff --git a/doc/pub/week48/html/week48-reveal.html b/doc/pub/week48/html/week48-reveal.html index 7bdb8c9c1..a8e9d41b4 100644 --- a/doc/pub/week48/html/week48-reveal.html +++ b/doc/pub/week48/html/week48-reveal.html @@ -697,12 +697,12 @@ We remind ourselves about the general problem we want to solve $$ \begin{align*} &\mathrm{min}_{x}\hspace{0.2cm} \frac{1}{2}\boldsymbol{x}^T\boldsymbol{P}\boldsymbol{x}+\boldsymbol{q}^T\boldsymbol{x},\\ \nonumber - &\mathrm{subject\hspace{0.1cm} to} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{x} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{x}=f. + &\mathrm{s.t.} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{x} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{x}=f. \end{align*} $$

 
-

+Note: we use s.t. for subject to. Let us show how to perform the optmization using a simple case. Assume we want to optimize the following problem

 
$$ @@ -756,15 +756,15 @@ The following code solves the equations for us import numpy from cvxopt import matrix from cvxopt import solvers -P = matrix(numpy.diag([1,0]), tc=d) -q = matrix(numpy.array([3,4]), tc=d) -G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc=d) -h = matrix(numpy.array([0,0,-15,100,80]), tc=d) +P = matrix(numpy.diag([1,0]), tc='d') +q = matrix(numpy.array([3,4]), tc='d') +G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc='d') +h = matrix(numpy.array([0,0,-15,100,80]), tc='d') # Construct the QP, invoke solver sol = solvers.qp(P,q,G,h) # Extract optimal value and solution -sol[x] -sol[primal objective] +sol['x'] +sol['primal objective'] @@ -800,7 +800,7 @@ We have the general problem $$ \begin{align*} &\mathrm{min}_{\lambda}\hspace{0.2cm} \frac{1}{2}\boldsymbol{\lambda}^T\boldsymbol{P}\boldsymbol{\lambda}+\boldsymbol{q}^T\boldsymbol{\lambda},\\ \nonumber - &\mathrm{subject\hspace{0.1cm}to} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{\lambda} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{\lambda}=f. + &\mathrm{s.t.} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{\lambda} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{\lambda}=f. \end{align*} $$

 
diff --git a/doc/pub/week48/html/week48-solarized.html b/doc/pub/week48/html/week48-solarized.html index 026699991..5cabd62ef 100644 --- a/doc/pub/week48/html/week48-solarized.html +++ b/doc/pub/week48/html/week48-solarized.html @@ -720,11 +720,11 @@ We remind ourselves about the general problem we want to solve $$ \begin{align*} &\mathrm{min}_{x}\hspace{0.2cm} \frac{1}{2}\boldsymbol{x}^T\boldsymbol{P}\boldsymbol{x}+\boldsymbol{q}^T\boldsymbol{x},\\ \nonumber - &\mathrm{subject\hspace{0.1cm} to} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{x} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{x}=f. + &\mathrm{s.t.} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{x} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{x}=f. \end{align*} $$ -

+Note: we use s.t. for subject to. Let us show how to perform the optmization using a simple case. Assume we want to optimize the following problem $$ \begin{align*} @@ -768,15 +768,15 @@ The following code solves the equations for us import numpy from cvxopt import matrix from cvxopt import solvers -P = matrix(numpy.diag([1,0]), tc=d) -q = matrix(numpy.array([3,4]), tc=d) -G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc=d) -h = matrix(numpy.array([0,0,-15,100,80]), tc=d) +P = matrix(numpy.diag([1,0]), tc='d') +q = matrix(numpy.array([3,4]), tc='d') +G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc='d') +h = matrix(numpy.array([0,0,-15,100,80]), tc='d') # Construct the QP, invoke solver sol = solvers.qp(P,q,G,h) # Extract optimal value and solution -sol[x] -sol[primal objective] +sol['x'] +sol['primal objective']











@@ -808,7 +808,7 @@ We have the general problem $$ \begin{align*} &\mathrm{min}_{\lambda}\hspace{0.2cm} \frac{1}{2}\boldsymbol{\lambda}^T\boldsymbol{P}\boldsymbol{\lambda}+\boldsymbol{q}^T\boldsymbol{\lambda},\\ \nonumber - &\mathrm{subject\hspace{0.1cm}to} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{\lambda} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{\lambda}=f. + &\mathrm{s.t.} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{\lambda} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{\lambda}=f. \end{align*} $$ diff --git a/doc/pub/week48/html/week48.html b/doc/pub/week48/html/week48.html index be0846702..62712fe3c 100644 --- a/doc/pub/week48/html/week48.html +++ b/doc/pub/week48/html/week48.html @@ -725,11 +725,11 @@ We remind ourselves about the general problem we want to solve $$ \begin{align*} &\mathrm{min}_{x}\hspace{0.2cm} \frac{1}{2}\boldsymbol{x}^T\boldsymbol{P}\boldsymbol{x}+\boldsymbol{q}^T\boldsymbol{x},\\ \nonumber - &\mathrm{subject\hspace{0.1cm} to} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{x} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{x}=f. + &\mathrm{s.t.} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{x} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{x}=f. \end{align*} $$ -

+Note: we use s.t. for subject to. Let us show how to perform the optmization using a simple case. Assume we want to optimize the following problem $$ \begin{align*} @@ -773,15 +773,15 @@ The following code solves the equations for us import numpy from cvxopt import matrix from cvxopt import solvers -P = matrix(numpy.diag([1,0]), tc=’d’) -q = matrix(numpy.array([3,4]), tc=’d’) -G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc=’d’) -h = matrix(numpy.array([0,0,-15,100,80]), tc=’d’) +P = matrix(numpy.diag([1,0]), tc='d') +q = matrix(numpy.array([3,4]), tc='d') +G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc='d') +h = matrix(numpy.array([0,0,-15,100,80]), tc='d') # Construct the QP, invoke solver sol = solvers.qp(P,q,G,h) # Extract optimal value and solution -sol[’x’] -sol[’primal objective’] +sol['x'] +sol['primal objective']











@@ -813,7 +813,7 @@ We have the general problem $$ \begin{align*} &\mathrm{min}_{\lambda}\hspace{0.2cm} \frac{1}{2}\boldsymbol{\lambda}^T\boldsymbol{P}\boldsymbol{\lambda}+\boldsymbol{q}^T\boldsymbol{\lambda},\\ \nonumber - &\mathrm{subject\hspace{0.1cm}to} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{\lambda} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{\lambda}=f. + &\mathrm{s.t.} \hspace{0.2cm} \boldsymbol{G}\boldsymbol{\lambda} \preceq \boldsymbol{h} \wedge \boldsymbol{A}\boldsymbol{\lambda}=f. \end{align*} $$ diff --git a/doc/pub/week48/ipynb/ipynb-week48-src.tar.gz b/doc/pub/week48/ipynb/ipynb-week48-src.tar.gz index f1c2daebea83876619e4f4faefb198592d438fb4..4b9dbbba2a37bc5444bbcd3f22a4745b704f7354 100644 GIT binary patch delta 53 zcmaDg%jnfCBR2VN4u(^%jcl!KjIC@;t!&J#Y%Hy8tgUQ75%yL#j#f6#RyM9yHtwx# HJSn{ZqL&S> delta 53 zcmaDg%jnfCBR2VN4u&1hjcl!KjIC@;t!&J#Y%Hy8tgUQ75%yL#j#f6#RyM9yHtwx# HJSn{ZpHU5( diff --git a/doc/pub/week48/ipynb/week48.ipynb b/doc/pub/week48/ipynb/week48.ipynb index 5dd1f2f42..b1656ffc5 100644 --- a/doc/pub/week48/ipynb/week48.ipynb +++ b/doc/pub/week48/ipynb/week48.ipynb @@ -634,7 +634,7 @@ "$$\n", "\\begin{align*}\n", " &\\mathrm{min}_{x}\\hspace{0.2cm} \\frac{1}{2}\\boldsymbol{x}^T\\boldsymbol{P}\\boldsymbol{x}+\\boldsymbol{q}^T\\boldsymbol{x},\\\\ \\nonumber\n", - " &\\mathrm{subject\\hspace{0.1cm} to} \\hspace{0.2cm} \\boldsymbol{G}\\boldsymbol{x} \\preceq \\boldsymbol{h} \\wedge \\boldsymbol{A}\\boldsymbol{x}=f.\n", + " &\\mathrm{s.t.} \\hspace{0.2cm} \\boldsymbol{G}\\boldsymbol{x} \\preceq \\boldsymbol{h} \\wedge \\boldsymbol{A}\\boldsymbol{x}=f.\n", "\\end{align*}\n", "$$" ] @@ -643,6 +643,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "Note: we use **s.t.** for subject to. \n", "Let us show how to perform the optmization using a simple case. Assume we want to optimize the following problem" ] }, @@ -747,15 +748,15 @@ "import numpy\n", "from cvxopt import matrix\n", "from cvxopt import solvers\n", - "P = matrix(numpy.diag([1,0]), tc=’d’)\n", - "q = matrix(numpy.array([3,4]), tc=’d’)\n", - "G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc=’d’)\n", - "h = matrix(numpy.array([0,0,-15,100,80]), tc=’d’)\n", + "P = matrix(numpy.diag([1,0]), tc='d')\n", + "q = matrix(numpy.array([3,4]), tc='d')\n", + "G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc='d')\n", + "h = matrix(numpy.array([0,0,-15,100,80]), tc='d')\n", "# Construct the QP, invoke solver\n", "sol = solvers.qp(P,q,G,h)\n", "# Extract optimal value and solution\n", - "sol[’x’] \n", - "sol[’primal objective’]" + "sol['x'] \n", + "sol['primal objective']" ] }, { @@ -802,7 +803,7 @@ "$$\n", "\\begin{align*}\n", " &\\mathrm{min}_{\\lambda}\\hspace{0.2cm} \\frac{1}{2}\\boldsymbol{\\lambda}^T\\boldsymbol{P}\\boldsymbol{\\lambda}+\\boldsymbol{q}^T\\boldsymbol{\\lambda},\\\\ \\nonumber\n", - " &\\mathrm{subject\\hspace{0.1cm}to} \\hspace{0.2cm} \\boldsymbol{G}\\boldsymbol{\\lambda} \\preceq \\boldsymbol{h} \\wedge \\boldsymbol{A}\\boldsymbol{\\lambda}=f.\n", + " &\\mathrm{s.t.} \\hspace{0.2cm} \\boldsymbol{G}\\boldsymbol{\\lambda} \\preceq \\boldsymbol{h} \\wedge \\boldsymbol{A}\\boldsymbol{\\lambda}=f.\n", "\\end{align*}\n", "$$" ] diff --git a/doc/src/week48/week48.do.txt b/doc/src/week48/week48.do.txt index 3f1006fe2..98166a542 100644 --- a/doc/src/week48/week48.do.txt +++ b/doc/src/week48/week48.do.txt @@ -480,10 +480,10 @@ We remind ourselves about the general problem we want to solve !bt \begin{align*} &\mathrm{min}_{x}\hspace{0.2cm} \frac{1}{2}\bm{x}^T\bm{P}\bm{x}+\bm{q}^T\bm{x},\\ \nonumber - &\mathrm{subject\hspace{0.1cm} to} \hspace{0.2cm} \bm{G}\bm{x} \preceq \bm{h} \wedge \bm{A}\bm{x}=f. + &\mathrm{s.t.} \hspace{0.2cm} \bm{G}\bm{x} \preceq \bm{h} \wedge \bm{A}\bm{x}=f. \end{align*} !et - +Note: we use _s.t._ for subject to. Let us show how to perform the optmization using a simple case. Assume we want to optimize the following problem !bt \begin{align*} @@ -529,15 +529,15 @@ The following code solves the equations for us import numpy from cvxopt import matrix from cvxopt import solvers -P = matrix(numpy.diag([1,0]), tc=’d’) -q = matrix(numpy.array([3,4]), tc=’d’) -G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc=’d’) -h = matrix(numpy.array([0,0,-15,100,80]), tc=’d’) +P = matrix(numpy.diag([1,0]), tc='d') +q = matrix(numpy.array([3,4]), tc='d') +G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc='d') +h = matrix(numpy.array([0,0,-15,100,80]), tc='d') # Construct the QP, invoke solver sol = solvers.qp(P,q,G,h) # Extract optimal value and solution -sol[’x’] -sol[’primal objective’] +sol['x'] +sol['primal objective'] !ec !split @@ -566,12 +566,13 @@ We have the general problem !bt \begin{align*} &\mathrm{min}_{\lambda}\hspace{0.2cm} \frac{1}{2}\bm{\lambda}^T\bm{P}\bm{\lambda}+\bm{q}^T\bm{\lambda},\\ \nonumber - &\mathrm{subject\hspace{0.1cm}to} \hspace{0.2cm} \bm{G}\bm{\lambda} \preceq \bm{h} \wedge \bm{A}\bm{\lambda}=f. + &\mathrm{s.t.} \hspace{0.2cm} \bm{G}\bm{\lambda} \preceq \bm{h} \wedge \bm{A}\bm{\lambda}=f. \end{align*} !et + o With a given kernel we can thus define the matrix $\bm{P}$. o The matrix $\bm{P}$ has matrix elements $p_{ij}=y_iy_jK(\bm{x}_i,\bm{x}_j)$. Given a kernel $K$ and the targets $y_i$ this matrix is easy to set up. o The vector $\bm{q}$ is zero.