<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://tomwiki.com/index.php?action=history&amp;feed=atom&amp;title=Quickguide_MCP_Problem</id>
	<title>Quickguide MCP Problem - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://tomwiki.com/index.php?action=history&amp;feed=atom&amp;title=Quickguide_MCP_Problem"/>
	<link rel="alternate" type="text/html" href="http://tomwiki.com/index.php?title=Quickguide_MCP_Problem&amp;action=history"/>
	<updated>2026-11-01T22:08:06Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>http://tomwiki.com/index.php?title=Quickguide_MCP_Problem&amp;diff=2532&amp;oldid=prev</id>
		<title>Elias at 22:28, 17 January 2012</title>
		<link rel="alternate" type="text/html" href="http://tomwiki.com/index.php?title=Quickguide_MCP_Problem&amp;diff=2532&amp;oldid=prev"/>
		<updated>2012-01-17T22:28:20Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:28, 17 January 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l45&quot;&gt;Line 45:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 45:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Open the file for viewing, and execute mcpQG in Matlab.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Open the file for viewing, and execute mcpQG in Matlab.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight &lt;/del&gt;lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;source &lt;/ins&gt;lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  % mcpQG.m&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  % mcpQG.m&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  %&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  %&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l175&quot;&gt;Line 175:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 175:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  %&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  %&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  % I.e, we have the complementarity conditions satisfied.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  % I.e, we have the complementarity conditions satisfied.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;source&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Elias</name></author>
	</entry>
	<entry>
		<id>http://tomwiki.com/index.php?title=Quickguide_MCP_Problem&amp;diff=866&amp;oldid=prev</id>
		<title>Elias at 06:42, 11 August 2011</title>
		<link rel="alternate" type="text/html" href="http://tomwiki.com/index.php?title=Quickguide_MCP_Problem&amp;diff=866&amp;oldid=prev"/>
		<updated>2011-08-11T06:42:07Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 01:42, 11 August 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{Part Of Manual|title=the Quickguide Manual|link=[[Quickguide|Quickguide]]}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;TOMLAB requires that general nonlinear complementarity problems are defined in Matlab m-files. The function to be optimized does not need to be supplied (pure equilibrium problem). It is recommended that the user supply as many analytical functions as possible.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;TOMLAB requires that general nonlinear complementarity problems are defined in Matlab m-files. The function to be optimized does not need to be supplied (pure equilibrium problem). It is recommended that the user supply as many analytical functions as possible.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Elias</name></author>
	</entry>
	<entry>
		<id>http://tomwiki.com/index.php?title=Quickguide_MCP_Problem&amp;diff=865&amp;oldid=prev</id>
		<title>Elias: Created page with &quot;TOMLAB requires that general nonlinear complementarity problems are defined in Matlab m-files. The function to be optimized does not need to be supplied (pure equilibrium problem...&quot;</title>
		<link rel="alternate" type="text/html" href="http://tomwiki.com/index.php?title=Quickguide_MCP_Problem&amp;diff=865&amp;oldid=prev"/>
		<updated>2011-08-11T06:41:55Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;TOMLAB requires that general nonlinear complementarity problems are defined in Matlab m-files. The function to be optimized does not need to be supplied (pure equilibrium problem...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;TOMLAB requires that general nonlinear complementarity problems are defined in Matlab m-files. The function to be optimized does not need to be supplied (pure equilibrium problem). It is recommended that the user supply as many analytical functions as possible.&lt;br /&gt;
&lt;br /&gt;
The constrained nonlinear complementarity problem is defined as:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{ll}&lt;br /&gt;
\min\limits_{x} &amp;amp; f(x) \\&lt;br /&gt;
&amp;amp;  \\&lt;br /&gt;
s/t &amp;amp; \begin{array}{lcccl}&lt;br /&gt;
x_{L} &amp;amp; \leq  &amp;amp; x    &amp;amp; \leq &amp;amp; x_{U} \\&lt;br /&gt;
b_{L} &amp;amp; \leq  &amp;amp; A x  &amp;amp; \leq &amp;amp; b_{U} \\&lt;br /&gt;
c_{L} &amp;amp; \leq  &amp;amp; c(x) &amp;amp; \leq &amp;amp; c_{U} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The complementarity conditions can be any combination of decision variables and linear/nonlinear constraints:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;math&amp;gt;x(i) \perp x(j)&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;x(i) \perp A(j,:) x&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;x(i) \perp c(j)&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;A(i,:) x \perp A(j,:) x&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;A(i,:) x \perp c(j)&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;c(i) \perp c(j)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following files define the problem in TOMLAB.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;File: &amp;#039;&amp;#039;&amp;#039;&amp;lt;span class=&amp;quot;roman&amp;quot;&amp;gt;tomlab/quickguide/mcpQG_f.m, mcpQG_g.m, mcpQG_H.m, mcpQG_c.m, mcpQG_dc.m, mcpQG_d2c.m&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
f:   Function value&lt;br /&gt;
g:   Gradient vector&lt;br /&gt;
H:   Hessian matrix&lt;br /&gt;
c:   Nonlinear constraint vector&lt;br /&gt;
dc:  Nonlinear constraint gradient matrix&lt;br /&gt;
d2c: The second part of the Hessian to the Lagrangian function for the nonlinear constraints.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following file illustrates how to solve a MCP problem in TOMLAB. Also view the m-files specified above for more information.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;File: &amp;#039;&amp;#039;&amp;#039;&amp;lt;span class=&amp;quot;roman&amp;quot;&amp;gt;tomlab/quickguide/mcpQG.m&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Open the file for viewing, and execute mcpQG in Matlab.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
 % mcpQG.m&lt;br /&gt;
 %&lt;br /&gt;
 % Demonstrates how to setup and solve a nonlinear problem with equilibrium&lt;br /&gt;
 % (complementary) constraints.&lt;br /&gt;
 %&lt;br /&gt;
 % TOMLAB /KNITRO is capable of solving general complementarity problems&lt;br /&gt;
 %&lt;br /&gt;
 % The problem is the following:&lt;br /&gt;
 %&lt;br /&gt;
 % minimize  f = (x(1)-5)^2 + (2*x(2)+1)^2&lt;br /&gt;
 %&lt;br /&gt;
 % subject to&lt;br /&gt;
 %&lt;br /&gt;
 %    2*(x(2)-1) - 1.5*x(1) + x(3) - 0.5*x(4) + x(5) ==0   % c(1)&lt;br /&gt;
 %     3*x(1) - x(2) - 3     &amp;amp;gt;= 0                           % c(2)&lt;br /&gt;
 %      -x(1) + 0.5*x(2) + 4 &amp;amp;gt;= 0                           % c(3)&lt;br /&gt;
 %      -x(1) -     x(2) + 7 &amp;amp;gt;= 0                           % c(4)&lt;br /&gt;
 %&lt;br /&gt;
 %    x(1:5) &amp;amp;gt;= 0&lt;br /&gt;
 %&lt;br /&gt;
 % The following complementarity demands are also imposed:&lt;br /&gt;
 %&lt;br /&gt;
 %   0 &amp;amp;lt;= c(2) _|_ x(3) &amp;amp;gt;= 0&lt;br /&gt;
 %   0 &amp;amp;lt;= c(3) _|_ x(4) &amp;amp;gt;= 0&lt;br /&gt;
 %   0 &amp;amp;lt;= c(4) _|_ x(5) &amp;amp;gt;= 0&lt;br /&gt;
 %&lt;br /&gt;
 % All four constraints are in fact linear, but are modelled as nonlinear&lt;br /&gt;
 % constraints with the constants moved to the LHS.&lt;br /&gt;
 %&lt;br /&gt;
 % The same problem is solved as a explicitly quadratic complementarity&lt;br /&gt;
 % problem in qcpQG.m&lt;br /&gt;
 &lt;br /&gt;
 % There are no (explicitly) linear constraints.&lt;br /&gt;
 A   = [];&lt;br /&gt;
 b_L = [];&lt;br /&gt;
 b_U = [];&lt;br /&gt;
 &lt;br /&gt;
 % Provide a pattern for the nonlinear constraints&lt;br /&gt;
 ConsPattern = [&lt;br /&gt;
     1 1 1 1 1&lt;br /&gt;
     1 1 1 0 0&lt;br /&gt;
     1 1 0 0 0&lt;br /&gt;
     1 1 0 0 0&lt;br /&gt;
     ];&lt;br /&gt;
 &lt;br /&gt;
 HessPattern = [];&lt;br /&gt;
 &lt;br /&gt;
 % First constraint is equality ==0, the remaining are &amp;amp;gt;= 0&lt;br /&gt;
 c_L = [0,0,0,0]&amp;#039;;&lt;br /&gt;
 c_U = [0,inf,inf,inf]&amp;#039;;&lt;br /&gt;
 &lt;br /&gt;
 x_L = zeros(5,1);&lt;br /&gt;
 x_U = inf*ones(5,1);&lt;br /&gt;
 x_0 = x_L;&lt;br /&gt;
 &lt;br /&gt;
 Name = &amp;#039;JF Bard 1998 MPEC&amp;#039;;&lt;br /&gt;
 &lt;br /&gt;
 % Functions for calculating the nonlinear function and derivative values.&lt;br /&gt;
 f   = &amp;#039;mcpQG_f&amp;#039;;&lt;br /&gt;
 g   = &amp;#039;mcpQG_g&amp;#039;;&lt;br /&gt;
 H   = &amp;#039;mcpQG_H&amp;#039;;&lt;br /&gt;
 c   = &amp;#039;mcpQG_c&amp;#039;;&lt;br /&gt;
 dc  = &amp;#039;mcpQG_dc&amp;#039;;&lt;br /&gt;
 d2c = &amp;#039;mcpQG_d2c&amp;#039;;&lt;br /&gt;
 &lt;br /&gt;
 % Each row of mpec is one pair. The first says x(3) _|_ c(2) should be&lt;br /&gt;
 % complementary. Exactly two nonzeros per row is allowed.&lt;br /&gt;
 &lt;br /&gt;
 mpec = [ ...&lt;br /&gt;
     3,0, 0,0, 2,0; ...&lt;br /&gt;
     4,0, 0,0, 3,0; ...&lt;br /&gt;
     5,0, 0,0, 4,0; ...&lt;br /&gt;
     ];&lt;br /&gt;
 &lt;br /&gt;
 Prob = mcpAssign(f, g, H, HessPattern, x_L, x_U, Name, x_0, mpec, ...&lt;br /&gt;
     [], ...&lt;br /&gt;
     A, b_L, b_U, c, dc, d2c, ConsPattern, c_L, c_U);&lt;br /&gt;
 &lt;br /&gt;
 Prob.PriLevOpt = 2;&lt;br /&gt;
 &lt;br /&gt;
 % KNITRO options. Algorithm 3 works good on this problem.&lt;br /&gt;
 opts     = [];&lt;br /&gt;
 opts.ALG = 3;&lt;br /&gt;
 Prob.KNITRO.options = opts;&lt;br /&gt;
 &lt;br /&gt;
 % Now solve this problem with KNITRO:&lt;br /&gt;
 Result = tomRun(&amp;#039;knitro&amp;#039;,Prob,2);&lt;br /&gt;
 &lt;br /&gt;
 % The original problem is available as Prob.orgProb.&lt;br /&gt;
 &lt;br /&gt;
 N0 = Prob.orgProb.N;&lt;br /&gt;
 &lt;br /&gt;
 x = Result.x_k;&lt;br /&gt;
 s = x(N0+1:end)     % The slacks added by BuildMPEC&lt;br /&gt;
 x = x(1:N0)         % The &amp;quot;original&amp;quot; variables&lt;br /&gt;
 &lt;br /&gt;
 % Constraint values for the modified problem. If not infeasible, these&lt;br /&gt;
 % should all be zero because BuildMPEC has changed the constraints in the&lt;br /&gt;
 % mpec pairs to include slack variables.&lt;br /&gt;
 &lt;br /&gt;
 c = Result.c_k&lt;br /&gt;
 &lt;br /&gt;
 % The permutation matrix for the slacks in the nonlinear constraints is&lt;br /&gt;
 % available:&lt;br /&gt;
 &lt;br /&gt;
 MP = full(Prob.MPEC.MP);&lt;br /&gt;
 &lt;br /&gt;
 % The values of the constraints + their respective slacks:&lt;br /&gt;
 &lt;br /&gt;
 C = c + MP*s&lt;br /&gt;
 &lt;br /&gt;
 x(3:5), C(2:4)&lt;br /&gt;
 &lt;br /&gt;
 % This should give something like:&lt;br /&gt;
 %&lt;br /&gt;
 % ans =&lt;br /&gt;
 %&lt;br /&gt;
 %     3.5000&lt;br /&gt;
 %          0&lt;br /&gt;
 %          0&lt;br /&gt;
 %&lt;br /&gt;
 %&lt;br /&gt;
 % ans =&lt;br /&gt;
 %&lt;br /&gt;
 %      0&lt;br /&gt;
 %      3&lt;br /&gt;
 %      6&lt;br /&gt;
 %&lt;br /&gt;
 % I.e, we have the complementarity conditions satisfied.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elias</name></author>
	</entry>
</feed>