就楼主所讲的,我有一点非常疑惑:
对于很多工程问题做优化设计时,比如说做模型修正,我们是得不到设计参数与目标函数的显式表达的,但是目标函数和设计点之间是存在对应关系的,那么在优化迭代处理过程中,我们是不是对每一步给定的一个设计参数系列都得进行一次有限元模型分析啊?这样就会产生两个问题:1)每次迭代都要做一次有限元分析,对于更加复杂庞大的结构将非常好时,如果迭代次数很多,那么计算量将很大;2)为了配合整个优化分析程序的执行,必须编制专门的程序,或者进行商业软件接口处理,这样很不利于应用商业软件应用。
大家做实际应用都是怎么解决这个问题的啊?最近很郁闷!
sensitivity(灵敏度)的概念?
本人做优化时,不是很清楚软件包是怎么样算出灵敏度来的,它是按怎样的数学公式计算的呢?请教各位专家,教授,以及高手们!
学生在此谢过! 其实现在很多人都在自己编程,一是更清楚整个过程,而是自己算法更简单明了,当然对一般人而言也很有难度 其实基本理论大家都清楚,就是一应用到具体实践中就产生问题了,能不能多讲一讲具体实例阿:@)
例如,我做的是节流降压—小孔喷注复合式消声器,我该怎么优化阿,我试过用体积最小或者消声量最小作目标函数,采用惩罚函数法,但是运行时总是提示“subscript out of range”即第310行“ XO(K) = XZ(K): XM(K) = XZ(K)”有问题,我该怎么解决阿?:@L 你采用什么软件啊,matlab吗?
你这个出错应该不是怎么优化的问题,应该是编程的问题吧
matlab我也不熟悉 原帖由 hhh1234 于 2007-1-5 13:46 发表
其实基本理论大家都清楚,就是一应用到具体实践中就产生问题了,能不能多讲一讲具体实例阿:@)
例如,我做的是节流降压—小孔喷注复合式消声器,我该怎么优化阿,我试过用体积最小或者消声量最小作目标函数 ...
下标超出取值范围,应该是在循环过程中,你取得K值超出XO()、XZ()、 XM()、XZ()中的某一矩阵的阶数了 哦,谢谢你们:handshake ,我用的是Qbasic语言,程序是调用的,应该没问题,问题可能如xinyuxf 说的,我再试试:@) 谢谢大家!
程序是这样的:
10 CLEAR 100
20 REM SUMT PROGRAM OPTIMAR DESIGN
30 INPUT "N="; N
40 INPUT "FK="; FK
50 INPUT "GK="; GK
60 INPUT "HK="; HK
70 DIM x(N), XZ(N), BL(N), BU(N), FX(FK), GX(GK), HX(HK)
80 FOR K = 1 TO N
90 PRINT "X("; K; ")="; : INPUT XZ(K)
100 NEXT K
110 FOR K = 1 TO N
120 PRINT "BL("; K; ")="; : INPUT BL(K)
130 NEXT K
140 FOR K = 1 TO N
150 PRINT "BU("; K; ")="; : INPUT BU(K)
160 NEXT K
170 INPUT "E1="; E1: INPUT "E2="; E2
INPUT "R="; R
200 PRINT "N="; N, "FK="; FK, "GK="; GK, "HK="; HK
210 PRINT "E1="; E1, "E2="; E2, "R="; R
220 FOR K = 1 TO N
230 PRINT "X("; K; ")="; XZ(K), "BL("; K; ")="; BL(K), "BU("; K; ")="; BU(K)
240 NEXT K
250 INPUT "QQ=(00000 OR 55555)"; QQ
260 C = .2: HO = .01: FM = 1E+10
270 M = 265786!: M5 = 2 ^ 35: M6 = M5 * 2: M7 = M6 * 2
280 CY = 0: KT = 0: FU = 0: N1 = N + 1
290 DIM XM, XO, XX, X3(N), S(N1, N)
300 FOR K = 1 TO N
310 XO(K) = XZ(K): XM(K) = XZ(K)
320 NEXT K
330 FOR KI = 1 TO N
340 FOR K = 1 TO N
350 IF KI = K THEN S(KI, K) = 1 ELSE S(KI, K) = 0
360 NEXT K, KI
370 CY = CY + 1
390 PRINT TAB(20); STRING$(40, ".")
400 PRINT : PRINT "CYCLE="; CY, "R="; R
420 FOR K = 1 TO N
430 x(K) = XZ(K)
440 NEXT K
450 GOSUB 3000: FO = Y
460 IF CY <> 1 THEN 560
470 FOR KI = 1 TO GK
480 IF GX(KI) > 1E-15 THEN 550
490 FOR K = 1 TO N
500 GOSUB 2000
510 XZ(K) = BL(K) + Q * (BU(K) - BL(K))
520 NEXT K
530 IF QQ = 55555! THEN PRINT "QQ"
540 GOTO 420
550 NEXT KI
560 GOSUB 6000
570 PRINT "ITER="; KT, "Fo="; FO, "F(X)="; SF, "FUM="; FU
580 FOR K = 1 TO N
590 PRINT TAB(10); "X("; K; ")="; XZ(K)
600 NEXT K
610 FOR K = 1 TO GK
620 IF GX(K) < 1E-15 THEN PRINT STRING$(40, "$"); :GOTO 800
630 NEXT K
640 MZ = 0
650 FOR K = 1 TO N
660 MZ = MZ + (XM(K) - XZ(K)) * (XM(K) - XZ(K))
670 NEXT K
680 MZ = SQR(MZ)
690 IF MZ < E1 THEN 730
700 IF ABS((FM - FO) / FO) < E2 THEN 730
710 IF FM - FO < 0 THEN 730
720 GOTO 750
730 PRINT STRING$(40, "*")
740 PRINT : GOTO 800
750 FM = FO: R = R * C
760 FOR K = 1 TO N
770 XM(K) = XZ(K)
780 NEXT K
790 GOTO 370
800 Q = (SO - SF) / ABS(SO)
810 PRINT "CYCLE="; CY, "R="; R, "FUN="; FU
820 PRINT "ITER="; KT, "Fo="; FO, "F(X)="; SF
830 FOR K = 1 TO N
840 PRINT TAB(25); "X("; K; ")="; XZ(K)
850 NEXT K
860 PRINT "Q="; Q, "Fo="; FO, "F(X)="; SF
870 FOR K = 1 TO FK
880 PRINT "FX("; K; ")="; FX(K)
890 NEXT K
910 FOR K = 1 TO GK
920 PRINT "GX("; K; ")="; GX(K)
930 NEXT K
950 FOR K = 1 TO HK
960 PRINT "HX("; K; ")="; HX(K)
970 NEXT K
980 END
1000 REM FGH PROCEdURE
1010 FX(1) = 0.7854 * ((2 * x(4) ^ 2 - x(1)^2) * x(8) + x(3) ^ 2 * x(7) + x(2) ^ 2 * x(6) + x(1)^2 * x(5)) + 3.1416 * (x(4) * x(12) + x(3) * x(11) + x(2) * x(10) + x(1) * x(9))-(x(17)*x(5)+x(18)*x(6)+x(19)*x(7)+x(20)*x(8))
1020 GX(1) = x(2) - x(1) - 15 * x(13)
1030 GX(2) = x(3) - x(2) - 15 * x(14)
1040 GX(3) = x(4) - x(3) - 15 * x(15)
1041 GX(4) = x(5) - .01607 * x(1)
1042 GX(5) = x(6) - 0.008775* x(2)
1043 GX(6) = x(7) - 0.00479 * x(3)
1044 GX(7) = x(8) - 0.002616* x(4)
1045 GX(8) = x(9) - (4*x(17) * x(21) / (9.87 * x(13) * x(1)) - 1) * .866 * x(21) * x(13)
1046 GX(9) = x(10) - (4*x(20) * x(22) / (9.87 * x(14) * x(2)) - 1) * .866 * x(22) * x(14)
1047 GX(10) = x(11) - (4 * x(19) * x(23) / (9.87 * x(15) * x(3)) - 1) * .866 * x(23) * x(15)
1048 GX(11) = x(12)-(4 * x(20) * x(24) / (9.87 * x(16)^2 * x(4)) - 1) * .866 * x(24)
1049 GX(12) = x(24) - x(16) - 6 * sqrtx(16)
1050 GX(13) = 45.74385 - 10 * lg(x(17) /0.16277)
1070 HX(1) = x(2) - x(1) - 15 * x(13)
1071 HX(2) = x(3) - x(2) - 15 * x(14)
1072 HX(3) = x(4) - x(3) - 15 * x(15)
1073 HX(4) = x(5) - .01607 * x(1)
1074 HX(5) = x(6) - 0.008775* x(2)
1075 HX(6) = x(7) - 0.00479 * x(3)
1076 HX(7) = x(8) - 0.002616* x(4)
1077 HX(8) = x(9) - (4*x(17) * x(21) / (9.87 * x(13) * x(1)) - 1) * .866 * x(21) * x(13)
1078 HX(9) = x(10) - (4*x(20) * x(22) / (9.87 * x(14) * x(2)) - 1) * .866 * x(22) * x(14)
1079 HX(10) = x(11) - (4 * x(19) * x(23) / (9.87 * x(15) * x(3)) - 1) * .866 * x(23) * x(15)
1080 HX(11) = x(12)-(4 * x(20) * x(24) / (9.87 * x(16)^2 * x(4)) - 1) * .866 * x(24)
1081 HX(12) = x(24) - x(16) - 6 * sqrtx(16)
1082 HX(13) = 45.74385 - 10 * lg(x(17) /0.16277)
1090 RETURN
2000 REM RANDOM PROCEDURE
2010 M = M * 5
2020 IF M >= M7 THEN M = M - M7
2030 IF M >= M6 THEN M = M - M6
2040 IF M >= M5 THEN M = M - M5
2050 Q = M / M5
2060 RETURN
3000 REM FUNCT(X,Y) PROCEDURE
3010 GOSUB 1000
3020 FU = FU + 1
3030 SF = 0: SG = 0: SH = 0
3040 FOR K = 1 TO FK
3050 SF = SF + FX(K)
3060 NEXT K
3070 FOR K = 1 TO GK
3080 SG = SG + 1 / GX(K)
3090 NEXT K
3100 FOR K = 1 TO HK
3110 SH = SH + HX(K) * HX(K)
3120 NEXT K
3130 Y = SF + R * SG + SH / SQR(R)
3140 IF FU = 1 THEN SO = SF
3150 IF FU <> 1 THEN 3340
3160 PRINT "R="; R, "Y="; Y
3170 PRINT "SF="; SF, "SG="; SG, "SH="; SH
3180 FOR K = 1 TO N
3190 PRINT "X("; K; ")="; x(K),
3200 NEXT K
3220 FOR K = 1 TO FK
3230 PRINT "FX("; K; ")="; FX(K),
3240 NEXT K
3260 FOR K = 1 TO GK
3270 PRINT "GX("; K; ")="; GX(K),
3280 NEXT K
3300 FOR K = 1 TO HK
3310 PRINT "HX("; K; ")="; HX(K),
3320 NEXT K
3340 RETURN
4000 REM PENALTY(T,Y) PROCEDURE
4010 T0 = T - T0
4020 FOR K = 1 TO N
4030 XX(K) = XX(K) + T0 * S(KI, K)
4040 NEXT K
4050 T0 = T
4060 FOR K = 1 TO N
4070 x(K) = XX(K)
4080 NEXT K
4090 GOSUB 3000
4100 RETURN
5000 REM LINEMIN(Ho,T,Y) PROCEDURE
5010 FOR K = 1 TO N
5020 XX(K) = XZ(K)
5030 NEXT K
5040 HT = HO: T2 = HO
5050 T0 = 0: T1 = 0: Y1 = YO
5060 T = T2: GOSUB 4000
5065 Y2 = Y
5070 FOR K = 1 TO GK
5080 IF GX(K) > 1E-15 THEN 5120
5090 IF ABS(T2) > .0000001 THEN 5110
5100 T2 = 0: Y2 = YO: GOTO 5570
5110 T2 = T2 * .5: GOTO 5060
5120 NEXT K
5130 IF Y2 < Y1 THEN 5170
5140 HT = -HT: T3 = T1: Y3 = Y1
5150 T1 = T2: Y1 = Y2
5160 T2 = T3: Y2 = Y3
5170 T3 = T2 + HT
5180 T = T3: GOSUB 4000: Y3 = Y
5190 FOR K = 1 TO GK
5200 IF GX(K) > 1E-15 THEN 5230
5210 IF ABS(HT) < .0000001 THEN 5570
5220 HT = HT * .5: GOTO 5170
5230 NEXT K
5240 IF Y2 < Y3 THEN 5270
5250 HT = HT + HT
5260 GOTO 5150
5270 IF ABS(T2 - T1) < 1E-10 THEN 5570
5280 IF ABS(T2 - T3) < 1E-10 THEN 5570
5290 C1 = (Y3 - Y1) / (T3 - T1)
5300 C2 = ((Y2 - Y1) / (T2 - T1) - C1) / (T2 - T3)
5310 IF ABS(C2) < 1E-10 THEN 5570
5320 T4 = .5 * (T1 + T3 - C1 / C2)
5330 IF (T4 - T1) * (T3 - T4) <= 0 THEN 5570
5340 T = T4: GOSUB 4000: Y4 = Y
5350 FOR K = 1 TO GK
5360 IF GX(K) > 1E-15 THEN 5380
5370 GOTO 5570
5380 NEXT K
5390 IF ABS(Y2) < 1 THEN A = 1 ELSE A = Y2
5400 IF ABS((Y2 - Y4) / A) < E1 THEN 5440
5410 IF ABS(T2 - T1) < 1E-15 THEN 5440
5420 IF ABS(T2 - T3) < 1E-15 THEN 5440
5430 GOTO 5450
5440 IF Y2 > Y4 THEN 5580 ELSE 5570
5450 IF (T4 - T2) * HT < 0 THEN 5510
5460 IF Y2 < Y4 THEN 5490
5470 T1 = T2: Y1 = Y2: T2 = T4: Y2 = Y4
5480 GOTO 5500
5490 T3 = T4: Y3 = Y4
5500 GOTO 5560
5510 IF Y2 < Y4 THEN 5550
5520 T3 = T2: Y3 = Y2
5530 T2 = T4: Y2 = Y4
5540 GOTO 5560
5550 T1 = T4: Y1 = Y4
5560 GOTO 5290
5570 T = T2: Y = Y2: GOTO 5590
5580 T = T4: Y = Y4
5590 RETURN
6000 REM MINIMIZE PROCEDURE
6010 DX = 1E+10
6020 KT = KT + 1
6030 IF DX < E1 THEN 6660
6040 YO = FO: F1 = FO: DM = 0: DI = 1
6050 FOR KI = 1 TO N
6060 GOSUB 5000: F2 = Y
6070 FOR K = 1 TO N
6080 XZ(K) = XZ(K) + T * S(KI, K)
6090 NEXT K
6100 FOR K = 1 TO N
6110 x(K) = XZ(K)
6120 NEXT K
6130 GOSUB 3000: F2 = Y
6140 DF = F1 - F2: YO = F2: F1 = F2
6150 IF DF < DM THEN 6170
6160 DM = DF: DI = KI
6170 NEXT KI
6180 DX = 0
6190 FOR K = 1 TO N
6200 DX = DX + (XZ(K) - XO(K)) * (XZ(K) - XO(K))
6210 NEXT K
6220 DX = SQR(DX)
6230 FOR K = 1 TO N
6240 X3(K) = 2 * XZ(K) - XO(K)
6250 S(N + 1, K) = XZ(K) - XO(K)
6260 NEXT K
6270 FOR K = 1 TO N
6280 x(K) = X3(K)
6290 NEXT K
6300 GOSUB 3000: F3 = Y
6310 FOR K = 1 TO GK
6320 IF GX(K) < 1E-15 THEN 6610
6330 NEXT K
6340 IF F3 > FO THEN 6540
6345 U = (FO - F2 - DM) * (FO - F2 - DM): V = (FO - F3) * (FO - F3)
6350 IF (FO - 2 * F2 + F3) * U < .5 * DM * V THEN 6360 ELSE 6540
6360 FOR KI = DI TO N
6370 FOR K = 1 TO N
6380 S(KI, K) = S(KI + 1, K)
6390 NEXT K, KI
6400 YO = Y2
6410 GOSUB 5000: FO = Y
6420 FOR K = 1 TO N
6430 XZ(K) = XZ(K) + T * S(N, K)
6440 XO(K) = XZ(K)
6450 NEXT K
6460 FOR K = 1 TO N
6470 x(K) = XZ(K)
6480 NEXT K
6490 GOSUB 3000: FO = Y
6500 FOR K = 1 TO GK
6510 IF GX(K) < 1E-15 THEN 6540
6520 NEXT K
6530 GOTO 6650
6540 IF F3 > F2 THEN 6610
6550 FO = F3
6560 FOR K = 1 TO N
6570 XO(K) = X3(K)
6580 XZ(K) = X3(K)
6590 NEXT K
6600 GOTO 6650
6610 FOR K = 1 TO N
6620 XO(K) = XZ(K)
6630 NEXT K
6640 FO = F2
6650 GOTO 6020
6660 KT = KT - 1
6670 RETURN
6680 REM THE END!
麻烦大家帮我看看阿,程序是调用的惩罚函数法,1010~1082行是我添加的,其中1010行是目标函数,1020~1050是不等式约束,1070~1082是等式约束。
非常感谢!!! 哈哈,还在学习,我觉得学习优化方法最重要的是怎样在设计每个产品是能有目的的用上。 强烈支持开一个班 优化软件,国产的1stOpt和国外的Lingo都很不错! 我也在做优化,可是用的都是别人的模型,用ansys软件,怎样才能生成优化文件啊? 学习了,值得参考 现在软件里用的嵌入的优化算法都是很经典的,换句话说很老的. 但是收敛好. 太新的没人敢用啊 ,不准
页:
1
[2]