Genetic Algorithm for Scheduling Diet
Case: Liver Patient
M. F. Syahputra
1
, R. F. Rahmat
1
, Dian Aria Ningsih
1
, U. Andayani
1
1
Department of Information Technology, Universitas Sumatera Utara , Jl. Alumni no.3, Medan, Indonesia
Keywords: genetic algorithm, diet schedule, liver patient.
Abstract: The main function of liver is to process the absorbed nutrients from food consumed. Several factors that affect
its functions are alcohol, infection, drugs or herbal medicine, cancer, autoimmune disease, etc. Balanced and
healthy diet can help the liver patients to heal the disease by considering the calorie needs. In this research,
we schedule diet for liver patients by using genetic algorithm, which starts from calculating patient’s calorie
needs and then initializing the population, calculating fitness score, performing crossover and mutation. Next,
7 individuals with the lowest score will be selected as a diet schedule in a week (7 days). From the 8 times of
testing results, we get 0.5 lowest fitness score with 20 initial population and 100 generations. It shows that
the greater the created generation, the more the opportunities to obtain best individual with fitness score
approaching 0 (zero) or equal to 0 (zero).
1 INTRODUCTION
The liver is the largest glandular organ that serves to
process the absorbed nutrients from food consumed
and also to keep the body pure of toxins and harmful
substances (Dixit, 2014). Several factors that affect its
functions are alcohol, infection, drugs or herbal
medicine, cancer, autoimmune disease, etc. The most
common diseases that causes of chronic liver failure
include hepatitis, cirrhosis, hemochromatosis, etc.
One of the treatment able to help the liver patients
to cure the disease is balanced and healthy diet, by
considering the calorie needs. It aims to prevent the
fatal liver failure, to repair the damaged liver tissue,
to reduce its workload, to meet nutrition of patients
and to prevent the complication of liver failure
(Kargulewicz, 2014). Food consumed by liver patient
needs specific nutrient levels, such as protein, energy
and fat in a certain amount. Therefore, diet scheduling
system is required for liver patients to help them meet
the nutrient level and cure the disease more rapidly,
and also to inform them various food menu able to be
consumed so that it can increase the appetite of
patients.
Several method had been proposed for dietary
recommender system. The latest research was done
by Norouzi, et al. in 2016 who narratively reviewed
food recommender system for a diabetic patients
(Norouzi, 2016). They recognized three common
methods for food recommender system, namely
Collaborative Filtering Recommender System
(CFRS), knowledge based recommender system
(KBRS), and content aware recommender system
(CARS). Artificial intelligence method and semantic
web techniques are also often used in food
recommender systems.
In (El-Dosuky, 2012) used ontology and
heuristics for building food recommender system.
They concluded that their proposed algorithm could
give better result of F-measure, recall, precision and
accuracy than the other existing semantic
recommenders (El-Dosuky, 2012). But, due to the
complexity of the ontology construction, many
researchers prefer to use artificial intelligence
techniques. In the next year, Chen, et al. constructed
a diet recommendation system using fuzzy rules and
knapsack method. They designed a diet
recommendation system which has the expert
knowledge of three high chronic diseases, namely
diabetes, hypertension and cholesterol. The system
recommended suitable diet based on six parameters,
namely height, weight, activity levels, kidney
function, hypertension and hyperlipidaemia. They
also stated that their system had been evaluated by the
nutritionist to prove that it is effective (Chen, 2013).
Recently, genetic algorithm (GA) is often used for
solving optimization problems, such as shortest path
Syahputra, M., Rahmat, R., Ningsih, D. and Andayani, U.
Genetic Algorithm for Scheduling Diet Case: Liver Patient.
DOI: 10.5220/0010091919051909
In Proceedings of the International Conference of Science, Technology, Engineering, Environmental and Ramification Researches (ICOSTEERR 2018) - Research in Industry 4.0, pages
1905-1909
ISBN: 978-989-758-449-7
Copyright
c
2020 by SCITEPRESS Science and Technology Publications, Lda. All rights reserved
1905
and also scheduling system (Kumar, 2010). In 2013,
Skinner, et al. presented genetic algorithm based
optimization approach to improve container handling
operations at a container terminal in Australia. The
experimental result of their research showed that GA
can reduce the overall time for container transfers and
improve the overall performance (Skinner, 2013).
Another related research in 2014, Filho, et al. solved
scheduling problems on flexible manufacturing
systems (FMS) using genetic algorithm (Filho, 2014).
Next research, Xu, et al. also used GA for task
scheduling on heterogeneous computing systems
using multiple priority queues. They concluded that
GA can cover a larger search space than the
deterministic scheduling approaches and do not lead
to high computational cost (Xu, 2014).
In this research, we propose genetic algorithm to
schedule diet for liver patients. The rest of the paper
will be organized as follows: Section II describes the
proposed method. Results and discussions are
presented in Section III. Section IV provides
summary and suggestions for future research.
2 CONCEPT DEVELOPMENT
Here are the steps in implementing the GA to
calculate the calorie needs:
2.1 Data Collection
This data of the calorie needs consist of two
parameter, i.e., liver patient and food nutrition. The
liver patient parameters, i.e., age, sex, weight, height,
allergy, ability of oral intake and edema. The food
nutrition parameters are food name, type of food
(staple food, side dishes, vegetables, fruits, and
complement), energy (kcal), protein (gr), fat (gr) and
carbohydrate (gr) and the ingredients data in 100
grams obtained from Nutri Survey Indonesia in 2007.
2.2 Calculation of Calorie Needs
The calorie needs can be calculated using Harris-
Benedict equation which estimates resting energy
expenditure (REE). The total calorie needs for liver
patients is called by basal calorie that used to create a
chromosome that consists of food menu.
Here, the following steps to calculate the calorie
needs (basal calorie).
Step 1 : Calculating the ideal body weight (kg)
based on the formula rule that showing in Table 1.
Table 1: Rule of Ideal Body Weight Calculation
Sex Height
Formula
Male < 160 cm
(Height-100) x 1 kg
Female < 150 cm
Male ≥ 160 cm
((Height-100) x 1 kg) x
90%
Female ≥ 150 cm
Step 2 : Calculating Basal Calorie (kcal)
based on rule in Table 2.
Table 2: Rule of Basal Calorie Calculation
Sex
Formula
Male
Ideal Body Weight x 30 kcal
Female
Ideal Body Weight x 25 kcal
2.3 Gen and Chromosome Structure
In genetic algorithm, an individual consists of gen and
chromosome. In this subsection, we will discuss
about the structure of gen and chromosome.
2.3.1 Gen
It consists of food types that will be initialized to
create initial population in genetic algorithm. In this
research, there are 5 genes (kind of food), namely
staple food (st), side dishes (sd), vegetables (v), fruits
(f) and complement (c). Each of them has two values,
namely calorie and food weight. The value in each of
gene is called by allele. Fig. 1 shows the structure of
gen.
Figure 1: Gen structure
2.3.2 Chromosome
In this research, there are three chromosomes in each
of individual, namely breakfast, lunch and dinner.
Each of chromosome has 5 genes, so there are 15
genes in an individual. It also has two values, namely
fitness score and the total of calorie. The total of
calorie is the calorie of food menu in a chromosome
for scheduling diet in a day. The fitness score is used
to evaluate the generated food menu based on the
patient calorie needs. Fig. 2 shows the structure of
chromosome.
ICOSTEERR 2018 - International Conference of Science, Technology, Engineering, Environmental and Ramification Researches
1906
Figure 2: Chromosome structure
2.4 Initialization of Population
In this research, population is the data of food menu.
The greater the size of population, the more the
generated diet variation. Several steps below are done
to initialize the population.
Step 1 : Normalize food menu which
aims to adjust the generated diet
2.4.1 Divide the Total of Calorie Needs
Total of calorie needs is divided into 3 chromosomes,
namely breakfast, lunch and dinner. It aims to make
the diet schedule consider the balance of total calorie
for breakfast, lunch and dinner. It is done as
formulated in equation (1)
𝑇𝑜𝑡𝑎𝑙 𝑐𝑎𝑙𝑜𝑟𝑖𝑒 𝑝𝑒𝑟 𝑐ℎ𝑟𝑜𝑚
   
