<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Guys, I’ve tried it both ways, and it never seems to change the objective using the command line clp,&nbsp;<div><br></div><div>But the interesting thing is that if I hard-code it into C++ with the attached code, and flip the signs on the objective function, then it seems to work. So, the objective optimization is always a minimization in Clp?<br><div><br></div><div><br></div><div>Here is the output, first with the pos cooef, then with a neg cooef changed in the mps:</div><div><br></div><div><div>./clp exmip1.mps -primalsimplex</div><div>Coin LP version 1.16, build Feb 17 2015</div><div>command line - ./clp test.mps -primalsimplex</div><div>At line 20 NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EXAMPLE</div><div>At line 21 ROWS</div><div>At line 25 COLUMNS</div><div>At line 31 RHS</div><div>At line 35 BOUNDS</div><div>At line 41 ENDATA</div><div>Problem EXAMPLE has 2 rows, 4 columns and 6 elements</div><div>Model was imported from ./exmip1.mps in 0.000162 seconds</div><div>Presolve 0 (-2) rows, 0 (-4) columns and 0 (-6) elements</div><div>Empty problem - 0 rows, 0 columns and 0 elements</div><div>Optimal - objective value 0</div><div>After Postsolve, objective 0, infeasibilities - dual 0 (0), primal 0 (0)</div><div>Optimal objective 0 - 0 iterations time 0.002, Presolve 0.00</div><div>./clp exmip1.mps -primalsimplex</div><div>Coin LP version 1.16, build Feb 17 2015</div><div>command line - ./clp exmip1.mps -primalsimplex</div><div>At line 20 NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EXAMPLE</div><div>At line 21 ROWS</div><div>At line 25 COLUMNS</div><div>At line 31 RHS</div><div>At line 35 BOUNDS</div><div>At line 41 ENDATA</div><div>Problem EXAMPLE has 2 rows, 4 columns and 6 elements</div><div>Model was imported from ./test.mps in 0.000343 seconds</div><div>Presolve 0 (-2) rows, 0 (-4) columns and 0 (-6) elements</div><div>Empty problem - 0 rows, 0 columns and 0 elements</div><div>Optimal - objective value -1</div><div>After Postsolve, objective -1, infeasibilities - dual 0 (0), primal 0 (0)</div><div>Optimal objective -1 - 0 iterations time 0.002, Presolve 0.00</div><div><br></div><div><br></div><div>At first I hard-coded it into C++, with the following code, and same results, which are attached below.&nbsp;</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span style="color: #931a68">int</span> main(<span style="color: #931a68">int</span> argc, <span style="color: #931a68">const</span> <span style="color: #931a68">char</span> *argv[])</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">{</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #006141">ClpSimplex</span>&nbsp; model;</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">/*</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">Maximize</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">objective1_objf:</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">+ 1.0 R2</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">Subject To</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">&nbsp;A: +R1 +0R2 -X1 -X2 = 0</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">&nbsp;B: 0R1 -R2&nbsp; +X1 +X2 = 0</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">Bounds</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">&nbsp;R1 &lt;= 1.0</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">&nbsp;0.0 &lt;= R2 &lt;= +inf</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">&nbsp;0.0 &lt;= X1 &lt;= +inf</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">&nbsp;0.0 &lt;= X2 &lt;= +inf</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">1&nbsp; 0 −1 −1</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">0 −1&nbsp; 1&nbsp; 1</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);">&nbsp;*/</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">int</span> numberRows = 2;</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">int</span> numberColumns = 4;</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">int</span> numberElements = 6;</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);"><span style="color: #000000">&nbsp; &nbsp; </span>// matrix data - column ordered</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">int</span> start[5] = &nbsp; &nbsp; &nbsp; {0, 1, 2, 4, 6};</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">int</span> length[4] =&nbsp; &nbsp; &nbsp; {1, 1, 2, 2};</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">int</span> rows[6] =&nbsp; &nbsp; &nbsp; &nbsp; {0, &nbsp; 1, &nbsp; 0,&nbsp; 1, &nbsp; 0,&nbsp; 1 };</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">double</span> elements[6] = {1., -1., -1., 1., -1., 1.};</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #006141">CoinPackedMatrix</span> matrix(<span style="color: #931a68">true</span>, numberRows, numberColumns, numberElements, elements, rows, start, length);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">for</span>(<span style="color: #931a68">int</span> i = 0; i &lt; numberRows; ++i) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span class="Apple-tab-span" style="white-space:pre">        </span><span style="color: #931a68">for</span>(<span style="color: #931a68">int</span> j = 0; j &lt; numberColumns; j++) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span class="Apple-tab-span" style="white-space:pre">                </span>printf(<span style="color: #3933ff">"%i, %i, %f\n"</span>, i, j, matrix.<span style="color: #793d93">getCoefficient</span>(i, j));</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;">&nbsp; &nbsp;&nbsp;<span style="color: rgb(78, 144, 114);">// Have to flip the sign on the objective, is this right, seems to work???????</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">double</span> objective[4] = {0, -1, 0, 0};</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">double</span> rowLower[2] = {0., 0.};</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">double</span> rowUpper[2] = {0, 0};</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">double</span> colLower[4] = {0, 0, 0, 0};</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">double</span> colUpper[4] = {1., COIN_DBL_MAX, COIN_DBL_MAX, COIN_DBL_MAX};</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);"><span style="color: #000000">&nbsp; &nbsp; </span>// load problem</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; model.<span style="color: #793d93">loadProblem</span>(matrix, colLower, colUpper, objective,</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowLower, rowUpper);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);"><span style="color: #000000">&nbsp; &nbsp; </span>// Solve</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; model.<span style="color: #793d93">initialSolve</span>();</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);"><span style="color: #000000">&nbsp; &nbsp; </span>// Solve - primal as primal feasible</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; model.<span style="color: #793d93">primal</span>(1);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 144, 114);"><span style="color: #000000">&nbsp; &nbsp; </span>// Solution</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">const</span> <span style="color: #931a68">double</span> * solution = model.primalColumnSolution();</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">for</span> (<span style="color: #931a68">int</span> i = 0; i &lt; numberColumns; i++)</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(<span style="color: #3933ff">"Column %d has value %g\n"</span>, i, solution[i]);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">}</div></div><div><br></div><div><br></div><div>And here is the output:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><div style="margin: 0px;">0, 0, 1.000000</div><div style="margin: 0px;">0, 1, 0.000000</div><div style="margin: 0px;">0, 2, -1.000000</div><div style="margin: 0px;">0, 3, -1.000000</div><div style="margin: 0px;">1, 0, 0.000000</div><div style="margin: 0px;">1, 1, -1.000000</div><div style="margin: 0px;">1, 2, 1.000000</div><div style="margin: 0px;">1, 3, 1.000000</div><div style="margin: 0px;">Coin0506I Presolve 0 (-2) rows, 0 (-4) columns and 0 (-6) elements</div><div style="margin: 0px;">Clp3002W Empty problem - 0 rows, 0 columns and 0 elements</div><div style="margin: 0px;">Clp0000I Optimal - objective value -1</div><div style="margin: 0px;">Coin0511I After Postsolve, objective -1, infeasibilities - dual 0 (0), primal 0 (0)</div><div style="margin: 0px;">Clp0032I Optimal objective -1 - 0 iterations time 0.002, Presolve 0.00</div><div style="margin: 0px;">Clp0006I 0&nbsp; Obj -1</div><div style="margin: 0px;">Clp0000I Optimal - objective value -1</div><div style="margin: 0px;">Column 0 has value 1</div><div style="margin: 0px;">Column 1 has value 1</div><div style="margin: 0px;">Column 2 has value 1</div><div style="margin: 0px;">Column 3 has value 0</div></div></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">B</div><div><br></div><div><br><div><div>On Feb 20, 2015, at 3:13 AM, Babak Moazzez &lt;<a href="mailto:bmoazzez@ucdavis.edu">bmoazzez@ucdavis.edu</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div><div>In the MPS file you should change <br><br>&nbsp;R2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OBJ&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.0&nbsp;&nbsp; <br></div><br>to <br><br>&nbsp;R2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OBJ&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - 1.0&nbsp; .<br><br></div>MPS default is minimization! so this minimizes -R2 which is equivalent to Maximizing R2.<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 19, 2015 at 11:44 PM, Andy Somogyi <span dir="ltr">&lt;<a href="mailto:andy.somogyi@gmail.com" target="_blank">andy.somogyi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi All,<br>
<br>
I’m trying to use Clp, works fine for the built-in examples, but I can’t seem to get this simple attached problem to work. I’ve tried hard-coding this in C++, following the modify.cpp example, and I’ve tried reading it form a mps file, using either the command line clp program, or direction into the ClpModel object via readMps.<br>
<br>
It always results in a zero solution, but this problem has an analytic solution of [1, 1, 1, 0], and Mathematica finds this solution just fine if I import the mps and use NMinimise.<br>
<br>
Any ideas why this simple problem won’t converge to the correct solution in Clp.<br>
<br>
Thanks<br>
<br>
Here is the mps:<br>
<br>
************************************************************************<br>
*<br>
*&nbsp; Maximize<br>
*&nbsp; objective1_objf:<br>
*&nbsp; + 1.0 R2<br>
*<br>
* Subject To<br>
*&nbsp; A: +R1&nbsp; &nbsp; &nbsp; -X1 -X2 = 0<br>
*&nbsp; B:&nbsp; &nbsp; &nbsp;-R2&nbsp; +X1 +X2 = 0<br>
*<br>
*&nbsp; Bounds<br>
*&nbsp; 0.0 &lt;= R1 &lt;= 1.0<br>
*&nbsp; 0.0 &lt;= R2 &lt;= +inf<br>
*&nbsp; 0.0 &lt;= X1 &lt;= +inf<br>
*&nbsp; 0.0 &lt;= X2 &lt;= +inf<br>
*<br>
************************************************************************<br>
NAME&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EXAMPLE<br>
ROWS<br>
&nbsp;N&nbsp; OBJ<br>
&nbsp;E&nbsp; A<br>
&nbsp;E&nbsp; B<br>
COLUMNS<br>
&nbsp; &nbsp; R1&nbsp; &nbsp; &nbsp; &nbsp; A&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1.0<br>
&nbsp; &nbsp; R2&nbsp; &nbsp; &nbsp; &nbsp; OBJ&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1.0&nbsp; &nbsp;B&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-1.0<br>
&nbsp; &nbsp; X1&nbsp; &nbsp; &nbsp; &nbsp; A&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-1.0&nbsp; &nbsp;B&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1.0<br>
&nbsp; &nbsp; X2&nbsp; &nbsp; &nbsp; &nbsp; A&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-1.0&nbsp; &nbsp;B&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1.0<br>
<br>
RHS<br>
&nbsp; &nbsp; RHS1&nbsp; &nbsp; &nbsp; A&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0<br>
&nbsp; &nbsp; RHS1&nbsp; &nbsp; &nbsp; B&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0<br>
<br>
BOUNDS<br>
&nbsp;LO BND1&nbsp; &nbsp; &nbsp; R1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0<br>
&nbsp;UP BND1&nbsp; &nbsp; &nbsp; R1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<br>
&nbsp;LO BND1&nbsp; &nbsp; &nbsp; R2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0<br>
&nbsp;LO BND1&nbsp; &nbsp; &nbsp; X1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0<br>
&nbsp;LO BND1&nbsp; &nbsp; &nbsp; X2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0<br>
ENDATA<br>
<br>
<br>
_______________________________________________<br>
Clp mailing list<br>
<a href="mailto:Clp@list.coin-or.org">Clp@list.coin-or.org</a><br>
<a href="http://list.coin-or.org/mailman/listinfo/clp" target="_blank">http://list.coin-or.org/mailman/listinfo/clp</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr">Babak Moazzez<br>Post Doctoral Scholar<br>University of California Davis<br><br>Email: <a href="mailto:bmoazzez@ucdavis.edu" target="_blank">bmoazzez@ucdavis.edu</a><br>Tel: (530) 752 5076<br></div></div>
</div>
</blockquote></div><br></div></div></div></body></html>