how can I compress many iterations for solving a program?

Hello,
I have created a function that solves a linear program for many iterations, more specifically I am changing the X(i)=X(i)+10^(-4) and I am solving the Linear Program for the new value of the X and I check if this value satisfies an inquality, e.g. X<Y. Value of Y is the output of another function (it has the new X as an input) I have included in the first function. Unfortunately, I am having so many iterations and the execution time is so long. Do you have any ideas about how can I reduce it and make it more efficient?
Thank you in advance.

8 个评论

Can you attach your code? If not, please add a little more details.
Are you trying to locate the boundary at which the inequality is no longer satisfied?
function p=HighestPrice(KFiltered, PriceFiltered, K0)
j = find(KFiltered==K0);
arb=0;
while arb==0
PriceFiltered(j)=PriceFiltered(j)+10^(-4);
[y,arb]=ArbitrageApple(KFiltered,PriceFiltered);
end
p=PriceFiltered(j)-10^(-4);
This is my code. KFiltered and PriceFiltered are two vectors and K0 is an input value from the user. The function 'ArbitrageApple' runs CVX for solving an LP program and it returns y, arb. In this case the initial value of PriceFiltered(j) is 5.35 and the output should be 5.6125. My step here is 10^(-4) so there are more than 2000 iterations. I am waiting for your suggestion.
The code will stop when arb==1 and I will keep the last value of PriceFiltered for which arb==0.
Are the inputs integral? Or could they have fractions?
Ultimately, here the issue is your step size. Unless you can be adaptive or increase the step size somehow, you cannot get out of it.
Without knowing what ArbitrageApple does, we (atleast I) cannot suggest what should be done
the inputs are double vectors. K0 is a double value. ArbitrageApple just solves a linear program for the new x which is an element of PriceFiltered double vector.

回答(1 个)

The HighestPrice code you show above is nearly as fast as you can get. You need to concentrate on making ArbitrageApple faster.

此问题已关闭。

提问:

2014-2-3

关闭:

2021-8-20

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by