(1)
2.4.2 Calculate Total Calorie for Every Kind
of Food
Each of chromosome consists of 5 genes of food type,
namely staple food, side dishes, vegetables, fruits,
and complement, which respectively has a weight of
0.45, 0.2, 0.15, 0.15, and 0.2. It can be calculated
using equation (2) until equation (6).
𝑠𝑡𝑎𝑝𝑙𝑒 𝑓𝑜𝑜𝑑 0.45 𝑥 𝑡𝑜𝑡𝑎𝑙 𝑐𝑎𝑙𝑜𝑟𝑖𝑒 𝑝𝑒𝑟 𝑐ℎ𝑟𝑜𝑚 (2)
𝑠𝑖𝑑𝑒 𝑑𝑖𝑠ℎ𝑒𝑠 0.2 𝑥 𝑡𝑜𝑡𝑎𝑙 𝑐𝑎𝑙𝑜𝑟𝑖𝑒 𝑝𝑒𝑟 𝑐ℎ𝑟𝑜𝑚 (3)
𝑣𝑒𝑔𝑒𝑡𝑎𝑏𝑙𝑒𝑠 0.15 𝑥 𝑡𝑜𝑡𝑎𝑙 𝑐𝑎𝑙𝑜𝑟𝑖𝑒 𝑝𝑒𝑟 𝑐ℎ𝑟𝑜𝑚 (4)
𝑓𝑟𝑢𝑖𝑡𝑠 0.15 𝑥 𝑡𝑜𝑡𝑎𝑙 𝑐𝑎𝑙𝑜𝑟𝑖𝑒 𝑝𝑒𝑟 𝑐ℎ𝑟𝑜𝑚 (5)
𝑐𝑜𝑚𝑝𝑙𝑒𝑚𝑒𝑛𝑡 0.2 𝑥 𝑡𝑜𝑡𝑎𝑙 𝑐𝑎𝑙𝑜𝑟𝑖𝑒 𝑝𝑒𝑟 𝑐ℎ𝑟𝑜𝑚 (6)
2.4.3 Calculate Each Food Weight in 100
Gram
Each of food in database is expressed in units of 100
grams. In the database, there are a few of menu that
has calorie more than needed calorie for the food. To
generate the number of calories and weight that
corresponds to the total calorie needs of DM patient,
we do the calculation as formulated in equation (7)
𝐹𝑜𝑜𝑑 𝑤𝑒𝑖𝑔ℎ𝑡
𝑔𝑟
 
 
𝑥100 (7)
Step 2 : Random and generate 15 food
menu based on its type as an initial population.
Step 3 : Input the calorie of food into
chromosome. The generated food menu from
previous step will be divided into 3 chromosomes,
namely breakfast, lunch and dinner, so each of
chromosome has 5 genes which contain the calorie of
staple food, side dishes, vegetables, fruits, and
complement. The number of generated population is
based on the number of initial individual and
generation.
2.5 Calculation of Fitness Score
Fitness score is used to evaluate the generated
solution and compare among the individuals to
determine the better or the worse one. In this research,
the fitness score for each individual is based on the
total of patient calorie needs and the total of food
calorie in a day. An optimal solution for an individual
is if the difference between the total of patient calorie
needs and the total of food calorie in a day equal or
approach to 0 (zero). Therefore, the less the generated
fitness score, the more optimal the individual. Fitness
score can be calculated using equation (8), while the
average of fitness score for each generation can be
calculated using equation (9).
𝐹𝑖𝑡𝑛𝑒𝑠𝑠 𝑠𝑐𝑜𝑟𝑒 |𝑡𝑜𝑡𝑎𝑙 𝑐𝑎𝑙𝑜𝑟𝑖𝑒  𝑡𝑜𝑡𝑎𝑙 𝑓𝑜𝑜𝑑 𝑐𝑎𝑙𝑜𝑟𝑖𝑒| (8)
𝑓𝑖𝑡𝑛𝑒𝑠𝑠 𝑎𝑣𝑒𝑟𝑎𝑔𝑒

