使用稀疏矩陣與ASCII字元儲存家禽產蛋記錄的記憶體空間需求比較

黃鈺嘉 林德育 張秀鑾

台灣省畜產試驗所

家禽的產蛋記錄通常可分為 ” 有生蛋、沒生蛋” 或是 “沒生蛋、一個蛋、兩個蛋” 或是 “沒生蛋、一個正常蛋、兩個正常蛋、異常蛋”•••等。利用諸如 Fortran Compiler提供的 ACHAR(I) 與 IACHAR(A) 對應函數與自建的轉換對照表,可以256 (=28)個ASCII字元儲存各類變化的產蛋記錄;如28 (00000000→11111111):八天的 “有生蛋、沒生蛋”的資料或是35 (<256) :五天的 “沒生蛋、一個蛋、兩個蛋”的資料 或是 44(0000→3333): 四天的”沒生蛋、一個正常蛋、兩個正常蛋、異常蛋”的資料•••等。若以上例而言,對照表較直接字元儲存最多可節省至 8倍的電腦記憶體空間。但是只要產蛋的記錄的代碼增加至 16種以上(162 =256)則256 ASCII字元儲存法所須空間與一般直接字元儲存相同,無法節省記憶體空間。然而在高產的家禽而言(如蛋雞、菜鴨)其初產後至280日齡間的產蛋記錄可能僅有數日停產,如以一個字元來儲存各式的每日生產代碼其所需的空間約為 (280-初產日齡) *隻數(m) bytes。但是如果把產蛋資料的生一個蛋與沒生蛋代碼互(1、0 ←→ 0、1)形成一個類似負相的圖形(negative image)陣列,再以列稀疏矩陣儲存沒生蛋、生兩個蛋或是異型蛋等字元(跳開一個正常蛋的生產),讀出時再與予以還原。其所需的空間約為 5*(平均無正常蛋日)*m + 4 m + 4 bytes,﹝假設以4 bytes儲存整數﹞,在產蛋率很高或很低(此時0、1不互換)而且規模大的記蛋系統,列稀疏矩陣的儲存概念可以用來降低所需的儲存空間。

關鍵語:稀疏矩陣、ASCII字元、蛋。

 

Comparing the memory space requirement of sparse matrix to
ASCII code storage in recording poultry egg production data

Y. C. Huang, D. Y. Lin and H. L. Chang

Taiwan Livestock Research Institute

In addition of yes/no (1 or 0) egg recording system, two eggs, soft shell egg and other abnormal eggs were possible recorded under different management systems. A simple way of saving the memory space is using the 256 ASCII codes(by functions such as ACHAR(I) and IACHAR(A) in Fortran Compiler) to represent 28 egg patterns (or less than 256 patterns). For examples: 00000000 to 11111111 has 256 egg patterns for yes/no data of eight days; 00000 to 22222 (system of no egg, one egg and two eggs) has 35 patterns for egg production of five days; and 0000 to 3333 has 44 patterns for system of no egg, one egg, two eggs and abnormal eggs in four days…etc. The method uses ASCII reference table to store 256 characters which can save up to use only one eighth memory requirement. But if the system use more than 16 codes in recording egg production (162 =256), then 256 ASCII character system can not improve the storage requirement than regular direct storage method. In fact, some prolific poultry, like Leghorn or Tsaiya, there were only no egg for few days within her 280 days of age after giving the first egg. If recorded all the egg patterns, p*m (production days*number of animals) bytes will be required in storing the laying information. From idea of negative image, switched recording codes of no egg and one egg (0 to1 and 1 to 0) without changing other codes, which can generate a row compressed sparse matrix for all animals. The estimated computer memory space is about 5*(average days which have no egg or two eggs or abnormal egg)*m+4m+4 bytes, if 4 bytes is used in storage of integer. For extremely high or low production birds (like wild birds, without switching 0 and 1) with large scale management system, the sparse matrix technique can improve the computer space requirement in recording poultry eggs.

Key Words: Sparse Matrix, ASCII Code, Egg .