0

Ok so I have a script that runs among other things lsqlin optimization function millions of times. To speed up this code I "codegen" it (basically automatically creates some mex files). This is a followup of Linear systems of inequations.

The problem here is that lsqlin as well as other optimization functions are not transformed and need to be called externally, which leads to loss of efficient.

I already found the MINQ toolbox but could not understand how to translate from lsqlin to this. Also found the QPC toolbox which requires a licence, which I am currently waiting.

Does anyone suggest another toolbox and how to convert from lsqlin to that?

General idea to codegen a lsqlin script (as can be seen a link is called and not a full conversion).

CODE:

function main_script()
  coder.extrinsic('lsqlin_script')
  for i=1:10^7
    X=lsqlin_script(A,b,X0)
    ...
  end
end

function X=lsqlin_script(A,b,X0)
  X=lsqlin(eye(2),X0, A, b,[],[],[],[],X0, optimoptions('lsqlin','Display','Off'));
end

RUN:

codegen main_script.m
main_script_mex(INPUTS)
4

1 回答 1

0

If you would describe your original problem I think you could expect more answers.

A possible approach to avoid lsqlin:
Calculate the orthogonal projection of Pxyz onto every plane defined by A and b. Check whether the projections satisfy the inequality requirements. From those which satisfy select the closest point to Pxyz. If no valid point is found then the closest point will be on the intersection of planes. Calculate the shortest distance from Pxyz to every intersection lines... follow the steps applied for projection on planes..

As you can see it is not fully elaborated, you should work out the details if you think it may solve your problem. For these calculations you do not need optimization function.

于 2014-11-06T22:34:08.553 回答