[Coin-lpsolver] Problems coding mex interface

John J Forrest jjforre at us.ibm.com
Fri Jan 21 09:42:09 EST 2005


Johan,

I will look into it at medium priority to get things to work - at least on 
small problems.

John Forrest



Johan Löfberg <loefberg at control.ee.ethz.ch> 
Sent by: coin-lpsolver-bounces at list.coin-or.org
01/20/2005 01:06 PM

To
<coin-lpsolver at list.coin-or.org>
cc

Subject
[Coin-lpsolver] Problems coding mex interface






Hi all,

I sat down today to finish a mex (MATLAB) interface to the CLP solvers, 
but
I seem to get into trouble regarding the QP solver.

I have essentially two problems

1: The simplex method for QP does not return any duals, and the dual 
simplex
fails. This is expected right?, from reading the FAQ.
2: The barrier method for QP gives wrong solutions and crashes. This is
probably due to some mistake by me.

The pseudo-code below shows the structure of my code. For LP problems, it
work as expected. I get the correct solution for all different solvers, 
and
correct dual variables. For QP problems, simplex method work fine (except
the dual variables) but the barrier method fails.

Any hints?

Best,
johan lofberg

//And yes, IANACP (I am not a C programmer)


**** PSEUDO MEX INTERFACE (returns primals in x and duals in lambda)

if simplex
    ClpSimplex * model = new ClpSimplex();
else
    ClpInterior * model = new ClpInterior();
end

model->loadProblem(ncols,nrows,cmatbeg,cmatind,cmatval,lower,upper,obj,lhs,r
hs);
model->loadQuadraticObjective(ncols,cmatbegQ,cmatindQ,cmatvalQ);

 switch (solverchoice)
 {
 case simplex primal:
  {
    model->primal();
  }
    case simplex dual:
  {
    model->dual();
  }
 case barrier:
  {
    ClpCholeskyDense * cholesky = new ClpCholeskyDense();
    model->setCholesky(cholesky);
    model->primalDual();
 }



double *primal;
double *dual;
primal = model->primalColumnSolution();
dual = model->dualRowSolution();
*returncode = model->status();

for ( i=0;i<ncols;i++)
{
    x[i] = primal[i];
}

for ( i=0;i<nrows;i++)
{
    lambda[i] = dual[i];
}

_______________________________________________
Coin-lpsolver mailing list
Coin-lpsolver at list.coin-or.org
http://list.coin-or.org/mailman/listinfo/coin-lpsolver

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/clp/attachments/20050121/7a621c22/attachment.html>


More information about the Clp mailing list