lpsolve and Matlab single precision

View: New views
2 Messages — Rating Filter:   Alert me  

lpsolve and Matlab single precision

by KYOS | Alexander Boogert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Recently I noted lpsolve seems to have a problem with single precision variables in Matlab. In the Matlab reference guide I saw no note on the topic, so let me mention my problem here.

When the objective function is defined using single precision variables, lpsolve gets confused and runs an incorrect optimization. When we transfer the single to double precision (the standard in Matlab) variables, the optimization runs correct.

A small example:
mxlpsolve('set_obj_fn', lp, single(f));
a2=mxlpsolve('get_obj_fn', lp)
mxlpsolve('set_obj_fn', lp, double(f));
a3=mxlpsolve('get_obj_fn', lp)
a2(1:3) gives  ans =  -30.4460  -30.3623  -30.2783
a3(1:3) gives ans =   -2.9763   -2.9757   -2.9750

The second setting produces good results, the first one doesn't. At the moment I set by default all values back to double.

regards Alexander


Re: lpsolve and Matlab single precision

by peter_notebaert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Indeed. The next version of the driver will support all numerical datatypes. So also single, int8, int16, int32.

Peter


From: alexanderboogert
Sent: Friday, September 11, 2009 12:37
To: lp_solve@...
Subject: [lp_solve] lpsolve and Matlab single precision


  Hi,

Recently I noted lpsolve seems to have a problem with single precision variables in Matlab. In the Matlab reference guide I saw no note on the topic, so let me mention my problem here.

When the objective function is defined using single precision variables, lpsolve gets confused and runs an incorrect optimization. When we transfer the single to double precision (the standard in Matlab) variables, the optimization runs correct.

A small example:
mxlpsolve('set_obj_fn', lp, single(f));
a2=mxlpsolve('get_obj_fn', lp)
mxlpsolve('set_obj_fn', lp, double(f));
a3=mxlpsolve('get_obj_fn', lp)
a2(1:3) gives ans = -30.4460 -30.3623 -30.2783
a3(1:3) gives ans = -2.9763 -2.9757 -2.9750

The second setting produces good results, the first one doesn't. At the moment I set by default all values back to double.

regards Alexander