第五章 結論與建議
5.2 建議
本研究所應用之混合演算法結合倒傳遞類神經網路架構結合啟發式演算法,未來 建議可針對啟發式演算法做修正,以符合不同品質特性的問題。
在案例中,本研究以「接收訊號強度」做為品質特性,未來根據不同的需求可考 慮以連線品質(link quality)、訊框錯誤率(frame error rate; FER)或傳輸速率(packets per second or throughput)等不同的傳輸品質指標,取代本實驗中的「接收訊號強度」做為 品質特性。另外在評估系統的輸入變數方面,可考慮再加入不同的筆記型電腦或是 PDA、WAP 手機等同時進行預估。利用倒傳遞類神經網路易建立系統模型之能力,
整合所有的傳輸品質之參考指數,可更完整的整合估測系統,為網路規劃者帶來更多 的參考數值,設計出更佳的無線區域網路系統。
參考文獻
一、中文部份
[1] 李善誠,「以混合式螞蟻族群最佳化解決無線通訊頻道指定問題」,國立暨南國際 大學資訊管理學系,碩士論文,民國 94 年。
[2] 林正鄰,「模擬退火與類神經網路在製程最適化之應用」,國立清華大學化學工程 研究所,博士論文,民國 82 年。
[3] 林欣志,「模擬退火法應用於倒傳遞類神經網路之參數調整與屬性篩選」,華梵大 學資訊管理學系,碩士論文,民國 95 年。
[4] 洪饒峰,「田口方法動態系統多品質特性之應用研究」,中原大學工業工程研究 所,碩士論文,民國 85 年。
[5] 周立德,「類神經網路與基因演算法應用於非同步傳送模式網路之研究」,國立台 灣科技大學工程技術研究所,博士論文,民國 83 年。
[6] 周柏宏,「多目標超模式法解參數設計問題之研究—以半導體封裝印字製程為 例」,國立成功大學製造工程研究所,碩士論文,民國92年。
[7] 姜台林,「整合智慧型最佳化參數設計之研究」,國立交通大學工業工程與管理學 系,博士論文,民國 90 年。
[8] 涂育瑋,「應用類神經網路模式與基因演算法則於品質設計之研究」,國立成功大 學工業設計學系,碩士論文,民國 91 年。
[9] 陳士偉,「備用零件存貨管理之研究」,國立台北科技大學商業自動化與管理研 究所,碩士論文,民國 93 年。
[10] 陳文江,「高速無線區域網路的發展與標準制定的近況」,電腦與通訊,第七十 九期,3~8 頁,民國 88 年。
[11] 陳明宏,「多種品質特性在動態系統中之研究」,中原大學工業工程研究所,碩 士論文,民國 83 年。
[12] 章俊彥,「階層式室內定位系統與其服務」,國立中央大學資訊工程研究所,碩 士論文,民國 93 年。
[13] 彭佳芸,「智慧城市 台北未來『無線』」,台視全球資訊網,民國 95 年。
(http://www.ttv.com.tw/news/html/095/06/0950629/095062990606018.htm)
[14] 黃國凌,「螞蟻/塔布混合演算法求解零工型排程問題」,國立台灣科技大學工業 管理系,碩士論文,民國 92 年。
[15] 黃寶賢,「應用物件導向技術及智慧型計算建構半導體製程之最佳化品質控制系 統—以化學機械研磨為例」,大葉大學工業工程學系,碩士論文,民國 91 年。
[16] 張旭華,「運用柔性演算法求解最佳參數設計」,國立交通大學工業工程與管理 學系,博士論文,民國 88 年。
[17] 張家瑲,「結合類神經網路與基因演算法於系統識別」,朝陽科技大學營建工程 系,碩士論文,民國 91 年。
[18] 葉謀銓,「應用啟發式解法求解多項式普羅比模式之最大概似估計值」,暨南國 際大學土木工程學系,碩士論文,民國 92 年。
[19] 詹緒林,「以基因演算法及類神經網路為基礎的電腦輔助和聲編寫系統」,中華 大學電機工程研究所,碩士論文,民國 86 年。
[20] 潘泰吉,「無線區域網路系列-1」,無線電界,第八十卷第六期,73~77 頁,民國 88 年。
[21] 鄒文杰,「應用類神經網路與共通式演算法於參數設計最佳化—以積體電路焊線 製程為例」,國立交通大學工業工程與管理學系,碩士論文,民國 91 年。
[22] 劉吉峰,「分散搜尋法於配水管網最佳化設計之應用」,國立中興大學環境工程 學系,碩士論文,民國 93 年。
[23] 盧炳勳,「組織因素對資訊系統規劃之影響探討」,國立中央大學資訊管理學系,
碩士論文,民國 96 年。
[24] 盧研伯,「混合式模擬退火法應用於具迴流特性流程工廠之研究」,國立台灣科 技大學工業管理系,碩士論文,民國 92 年。
[25] 蕭綱衡,「田口式參數設計在鐵礦燒結之應用研究」,中國統計學報,第二十 八卷第二期,253~275 頁,民國 79 年。
[26] 蘇朝墩,品質工程,初版,台北,中華民國品質學會,民國九十一年。
[27] 魏忠堅,「經濟部技術處通過投入鎂合金低壓成形整合系統技術開發等 5 項計 畫 」 , 產 業 資 訊 服 務 電 子 報 , 第 169 期 , 民 國 95 年 。 (http://cdnet.stpi.org.tw/techroom/policy/policy_06_058.htm)
二、英文部份
[28] Balas, E. and Vazacopoulos, A. (1998) Guided local search with shifting bottleneck for job shop scheduling. Management Science, 44, 262-275.
[29] Bauer Jr., R. J. (1994) Genetic Algorithms and Investment Strategies. John Wiley &
Sons.Behzad, K. P. and Kamgar-Parsi, B. (1990) On problem solving with Hopfield Neural Networks. Biological Cybernetics, 62, 415-423.
[30] Cerny, V. (1985) Thermo dynamical Approach to the Traveling Salesman Problem:
An efficient simulation algorithm. Journal of Optimization Theory and Application, 45, 41-51.
[31] Chan, H. L. and Liang, S. K. (2005) Yield improvement for Blood Glucose Strip by Taguchi Dynamic Approach. International Journal of Information Systems for Logistics and Management, 1(1), 9-16.
[32] Chang, P. T. and Lo, Y. T. (2001) Modeling of job shop scheduling with multiple quantitative and qualitative objectives and a GA/TS mixture approach. International Journal of Computer Integrated Manufacturing, 14, 367-384.
[33] Chang, S. I. and Shivpuri, R. (1995) A Multiple-Objective Decision Making Approach for Assessing Simultaneous Improvement in Die Life Casting Quality in A Die Casting Process. Quality Engineering, 7(2), 371-383.
[34] Chapman, R. E. ( 1996) Photochemistry Multiple Response Co-Optimization.. Quality Engineering, 8(1), 31-45.
[35] Cheung, K. W. (1998) A New Empirical Model for Indoor Propagation Prediction.
IEEE Transactions on Vehicular technology, 47(8), 996-1001.
[36] Chiu, C. C. (1996) Coverage Prediction in Indoor Wireless Communication. IEICE Transactions on Communications, 79(9), 1346-1350.
[37] Chryssolouris, G. and Guillot, M. A.(1990) Comparison of Statistical and AI Approaches to the Selection of Process Parameters in Intelligent Machining.
American Society of Mechanical Engineers Journal of Engineering, 112(2), 122-131.
[38] Cung, V. D., Mautor, T., Michelon, P. and Tavares, A. (1997). A Scatter Search Based Approach for the Quadratic Assignment Problem. IEEE International Conference on Evolutionary Computation, 165-169.
[39] De Jong, K. A. (1987) On Using Genetic Algorithms to Search Program Space.
Proceedings of the Second International Conference on Genetic Algorithm and Their Application, 210-216.
[40] Derringer, G.. and Suich, R. (1980) Simultaneous Optimization of Several Response Variables. Journal of Quality Technology, 12(4), 214-219.
[41] Fleurent, C., Glover, F., Michelon, P. and Valli, Z.(1996) A Scatter Search Approach for Unconstrained Continuous Optimization. Proceedings of IEEE International Conference on Evolutionary Computation, 643 -648.
[42] Fowlkes, W. Y. and Creveling, C. M. (1995) Engineering Methods for Robust Product Design. Addison-Wesley.
[43] Funahashi, K. (1989) On the Approximate Realization of Continuous Mapping by Neural Network. Neural Networks, 2, 183-192.
[44] Glover, F. (1965) A Multiphase Dual Algorithm for the Zero-One Integer Programming Problem. Operations Research, 13(6), 879.
[45] Glover, F. (1986) Future Path for Integer Programming and Links to Articial Intelligence. Computers and Operations Research, 13, 533-549.
[46] Glover, F. (1994) Tabu Search for Nonlinear Parametric Optimization (with links to Genetic Algorithm. Discrete Applied Mathematics, 49, 231-55.
[47] Glover, F. (1999) Scatter search and path relinking. In: Corne D, Dorigo M, Glover F(eds), New Ideas in Optimization, McGraw-Hill, London.
[48] Glover, F. (2000) Laguna M, Marti R, Fundamentals of Scatter Search and Path Relinking. Control and Cybernetics, 39(3), 653-684.
[49] Goik, P., Liddy , J. W. and Taam, W. ( 1995) Use of Desirability Functions to Determine Operating Windows for New Product Designs. Quality Engineering, 7(2), 267-276.
[50] Goldberg, D. E. (1989) Genetic Algorithms in Search, Optimization, and Machine Learning. Addision-Wesley.
[51] Holland, J. (1975) Adaptation in Natural and Artificial Systems. University of Michigan Press.
[52] Ichimura, T., Oeda, S. and Yoshida, K. (2001) An adaptive evolutional euro learning method using genetic search and extraction of rules from trained networks. Journal of Evolutionary Computation, 2, 1343-1350.
[53] Johnson, D. S., Aragon, C. R., McGroch, L. A. and Schevon , C. (1989) Optimization by simulated annealing : An experiment evaluation. Operations
Research, 37, 865-893.
[54] Kohonen, T. (1989) Self-Organization and Associative Memory. Springer-Verlag, Berlin.
[55] Kolonko, M. (1999) Some new results on simulated annealing applied to the job shop scheduling problem. European Journal of Operational Research, 113, 123-136.
[56] Kirkpatrick, S., Gelatt, C. D, and Vecchi, M. P. (1983) Optimization by Simulated Annealing. Science, 220,671-680.
[57] Kumar, K.K. and Smuda, E. (1994) Robust controll using ga-optimized neural networks. Journal of Control Applications, 3, 1573-1578.
[58] Laguna, M., Lino, P., Pérez, A., Quintanilla, S. and Valls, V. (2000) Minimizing Weighted Tardiness of Jobs with Stochastic Interruptions in Parallel Machines.
European Journal of Operational Research, 127(2), 444-457.
[59]Leinweber, D. J. and Arnott, R. D. (1990) Quantitative and Computational Innovation in Investment Management. Journal of Portfolio Management, 21(2) , 8-15.
[60] Li, K.L., Huang, H.S., Lin, J.D. ,Huang, B.Y. ,Huang M.J. and Wang P.W.(1994) Comparing Self-Monitoring Blood Glucose Devices. Laboratory Medicine, 25, 585-591.
[61] Logothetis, N. and Haigh, A. (1988) Charaterizing and Optimizing Multi-Response Process by the Taguchi Method. Quality and Reliability Engineering International, 4(2),159-169.
[62] McCulloch, W. S. and Pitts, W. (1943) A logical calculus of the ideas immanent in nervous activity. Bulletin of Mathematical Biophysics, 5, 115-133.
[63] Metropolis, N., Rosenbluth. , A., Teller, A. and Teller. E. (1953) Equation of State Calculations by Fast Computing Machines. Journal of Chemical Physics, 21, 1087-1092.
[64] Montgomery, D. C. (2004) Design and Analysis of Experiments. Wiley, New York.
[65] Murovec, B. and Suhel, P. (2004) A repairing technique for the local search
of the job-shop problem. European Journal of Operational Research, 153, 220-238.
[66] Nitta, T. (1994) An analysis on decision boundaries in the complex back-propagation network. IEEE International Conference on Neural Networks, 2, 934-939.
[67] Packard, N. H. (1987) A Genetic Learning Algorithm for the Analysis of Complex Data. Complex Systems, 4, 543-572.
[68] Panjwani, M. A. (1996) Interactive Computation of Coverage Regions for Wireless Communication in Multifloored Indoor Environments. IEEE Journal on Selected Areas in Communications, 14(3), 420-429.
[69] Pezzella, F. and Merelli, E. (2000) A tabu search method guided by shifting bottleneck for the job shop scheduling problem. European Journal of Operational Research, 120, 297-310.
[70] Phadke, M. S. (1989) Quality Engineering Using Robust Design. Prentice Hall, Englewood Cliffs, New Jersey.
[71] Su, C. T., Chen, M. C. and Chan, H. L. (2005) Applying Neural Network and Scatter Search to Optimize Parameter Design with Dynamic Characteristics, Journal of the Operational Research Society, 56(10), 1132-1140.
[72] Su, C. T. and Chang, H. H. (2000) Optimization of Parameter Design: An Intelligent Approach Using Neural Network and Simulated Annealing. International Journal of Systems Science,13(12), 1543-1549.
[73] Su, C. T. and Chiang, T. L. (2002) Optimal Design for a Ball Grid Array Wire Bonding Process Using a Neural-Genetic Approach. IEEE Transactions on Electronics Packaging Manufacturing, 25(1), 1-7.
[74] Taguchi G. (1990) Introduction to Quality Engineering. Asian Productivity Organization, Tokyo.
[75] Van Laarhoven, P. J. M., Aarts, E. H. L. and Lenstra, J. K. (1992) Job shop scheduling by simulated annealing. Operations Research, 40, 113-125.
[76] Vining, G.. S. and Mylers, R. H. (1990) Combining Taguchi and response surface philosophies: a dual response approach. JQT, 22 (1), 38-45.
[77] Wang, L. and Zheng, D. Z. (2001). An effective optimization strategy for job shop scheduling problems. Computers & Operations Research, 28, 585-596.
[78] William, L.C., Daniel, C., Linda, A., William, C. and Stephen, L. (1987) Evaluating Clinical Accuracy of Systems for Self-Monitoring of Blood Glucose. Diabetes Care, 10, 622-628.
[79] Yamada, T. and Nakano, R. (1996) Job-shop scheduling by simulated annealing combined with deterministic local search. Meta-heuristics: Theory and Applications.
Kluwer Academic Publishers, Hingham, MA.
[80] Young, D. L., Teplik, J., Weed, H. D., Tracht, N. T. and Alvarez, A. R.( 1991) Application of Statistical Design and Response Surface Methods to Computer-Aided VLSI Device Design II : Desirability Functions and Taguchi Methods. IEEE
Transactions on Reliability Engineering International, 7(4), 176-188.
附 錄
分散式搜尋法之 C 語言程式碼
1. SS_main
#include "ss.h"
double evaluate(SS *prob,double *x) {
double value;
int nvar;
nvar=prob->n_var;
value = 100*pow(x[2]-pow(x[2],2),2)+pow(1-x[1],2)+90*pow(x[4]-pow(x[3],2),2)+
pow(1-x[3],2)+10.1*pow(x[2]-1,2)+10.1*pow(x[4]-1,2)+19.8*(x[2]-1)*(x[4]-1);
return value;
}
void main(void) {
int MaxIter,Iter,i,nvar,b1,b2,PSize,LocalSearch;
double *best,best_value,LowerBound,UpperBound;
SS *prob;
/* Parameters Defined by the User */
MaxIter = 2; /* Number of global iterations */
nvar = 4; /* Number of variables (size of x) */
LowerBound = -10; /* Lower Bound of all variables */
UpperBound = 10; /* Upper Bound of all variables */
b1 = 10; /* Size of reference set 1 (quality) */
b2 = 10; /* Size of reference set 2 (diversity) */
PSize = 100; /* Size of the diversification generator population */
LocalSearch= 1; /* =1 Nelder and Mead Simplex Method activated,=0 OFF */
prob=DataStructures_init(nvar,b1,b2,PSize,LocalSearch);
/* Assign Variable Bounds */
for(i=1;i<=nvar;i++) {
prob->low[i] = LowerBound;
prob->high[i] = UpperBound;
}
/* Build Reference Set */
Initiate_RefSet(prob);
/* Perform Search */
for(Iter=1;Iter<=MaxIter;Iter++) {
if(prob->new_elements) Combine_RefSet(prob);
else {
Update_RefSet2(prob);
Combine_RefSet(prob);
} }
/*** Best Solution ***/
best_value = prob->value1[prob->order1[1]];
best = SSallocate_double_array(nvar);
for(i=1;i<=nvar;i++) best[i]=prob->RefSet1[prob->order1[1]][i];
printf("\n\nBest Solution Found. Value = %f\n\n",best_value);
for(i=1;i<=nvar;i++) printf("solution[%d] = %f\n",i,best[i]);
free(best);
Free_DataStructures(prob);
}
2. simplex
/* Nelder and Mead Simplex Method for Nonlinear unconstrained optimization problems
*/
#include "ss.h"
#define NMAX 5000
#define ALPHA 1.0
#define BETA 0.5
#define GAMMA 2.0
#define GET_PSUM for (j=1;j<=ndim;j++) { for (i=1, sum=0.0;i<=mpts;i++) sum +=
p[i][j]; psum[j]=sum; }
int amoeba(double **p, double *y, int ndim, double ftol, double (*funk)(), int *nfunk, SS
*prob) {
int i, j, ilo, ihi, inhi, mpts=ndim+1;
double ytry, ysave, sum, rtol, *psum;
psum = SSallocate_double_array(ndim+1);
*nfunk = 0;
GET_PSUM for (;;) {
ilo = 1;
ihi = y[1] > y[2] ? (inhi = 2, 1) : (inhi = 1, 2);
for (i = 1; i <= mpts; i++) { if (y[i] < y[ilo]) ilo = i;
if (y[i] > y[ihi]) { inhi = ihi;
ihi = i;
} else if (y[i] > y[inhi]) if (i != ihi) inhi = i;
}
rtol = 2.0*fabs(y[ihi]-y[ilo])/(fabs(y[ihi])+fabs(y[ilo]));
if (rtol < ftol) break;
if (*nfunk >= NMAX) return -1;
ytry = amotry(p, y, psum, ndim, funk, ihi, nfunk, -ALPHA,prob);
if (ytry <= y[ilo])
ytry = amotry(p, y, psum, ndim, funk, ihi, nfunk, GAMMA,prob);
else if (ytry >= y[inhi]) { ysave = y[ihi];
ytry = amotry(p, y, psum, ndim, funk, ihi, nfunk, BETA,prob);
if (ytry >= ysave) {
for (i = 1; i <= mpts; i++) { if (i != ilo) {
for (j = 1; j <= ndim; j++) {
psum[j] = 0.5*(p[i][j]+p[ilo][j]);
p[i][j] = psum[j];
}
y[i] = (*funk)(prob,psum);
} }
*nfunk += ndim;
GET_PSUM }
} }
free(psum);
return 0;
}
double amotry(double **p, double *y, double *psum, int ndim, double (*funk)(), int ihi, int
*nfunk, double fac,SS *prob)
{
int j;
double fac1, fac2, ytry, *ptry;
ptry = SSallocate_double_array(ndim+1);
fac1 = (1.0-fac)/(double)ndim;
fac2 = fac1 - fac;
for (j = 1; j <= ndim; j++) ptry[j] = psum[j]*fac1-p[ihi][j]*fac2;
ytry = (*funk)(prob,ptry);
++(*nfunk);
if (ytry < y[ihi]) { y[ihi] = ytry;
for (j = 1; j <= ndim; j++) {
psum[j] += ptry[j]-p[ihi][j];
p[ihi][j] = ptry[j];
} }
free(ptry);
return ytry;
}
3. SS_Memory
#include "ss.h"
SS *DataStructures_init(int nvar,int b1,int b2,int PSize,int LocalSearch) {
SS *problem;
problem = (SS*) calloc(1,sizeof(SS));
if(!problem) SSabort("Memory allocation problem");
problem->n_var = nvar;
problem->b1 = b1;
problem->b2 = b2;
problem->PSize = PSize;
problem->LS = LocalSearch;
problem->digits = 0;
problem->last_combine = 0;
problem->iter=0;
problem->high = SSallocate_double_array(nvar);
if(!problem->high) SSabort("Memory allocation problem");
problem->low = SSallocate_double_array(nvar);
if(!problem->low) SSabort("Memory allocation problem");
problem->ranges = SSallocate_int_matrix(nvar,5);
if(!problem->ranges) SSabort("Memory allocation problem");
problem->value1 = SSallocate_double_array(b1);
if(!problem->value1) SSabort("Memory allocation problem");
problem->RefSet1 = SSallocate_double_matrix(b1,nvar);
if(!problem->RefSet1) SSabort("Memory allocation problem");
problem->order1 = SSallocate_int_array(b1);
if(!problem->order1) SSabort("Memory allocation problem");
problem->iter1 = SSallocate_int_array(b1);
if(!problem->iter1) SSabort("Memory allocation problem");
problem->value2 = SSallocate_double_array(b2);
if(!problem->value2) SSabort("Memory allocation problem");
problem->RefSet2 = SSallocate_double_matrix(b2,nvar);
if(!problem->RefSet1) SSabort("Memory allocation problem");
problem->order2 = SSallocate_int_array(b2);
if(!problem->order1) SSabort("Memory allocation problem");
problem->iter2 = SSallocate_int_array(b2);
if(!problem->iter2) SSabort("Memory allocation problem");
/* Parameters for random generator */
problem->idum = 13171191;
problem->seed_reset = 1;
problem->iff = 0;
return problem;
}
void Free_DataStructures(SS *prob) {
SSfree_double_matrix(prob->RefSet1,prob->b1);
free(prob->value1);
free(prob->order1);
free(prob->iter1);
SSfree_double_matrix(prob->RefSet2,prob->b2);
free(prob->value2);
free(prob->order2);
free(prob->iter2);
SSfree_int_matrix(prob->ranges,prob->n_var);
free(prob->high);
free(prob->low);
free(prob);
}
int **SSallocate_int_matrix(int rows,int columns) {
int **aux;
int i;
aux=(int**)calloc(rows+1,sizeof(int*));
if(!aux) SSabort("Memory allocation problem");
for(i=1;i<=rows;i++) {
aux[i] = SSallocate_int_array(columns);
if(aux[i]==NULL) SSabort("Memory allocation problem");
}
return aux;
}
double **SSallocate_double_matrix(int rows,int columns) {
double **aux;
int i;
aux=(double**)calloc(rows+1,sizeof(double*));
if(!aux) SSabort("Memory allocation problem");
for(i=0;i<=rows;i++) {
aux[i] = SSallocate_double_array(columns);
if(!aux[i]) SSabort("Memory allocation problem");
}
return aux;
}
double *SSallocate_double_array(int size) {
double *aux;
aux=(double*)calloc(size+1,sizeof(double));
if(!aux) SSabort("Memory allocation problem");
return aux;
}
int *SSallocate_int_array(int size) {
int *aux;
aux=(int*)calloc(size+1,sizeof(int));
if(!aux) SSabort("Memory allocation problem");
return aux;
}
void SSfree_double_matrix(double **matrix,int rows) {
int i;
for(i=0;i<=rows;i++) free(matrix[i]);
free(matrix);
}
void SSfree_int_matrix(int **matrix,int rows)
{
int i;
for(i=1;i<=rows;i++) free(matrix[i]);
free(matrix);
}
4. SS_RefSet
#include "ss.h"
void Initiate_RefSet(SS *prob) {
double *current,*min_dist,*value,**solutions;
int j,i,i1,a,*index,*index2,cont=0;
double d,dmax,current_value;
prob->iter=1;
prob->new_elements = 1;
current = SSallocate_double_array(prob->n_var);
if(!current) SSabort("Memory allocation problem");
min_dist = SSallocate_double_array(prob->PSize);
if(!min_dist) SSabort("Memory allocation problem");
value = SSallocate_double_array(prob->PSize);
if(!min_dist) SSabort("Memory allocation problem");
solutions = SSallocate_double_matrix(prob->PSize,prob->n_var);
if(!solutions) SSabort("Memory allocation problem");
for(i=1;i<=prob->PSize;i++)
{
/* Generate new solution */
for(j=1;j<=prob->n_var;j++)
current[j] = SSGenerate_value(prob,j);
/* Evaluate Solution */
current_value=evaluate(prob,current);
if(prob->LS) SSimprove_solution(prob,current,¤t_value);
if(is_new(prob,solutions,i-1,current)) {
/* Store solution in matrix "solutions" */
for(j=1;j<=prob->n_var;j++) solutions[i][j] = current[j];
value[i]=current_value;
} else {
i--;
cont++;
}
if(cont>prob->PSize/2) {
prob->digits++;
cont=0;
} }
index = orden_indices(value,prob->PSize,-1);
/* Add the best b1 to RefSet1 */
for(i=1;i<=prob->b1;i++) {
for(j=1;j<=prob->n_var;j++)
prob->RefSet1[i][j] = solutions[index[i]][j];
prob->value1[i] = value[index[i]];
prob->order1[i] = i;
prob->iter1[i] = 1;
}
/* Compute minimum distances */
for(i=1;i<=prob->PSize;i++)
min_dist[i]=distance_to_RefSet1(prob,solutions[i]);
/*Add the second b2 to RefSet2 */
for(i=1;i<=prob->b2;i++) {
/* Select the solution with maximum min. dist */
dmax = -1;
for(j=1;j<=prob->PSize;j++) if(min_dist[j]>dmax)
{
dmax=min_dist[j];
a=j;
}
for(j=1;j<=prob->n_var;j++)
prob->RefSet2[i][j] = solutions[a][j];
prob->value2[i] = min_dist[a];
/* Update minimum distances */
for(i1=1;i1<=prob->PSize;i1++) {
d=0;
for(j=1;j<=prob->n_var;j++)
d += pow(solutions[i1][j]-solutions[a][j],2);
if(d<min_dist[i1]) min_dist[i1]=d;
} }
/* Update minimum distances in RefSet2 */
for(i=1;i<=prob->b2;i++) {
for(a=1;a<=prob->b2 && a!=i ;a++) {
d=0;
for(j=1;j<=prob->n_var;j++)
d += pow(prob->RefSet2[i][j]-prob->RefSet2[a][j],2);
if(prob->value2[i] > d) prob->value2[i]=d;
} }
index2 = orden_indices(prob->value2,prob->b2,1);
for(i=1;i<=prob->b2;i++) {
prob->order2[i] = index2[i];
prob->iter2[i] = 1;
}
free(index);free(index2);free(current);free(min_dist);
free(value);SSfree_double_matrix(solutions,prob->PSize);
}
void Update_RefSet2(SS *prob) {
double *current,*min_dist,*value,**solutions;
int j,i,i1,a,*index2,cont=0;
double d,dmax;
prob->iter++;
prob->digits++;
current = SSallocate_double_array(prob->n_var);
if(!current) SSabort("Memory allocation problem");
min_dist = SSallocate_double_array(prob->PSize);
if(!min_dist) SSabort("Memory allocation problem");
value = SSallocate_double_array(prob->PSize);
if(!min_dist) SSabort("Memory allocation problem");
solutions = SSallocate_double_matrix(prob->PSize,prob->n_var);
if(!solutions) SSabort("Memory allocation problem");
for(i=1;i<=prob->PSize;i++) {
/* Generate new solution */
for(j=1;j<=prob->n_var;j++)
current[j] = SSGenerate_value(prob,j);
if(is_new(prob,solutions,i-1,current)) {
/* Store solution in matrix "solutions" */
for(j=1;j<=prob->n_var;j++) solutions[i][j] = current[j];
} else
{ i--;
cont++;
}
if(cont>prob->PSize/2) {
prob->digits++;
cont=0;
} }
/* Compute minimum distances */
for(i=1;i<=prob->PSize;i++)
min_dist[i]=distance_to_RefSet1(prob,solutions[i]);
/*Add to RefSet */
for(i=1;i<=prob->b2;i++) {
/* Select the solution with maximum min. dist */
dmax = -1;
for(j=1;j<=prob->PSize;j++) if(min_dist[j]>dmax)
{
dmax=min_dist[j];
a=j;
}
for(j=1;j<=prob->n_var;j++)
prob->RefSet2[i][j] = solutions[a][j];
/* Update minimum distances */
for(i1=1;i1<=prob->PSize;i1++) {
d=0;
for(j=1;j<=prob->n_var;j++)
d += pow(solutions[i1][j]-solutions[a][j],2);
if(d<min_dist[i1]) min_dist[i1]=d;
} }
/* Update minimum distances in RefSet2 */
for(i=1;i<=prob->b2;i++) {
for(a=1;a<=prob->b2 && a!=i ;a++) {
d=0;
for(j=1;j<=prob->n_var;j++)
d += pow(prob->RefSet2[i][j]-prob->RefSet2[a][j],2);
if(min_dist[i] > d) min_dist[i]=d;
}
prob->value2[i] = min_dist[i];
}
index2 = orden_indices(prob->value2,prob->b2,1);
for(i=1;i<=prob->b2;i++) {
prob->order2[i] = index2[i];
prob->iter2[i] = prob->iter;
}
prob->new_elements = 1;
free(index2);
free(current);
free(min_dist);
free(value);
SSfree_double_matrix(solutions,prob->PSize);
}
void Combine_RefSet(SS *prob) {
int i,j,a,s,pull_size,total_size;
double **offsprings,**pull;
prob->new_elements=0;
offsprings = SSallocate_double_matrix(4,prob->n_var);
/* New solutions are temporarily stored in a pull */
pull_size=0;
total_size=(4*prob->b1*prob->b1)/2+(3*prob->b1*prob->b2)+
(2*prob->b2*prob->b2)/2;
pull = SSallocate_double_matrix(total_size,prob->n_var);
/* Combine elements in RefSet1 */
for(i=1;i<prob->b1;i++) for(j=i+1;j<=prob->b1;j++) {
/* Combine solutions not combined in the past */
if(prob->iter1[i]>prob->last_combine ||
prob->iter1[j]>prob->last_combine ) {
SScombine(prob,prob->RefSet1[i],prob->RefSet1[j],offsprings,4);
for(a=1;a<=4;a++) {
pull_size++;
for(s=1;s<=prob->n_var;s++)
pull[pull_size][s]=offsprings[a][s];
} } }
/* Combine RefSet1 with RefSet2*/
for(i=1;i<= prob->b1;i++) for(j=1;j<= prob->b2;j++) {
if(prob->iter1[i]>prob->last_combine ||
prob->iter2[j]>prob->last_combine )
prob->iter2[j]>prob->last_combine )