Speed up Matlab funtion optimset or fsolve

조회 수: 2 (최근 30일)
Quynh tran
Quynh tran 2016년 5월 16일
편집: Quynh tran 2016년 5월 16일
I repaired my post:
pop = [ 17.5489 22.0450 12.3356 0 0 0
24.2207 24.4891 11.6109 0 0 0
14.4916 24.0423 5.3751 0 0 0
15.5933 24.2429 1.5084 0 0 0
14.0768 8.4837 13.5116 0 0 0
23.0225 18.9584 15.0561 0 0 0
24.0094 14.7980 2.2642 0 0 0
22.8346 24.8367 5.7287 0 0 0
22.9392 15.0265 21.5263 0 0 0
24.9098 23.5567 8.0397 0 0 0
12.9304 18.0870 3.6067 0 0 0
10.7218 4.9208 23.2223 0 0 0
18.4719 6.1156 13.3655 0 0 0
7.1474 10.3145 21.6322 0 0 0
24.2926 18.5611 21.2992 0 0 0
8.7695 14.3906 7.3888 0 0 0
9.4825 2.9985 4.1883 0 0 0
19.7259 9.3699 11.3208 0 0 0
14.6069 8.1301 14.1943 0 0 0
21.7199 8.1151 22.3485 0 0 0
1.0794 18.6137 16.8374 0 0 0
13.7829 6.0216 14.2601 0 0 0
15.9794 17.3477 10.1006 0 0 0
16.5683 18.8737 10.2242 0 0 0
16.5552 3.8948 22.9116 0 0 0
21.0076 17.0693 19.1147 0 0 0
12.7140 2.1515 14.9522 0 0 0
7.5796 4.3793 7.7026 0 0 0
13.7626 24.1572 23.8614 0 0 0
9.5798 9.9038 14.7426 0 0 0
13.1142 22.8105 23.3993 0 0 0
4.4876 14.6915 10.0169 0 0 0
3.1052 14.1913 21.2961 0 0 0
15.0551 7.6167 12.4830 0 0 0
17.8893 8.8950 3.4193 0 0 0
2.4890 1.1493 16.6434 0 0 0
14.8805 23.2007 18.4197 0 0 0
22.6164 20.7104 20.8279 0 0 0
4.4673 12.8200 24.1456 0 0 0
16.2761 18.2880 15.7975 0 0 0
24.6292 7.2568 4.6912 0 0 0
18.3555 10.0734 6.3775 0 0 0
5.0947 5.8278 10.4251 0 0 0
14.9085 4.0396 10.6858 0 0 0
10.4061 17.2763 24.1169 0 0 0
2.7613 12.6563 22.6465 0 0 0
3.6709 10.5564 10.4706 0 0 0
6.5381 8.2180 4.5643 0 0 0
10.1283 4.4854 10.8909 0 0 0
14.1282 10.2230 5.9243 0 0 0
23.5585 2.1127 6.2529 0 0 0
24.1545 2.5714 8.1056 0 0 0
11.5353 16.8609 4.1955 0 0 0
7.1352 21.6823 10.7806 0 0 0
16.5840 16.9111 3.5680 0 0 0
22.2396 9.2008 17.2345 0 0 0
18.5981 13.9947 7.1893 0 0 0
2.9765 24.6996 12.7910 0 0 0
13.8668 2.4006 21.3071 0 0 0
1.8152 6.2962 1.5340 0 0 0
2.3862 11.2142 15.6256 0 0 0
1.4202 23.4801 6.8175 0 0 0
4.9021 9.4990 8.9636 0 0 0
21.0888 18.8429 13.4654 0 0 0
10.5702 21.0224 19.9158 0 0 0
19.2113 16.6863 7.6894 0 0 0
5.9662 5.3120 8.8289 0 0 0
12.5199 5.2563 5.1281 0 0 0
17.0951 24.5651 11.9476 0 0 0
17.1268 16.9841 18.6717 0 0 0
11.5547 23.8365 1.5220 0 0 0
3.1174 15.5810 13.3654 0 0 0
5.4717 16.0996 13.6953 0 0 0
19.9857 17.1725 5.2883 0 0 0
6.3686 12.0594 13.6691 0 0 0
2.1712 11.9174 8.4521 0 0 0
24.9662 17.5384 3.3057 0 0 0
22.1810 24.8619 19.5151 0 0 0
5.5853 7.9903 20.8547 0 0 0
15.9705 16.3129 12.3720 0 0 0
3.6243 16.5996 15.2950 0 0 0
1.7450 16.6138 17.6058 0 0 0
18.9411 15.2876 9.0251 0 0 0
16.6245 17.9257 6.9308 0 0 0
3.7184 4.2381 7.6155 0 0 0
15.9711 2.9491 1.5460 0 0 0
16.3059 22.6271 2.2782 0 0 0
9.2693 24.7359 22.6225 0 0 0
5.1539 7.8712 1.0588 0 0 0
23.9903 3.0403 6.0633 0 0 0
6.8119 9.3094 3.5283 0 0 0
21.1938 5.9598 19.9863 0 0 0
11.1118 4.7188 18.6718 0 0 0
12.9967 1.6915 19.8843 0 0 0
19.8283 1.0944 24.3935 0 0 0
1.6343 13.8421 9.8628 0 0 0
12.1101 9.7896 23.5194 0 0 0
9.2871 8.9912 1.3104 0 0 0
13.6724 18.1415 4.1001 0 0 0
2.1903 2.8484 17.0288 0 0 0]
for m=1:100
options=optimset('fsolve');
f=@(x)henchung(x,pop,busdata,SpecG,m);
[x,y,h]=fsolve(f,x0,options);
result_line;
pop(m,end) = Ploss*1000;
pop(m,end-1)=Over;
pop(m,end-2)=Delf;
clear x y h;
end;
pop
I want to improve some way to reduce caculation time to run fsolve or optimset.

답변 (2개)

Alan Weiss
Alan Weiss 2016년 5월 16일
It is hard to know what you are asking, because you give code that is not in a loop, so we cannot see what you are really optimizing. As a first guess, I would say don't put the optimset call inside a loop, because you need only call it once. But this might be an irrelevant comment, because you did not show us your real problem, which includes a loop.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 1
Quynh tran
Quynh tran 2016년 5월 16일
thanks for your contribution. My code is not problem. I repaired my code. Please check.

댓글을 달려면 로그인하십시오.


John D'Errico
John D'Errico 2016년 5월 16일
There is no need to call optimset more than once, so why do you think you need to speed it up? Save the options structure, and be done with that.
As far as fsolve goes, everybody wants things to go faster. Solve fewer problems. Get a faster computer. Those are the easy solutions.
Harder is to solve multiple problems in a single call, using a sparse (block diagonal) Jacobian pattern. Since you can in theory solve several hundred problems at once that way, it can gain a bit. (I've typically seen the max gain come from around 100-200 batched subproblems.) It will require good starting values. It will require understanding of how to use options like 'JacobPattern'. It will require setting up the objective function to handle batches of sub-problems.
  댓글 수: 3
Steven Lord
Steven Lord 2016년 5월 16일
Since you didn't show us the source code for the henchung function, it will be impossible for us to offer any concrete suggestions beyond recommending that you profile your henchung function to identify bottlenecks then work to improve the performance of those sections of your code.
Quynh tran
Quynh tran 2016년 5월 16일
편집: Quynh tran 2016년 5월 16일
thaks

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by