(9)
Where:
a
k
= fitness score for each individual
k = individual in a week (1-7)
2.6 Selection
In this research, we use Rank-Based fitness so that the
selection of individual is based on the lowest fitness
score. It aims to select the individual which becomes
a parent for the next phase, crossover. The number of
selected individual depends on the probability of
crossover.
2.7 Crossover
The used method of crossover in this research is one-
point crossover which generates the offspring from
every 2 parents. These following steps are done in the
process of crossover.
Step 1 : Calculate the number of
individual which becomes a parent for crossover by
using equation (10)
𝑁

 𝑁
𝑥 0.1 (10)
Where N
co
is the number of individual for
crossover and N
i
is the number of individual.
Step 2 : Determine the cut point of gen
by generating a random number from 1 until the
number of chromosome for each parent. The
crossover will start from the gen with the position
after the random number.
Step 3 : Performing crossover. Genes in
parent 1 will be copied to the offspring before the cut
Genetic Algorithm for Scheduling Diet Case: Liver Patient
1907
point, while genes in parent 2 will be copied to the
offspring after the cut point. This process will
generate one new offspring.
2.8 Mutation
Random mutation will be conducted after the
crossover by randomizing the position of
chromosome and gen to be mutated. These following
steps will clearly explain the process of random
mutation.
Step 1 : Calculate the number of gen to
be mutated. It depends on the Probability of mutation
(P
m
) and the number of genes from all chromosomes.
In this research, we set 0.2 as probability value, while
the total of gen depends on the number of initial
population and generation. The calculation can be
done using equation (11).
𝑁
 𝑃
𝑥 𝑡𝑜𝑡𝑎𝑙 𝑜𝑓 𝑖𝑛𝑑𝑖𝑣𝑖𝑑𝑢𝑎𝑙 𝑥 15 (11)
Step 2 : Determine the position of
individual and gen to be mutated randomly.
Step 3 : Performing mutation. The gen
will be mutated if the gen in the next chromosome has
the same type. For example, if generated gen is gen
with type of staple food in breakfast, then the gen will
be exchanged with the gen with the type of staple food
in lunch. And then the gen with the same type will be
exchange to chromosome of breakfast. It aims to keep
the calorie of every type of food as needed.
3 SYSTEM DESIGN
Figure 3 shows the general architecture of our
proposed method.
Figure 3: General architecture
From the figure above, the iteration numbers of
initial inputs to calculate the calorie needs from the
patients by implementing the Genetic Algorithm
(GA) by generating the number of selecting the 7
(seven) best individuals (solutions) with the lowest
fitness score, performing one-point crossover to the
individuals with the lowest score, and performing
random mutation to the chromosome. The output of
this system is a schedule menu in a week for liver
patients.
4 SYSTEM TESTING
The testing is conducted 8 times with different
number of initial individual and generation. 10 initial
individual is tested with the number of generation
respectively 60, 80, and 100. It is also conducted with
20 initial individual in the next testing. Then, 30
initial individual is tested with 60 and 80 generations.
The result of this research is schedule of diet for liver
patients.
Table 3:
Testing Result with 10 Initial Individual
Number of Generation Minimum fitness score
60 74.5
80 13.5
100 11.5
Table 4:
Testing Result with 20 Initial Individual
Number of Generation Minimum fitness score
60 74.5
80 13.5
100 11.5
Table 5:
Testing Result with 30 Initial Individual
Number of Generation Minimum fitness score
60 16.5
80 4.1
5 RESULT AND EVALUATION
From all the testing results, it can be concluded that
the greater the number of generation, the greater the
evolution of individual that causes the more
possibility of fitness score approaches or equals to 0
(zero). It means that the calorie total of the generated
food menu will correspond to the total of patient’s
daily calorie needs.
6 CONCLUSIONS
Based on all testing result of diet scheduling system
for liver patients, there are several obtained
ICOSTEERR 2018 - International Conference of Science, Technology, Engineering, Environmental and Ramification Researches
1908
conclusions. First, the greater the number of
population, the more the possibility of fitness score
changes into approaching best fitness score. The
greater the number of generation, the greater the
evolution of individual that causes the more
possibility of fitness score approaches or equals to 0
(zero). Best individual has the smallest fitness score.
The last solution of scheduling diet can change every
time running the system. It is caused by the initial
population generated randomly, so that the generated
fitness score in the solution of scheduling diet
becoming more varied.
For further research, adding the generated food
menu can be done to make it more varied and increase
the appetite of liver patients, but still limit the food
that contains meat. Another optimization algorithm
can be used to improve the effectiveness of the
obtained results.
ACKNOWLEDGEMENTS
This research was supported by Universitas Sumatera
Utara. All the faculty, staff members and laboratory
technicians of Information Technology Department.
REFERENCES
Dixit, V., Pruthi, J., 2014. “Review of image processing
techniques for automatic detection of tumor in human
live”, International Journal of Computer Science and
Mobile Computing, vol. 3, pp. 371-378.
Kargulewicz, A., Stankowiak-Kulpa, H., Grzymisławski,
M., 2014. “Dietary recommendations for patients
with nonalcoholic fatty liver disease,” Prz
Gastroenterol, vol. 9, pp. 18-23
Norouzi, S., Nematy, M., Zabolinezhad, H., Sistani, S.,
Etminani, K., 2016. “Food recommender systems for
diabetic patients: a Narrative review,” Reviews in
Clinical Medicine.
El-Dosuky, M. A., Rashad, M. Z., Hamza, T. T., El-
Bassiouny, A. H., 2012. “Food recommendation
using ontology and heuristics,” in International
Conference on Advanced Machine Learning
Technologies and Applications, p. 423-429.
Chen, R. C., Lin, Y. D., Tsai, C. M., Jiang, H., 2013.
“Constructing a diet recommendation system based
on fuzzy rules and knapsack method,” in
International Conference on Industrial, Engineering
and Other Applications of Applied Intelligent
Systems, p. 490-500.
Kumar, M., Husian, M., Upreti, N., Gupta, D., 2010.
“Genetic algorithm: Review and application,”
International Journal of Information Technology and
Knowledge Management, vol. 2, pp. 451-454.
Skinner, B., Yuan, S., Huang, S., Liu, D., Cai, B.,
Dissanayake, G., Pagac, D., 2013. “Optimisation for
job scheduling at automated container terminals
using genetic algorithm,” Computers & Industrial
Engineering, vol. 64, pp. 511-523.
Filho, M. G., Barco, C. F.. Neto, R. F. T., 2014. “Using
Genetic Algorithms to solve scheduling problems on
flexible manufacturing systems (FMS): a literature
survey, classification and analysis,” Flexible Services
and Manufacturing Journal, vol. 26, pp. 408-431.
Xu, Y., Li, K., Hu, J., Li, K., 2014. “A genetic algorithm
for task scheduling on heterogeneous computing
systems using multiple priority queues,” Information
Sciences, vol. 270, pp. 255-287.
Genetic Algorithm for Scheduling Diet Case: Liver Patient
1909