A Hybridized Scheme for Solving Ridesharing Problems Based on
Firefly Algorithm and a Variant of PSO Algorithm
Fu-Shiung Hsieh
a
Department of Computer Science and Information Engineering, Chaoyang University of Technology,
168, Jifeng E. Rd., Wufeng District, Taichung, 413310 Taiwan, R.O.C.
Keywords: Ridesharing, Particle Swarm Optimization, Firefly, Discrete Optimization.
Abstract: Solving constrained discrete optimization problems with discrete decision variables poses a challenge due to
complexity. Ridesharing problems are usually formulated as constrained discrete optimization problems. An
urgent need is to develop an efficient algorithm for solving ridesharing problems. One potential approach to
constrained discrete optimization problems is based on hybridization of different evolutionary algorithms to
increase diversity in generating candidates during the evolution processes. The goal of this paper is to provide
a proof of concept to study effectiveness of hybridizing the strategies of two evolutionary algorithms, the
Firefly algorithm and a variant of PSO algorithm. A hybrid algorithm is proposed based on the above
mentioned hybridization mechanism to illustrate that the idea. To verify effectiveness of the hybridization
mechanism, several experiments were conducted. The experimental results indicate the hybridization
mechanism works effectively and finds the solutions more efficiently than the existing hybrid Firefly-PSO
algorithm.
1 INTRODUCTION
A lot of decision problems can be modelled as
constrained discrete optimization problems.
Matching problems in ridesharing systems (Fiedler et
al. 2018) and design/analysis of Cyber-Physical
Systems (Hsieh, 2022) fall into the category of
constrained discrete optimization problems. Solving
constrained discrete optimization problems often
poses a challenge due to complexity to search the
solution space. Ridesharing problems can be
described by optimization problems with discrete
decision variables. The decision variables must
satisfy several constraints such as capacity
constraints, non-negative cost savings and time
constraints, etc. Therefore, ridesharing problems are
usually formulated as constrained discrete
optimization problems. Solving these discrete
optimization problems poses several challenges.
First, the solution space of discrete optimization
problems is typically nonconvex. Classical
optimization methods cannot be applied to find the
solutions of these non-convex discrete optimization
problems. Second, the solution space of discrete
a
https://orcid.org/0000-0003-0208-9937
optimization problems grows exponentially with the
problem size. Finally, due to the excessive constraints
in the discrete optimization problems, an effective
method need to be applied to efficiently move toward
the feasible region and find solutions. It is urgently
needed to design an efficient solver for ridesharing
problems. This study aims to compare effectiveness
of different ways of combining the search strategies
of existing evolutionary algorithms. This comparative
will be helpful for development of an efficient
algorithm.
Classical optimization methods cannot be applied
to find the solutions of these non-convex discrete
optimization problems effectively. Metaheuristic
approaches provide alternative methods to find
solutions based on automated selection of heuristic
rules. Evolutionary computation is based on
metaheuristic approaches to solve these complex non-
convex optimization problems. A lot of evolutionary
algorithms appeared in past decades. For example,
Firefly algorithm (Yang, 2009), (Li et al., 2022) and
PSO algorithms (Shami, et al. 2022) were proposed
to solve optimization problems. Firefly algorithm has
been applied to solve parameter estimation problem
Hsieh, F.
A Hybridized Scheme for Solving Ridesharing Problems Based on Firefly Algorithm and a Variant of PSO Algorithm.
DOI: 10.5220/0012761300003690
Paper published under CC license (CC BY-NC-ND 4.0)
In Proceedings of the 26th International Conference on Enterprise Information Systems (ICEIS 2024) - Volume 2, pages 769-774
ISBN: 978-989-758-692-7; ISSN: 2184-4992
Proceedings Copyright © 2024 by SCITEPRESS – Science and Technology Publications, Lda.
769
(Sarangi at al., 2018), clustering problem (Alam and
Muqeem, 2022) and economic dispatch problem
(Sulaiman et al., 2012). PSO algorithm has been
applied in Electric Power Systems (AlRashidi and El-
Hawary, 2009), Task Scheduling (Valarmathi and
Sheela, 2017) survey planning (Seah et al., 2015) and
ridesharing systems (Hsieh, 2022), (Hsieh, 2023).
Different evolutionary algorithms can be
regarded as different mechanisms to automated
selecting heuristic rules to optimize performance. An
interesting research issue is study whether combining
different evolutionary algorithms can improve
performance or convergent speed. However, whether
combining different evolutionary algorithms to solve
these non-convex discrete optimization problems is
effective need further study.
The goal of this paper is to provide a proof of
concept to study effectiveness of hybridizing the
strategies of two evolutionary algorithms, the Firefly
algorithm and a simplified version of PSO algorithm
called the Simplified PSO (SPSO) algorithm. A
hybrid algorithm is proposed based on the above
mentioned hybridization mechanism to illustrate that
the idea. To verify effectiveness of the hybridization
mechanism, several experiments were conducted.
The results indicated the proposed hybridization
mechanism based algorithm works effectively and
find the solutions more efficiently than the original
Firefly or PSO algorithms running alone or the hybrid
FA-PSO algorithm (Hsieh, 2024).
The structure of this paper is as follows. In Section
II, the instance of discrete optimization problem used
to study the effectiveness of hybridization will be
introduced. The fitness function and the hybridized
algorithm are presented in Section III. We compare
the results of PSO algorithm, SPSO algorithm,
Firefly-PSO algorithm and Firefly-SPSO algorithm
in Section IV. In Section V, we conclude this paper
and suggest a future research direction based on the
results of this study.
2 THE PROBLEM
As this paper aims to provide a proof of hybridization
concept, a problem must be selected for testing the
proposed algorithm. As the decision problem of
shared mobility systems is a complex constrained
discrete optimization problems, it is used as a good
candidate for testing the hybridization concept. We
will summarize the problem formulation as follows.
We will propose a hybridized algorithm for this
problem later and study the effects of hybridization
through experiments.
Let’s consider a system with
P
passengers and
D
drivers. We assumed that the drivers and riders send
requests to the shared mobility system. To formulate
the decision problem of a shared mobility system as a
constrained discrete optimization problem, the
requests sent by passengers and drivers are
represented by
P
p
b
,
},....3,2,1{ Pp
, and
D
dj
b
,
},...,1{},...,1{
d
JjDd
respectively. The
details of
P
p
b
is defined by
P
p
b
=
),,...,,,(
321 ppKppp
fssss , where
pk
s is the requested
seats at location
k
and
p
f is the original price of
passenger
p
. The details of
D
dj
b
is defined by
D
dj
b
=
),,,...,,,(
321 djdjdjKdjdjdj
coqqqq , where
j
the request
index of driver
d
,
djk
q is the seats available to pick up
passengers at location
k
,
dj
c is the travel cost and
dj
o is
the original travel cost of
d
in case the driver travels
alone.
To formulate the optimization problem, we define
dj
x ,
},...,1{},...,1{
d
JjDd
and
p
y ,
},....3,2,1{ Pp
as decision variables for drivers’
requests and passengers’ requests, respectively. If the
request
D
dj
b
is accepted,
dj
x is 1. Otherwise,
dj
x is zero.
If the request
P
p
b
is accepted,
p
y is 1. Otherwise,
p
y is
zero. To optimize total cost savings, we define the
objective function as
)(),(
111
djdjdj
D
d
J
j
P
p
pp
coxfyyxF
d
+=

===
.
We can describe the supply/demand constraints of
the seats by
K}{1,2,...,k
111

===
D
d
P
p
pkp
J
j
djkdj
syqx
d
(1)
We can describe the nonnegative cost savings
constraints by
djdj
D
d
J
j
djdj
D
d
J
j
P
p
pp
cxoxfy
dd

=====
+
11111
(2)
We can describe the constraints that each driver
will have at most one request accepted by
=
d
J
j
dj
Ddx
1
},...,1{1 (3)
SEC-SCIS 2024 - Special Session on Soft Computing in Ethicity and Smart Cities Services
770
In addition, the constraints that decision variables
can only be binary are described by
},...,1{},...,1{}1,0{
ddj
JjDdx (4)
},...,1{}1,0{ Ppy
p
(5)
The shared mobility problem is formulated as:
)5(),4(),3(),2(),1(..
),(max
,
ts
yxF
yx
As the problem stated above is a discrete optimization
problem, it is not convex. One approach to solving
nonconvex problems is to adopt evolutionary
algorithms. We will propose an evolutionary
algorithm by combining Firefly algorithm and SPSO
algorithm.
3 FITNESS FUNCTION AND
SOLUTION ALGORITHM
To develop an evolutionary algorithm to solve an
optimization problem, a fitness function must be
defined. The purpose of the fitness function is to
assess the quality of a solution. Therefore, it must
consider both the performance and feasibility of a
solution. Performance of a solution is evaluated using
the objective function. The fitness function must
include the objective function. Feasibility of a
solution is evaluated based on violation of
constraints. There are several ways to evaluate
violation of constraints. We adopt the following
function
),( yxU
to evaluate violation of constraints.
Let
f
S be the set of all feasible solutions in a
generation.
For the worst solution in the generation, the
corresponding objective function value of is
),(min
),(
min
yxFS
f
Syx
f
=
. We define
),(
),(),(),(),(),(
5
4321min
yxU
yxUyxUyxUyxUSyxU
f
+++++=

====
=
P
p
pkpdjkdj
D
d
J
j
K
k
syqxyxU
d
1111
1
)(),(
)1(),(
11
2
==
=
d
J
j
dj
D
d
xyxU
)0.0),min(
),(
11111
3
djdj
D
d
J
j
djdj
D
d
J
j
P
p
pp
cxoxfy
yxU
dd

=====
+
=
.
Based on the above function, we define the fitnesss
function
),(
1
yxF
as follows:
𝐹
(𝑥,𝑦) =
𝐹(𝑥,𝑦) 𝑖𝑓 (𝑥,𝑦) 𝑠𝑎𝑡𝑖𝑠𝑓𝑖𝑒𝑠 𝑐𝑜𝑛𝑠𝑡𝑟𝑎𝑖𝑛𝑡𝑠(1)~(6)
𝑈(𝑥,𝑦) 𝑜𝑡𝑒𝑟𝑤𝑖𝑠𝑒
.
As the algorithm developed in this paper is
through combining the strategies to update positions
in Firefly algorithm and the SPSO algorithm, the
mechanisms to update positions in the Firefly
algorithm and the SPSO algorithm are introduced first.
The Firefly algorithm works based on several
parameters, including
distance between firefly
i
a n d
firefly
j
,
ij
r
, light absorption coefficient,
γ
, a n d
attractiveness for firefly
i
and firefly
j
,
2
0
ij
r
e
γ
β
,
t
in
ε
:
a random value in [0, 1] and a constant
α
in [0, 1],
The Firefly algorithm updates the positions of
firefly
i
according to a better firefly
j
as follows.
t
ininjn
r
inin
xxexvx
ij
αεβ
γ
++
)(
2
0
t
ininjn
r
inin
yyeyvy
ij
αεβ
γ
++=
)(
2
0
The SPSO algorithm updates the positions of
firefly
i
according to firefly
j
as follows.
The SPSO algorithm
generates
random variables
1
r
with uniform distribution
)1,0(U
and updates
positions of individuals
as follows.
)(
11 inininin
xPxrcvxvx +
)(
11 inininin
yPyrcvyvy +
To describe the proposed algorithm, we use
max
t
to denote total iterations and
M
to denote the
population size. The solution found by an individual
is represented by
i
Z
= (
i
x
,
i
y
) , w h e r e
},...,2,1{ Ii
and
i
x
and
i
y
are the vectors for decision variables
x
and
y
, respectively. Let
N
denote the total dimension
of
x
and
y
. The maximal value of each element in
i
Z
is
max
V
.
The algorithm proposed is to combine the logic of
the standard Firefly algorithm to update positions of
A Hybridized Scheme for Solving Ridesharing Problems Based on Firefly Algorithm and a Variant of PSO Algorithm
771
firefly
i
according to a better firefly
j
with the logic
of
the standard SPSO algorithm to update positions of
firefly
i
in case firefly
j
is worse. In short, the pseudo
code of the proposed algorithm is as follows.
To describe the proposed algorithm, we use
max
t
to denote total iterations and
M
to denote the
population size. The solution found by an individual
is represented by
m
Z
=(
m
x
,
m
y
), where
},...,2,1{ Mm
and
m
x
and
m
y
are the vectors for
decision variables
x
and
y
, respectively. Let
N
denote the total dimension of
x
and
y
. The maximal
value of each element in
m
Z
i s
max
V
. Let
g
Z
denote
the global best
.
The algorithm proposed is to combine the logic of
the standard Firefly algorithm to update positions of
firefly
i
according to a better firefly
j
with the logic
of
the standard SPSO algorithm to update positions of
firefly
i
in case firefly
j
is worse. In short, the pseudo
code of the proposed algorithm is as follows.
FA-SPSO Algorithm.
Step 1:
0t
Set
γ
,
0
β
and
α
For each
},...,2,1{ Ii
Generate
i
Z
End For
Step 2:
While (generation
max
tt <
)
{
For
},...,2,1{ Ii
)(
ii
ZTZ =
)(
1 i
ZF
End For
For
},...,2,1{ Ii
For
},...,2,1{ Ij
If
))()((
11 ji
ZFZF <
For
},...,2,1{ Nn
t
ininjn
r
inin
xxexvx
ij
αεβ
γ
++
)(
2
0
t
ininjn
r
inin
yyeyvy
ij
αεβ
γ
++=
)(
2
0
End For
Else
For
},...,2,1{ Nn
Generate
random variables
1
r
with uniform
distribution
)1,0(U
)(
11 inininin
xPxrcvxvx +
)(
11 inininin
yPyrcvyvy +
End For
End If
End For
For
},...,2,1{ Nn
If
max
Vvx
in
>
max
Vvx
in
End If
If
max
Vvx
in
<
max
Vvx
in
End If
If
max
Vvy
in
>
max
Vvy
in
End If
If
max
Vvy
in
<
max
Vvy
in
End If
Generate
rsid
from
)1,0(U
,
where
)1,0(U
denotes
uniform distribution
<
=
otherwise
vxTrsid
x
in
in
0
)(1
, where
)(xT
=
1
1
2
2
+
x
x
e
e
Generate
rsid
from
)1,0(U
,
where
)1,0(U
denotes
uniform distribution
<
=
otherwise
vxTrsid
y
in
in
0
)(1
, where
)(xT
=
1
1
2
2
+
x
x
e
e
End For
),(
iii
yxZ =
End For
Update the global best
g
Z
1+tt
}
4 RESULTS
To study effectiveness of the hybridization
mechanism adopted in this paper, several test cases
were used to perform experiments. The experiments
include solving the test cases by PSO, Firefly, SPSO,
FA-PSO and FA-SPSO algorithms. The parameters
used in the experiments are summarized in this
section. The results of experiments will be compared
based on the fitness value and generations for finding
solutions.
SEC-SCIS 2024 - Special Session on Soft Computing in Ethicity and Smart Cities Services
772
For each algorithm, the population size,
M
, is set
to 30. The maximum generation for each simulation
run is
max
t
=10000. The maximal value
max
V
for each
element in the solution vector is 4.
For PSO, the parameters
ω
=0.4,
1
c
=0.4,
2
c
=0.6
are used.
For SPSO, the parameters
ω
=0.4,
1
c
=0.4
are used.
For the Firefly, the parameters
0
β
=1.0,
γ
=0.2,
α
=0.2 are used.
For the
FA-PSO
, the parameters
ω
=0.4,
1
c
=0.4,
2
c
=0.6,
0
β
=1.0,
γ
=0.2,
α
=0.2 are used.
For the
FA-SPSO
, the parameters
ω
=0.4,
1
c
=0.4,
0
β
=1.0,
γ
=0.2,
α
=0.2 are used.
We applied each algorithm to each test case 10
times, record the results and find the average fitness
value and generations. The results are listed in Table
1 and Table 2. Table 1 shows the average fitness
function values for all algorithms tested. Table 2
shows the average generation values required for all
algorithms and all test cases. The results show that
each test case can be solved by each algorithm and the
average fitness value found by each algorithm is the
same. But the average generations needed for
different algorithms are largely different. The average
generations needed for FA-PSO algorithm and FA-
SPSO algorithm are smaller than those of FA and
PSO algorithm. Moreover, the average generations
needed for FA-SPSO algorithm are smaller than that
of FA-PSO algorithm for most test cases in the
experiments.
Table 1: Average Fitness Function Values (
NP
=30).
Table 2: Average number of generations (
NP
=30).
Figure 1 shows the convergence speed of different
algorithms for one of the case. It indicates that FA-
SPSO algorithm enjoys faster convergence speed.
Figure 1: Convergence speed of different algorithms for an
example.
5 CONCLUSIONS
Due to computational complexity, constrained
discrete optimization problems requires efficient
problem solvers to find solutions. Evolutionary
computation approach is a practical approach for
solving constrained discrete optimization problems.
How to improve computational efficiency of
evolutionary computation approach in solving
constrained discrete optimization problems is an
important issue. Intuitively, combining the strategies
of two evolutionary computation approaches may be
helpful for increasing the diversity of the candidate
solutions generated in the evolution processes and
may improve either performance or convergence
speed. Motivated by this issue, we propose a scheme
to combine the strategies of two evolutionary
computation approaches. Two evolutionary
algorithms were selected to verify our scheme. We
study the approach to improve efficiency of
evolutionary computation approach through
hybridization of Firefly algorithm and SPSO
algorithm. We proposed an algorithm by hybridizing
Firefly algorithm and SPSO algorithm and study
effectiveness of the proposed method. Several test
cases were used to test the performance and
convergence rates of different algorithms for these
test cases. For performance, the results showed that
all the algorithms tested can find the same solutions.
That is, all of these algorithms perform equally well.
The results indicated the algorithm based on
hybridization of Firefly algorithm and SPSO
algorithm improve the convergence rate. The results
of this study sparks an interesting future research
direction to study whether the hybridization
A Hybridized Scheme for Solving Ridesharing Problems Based on Firefly Algorithm and a Variant of PSO Algorithm
773
mechanism can work effectively for other
evolutionary computation approaches and problems.
For example, effectiveness of hybridization of Firefly
algorithm with other meta-heuristic approaches such
as the ones proposed in (Hsieh, 2022) and (Hsieh,
2024) is one interesting future research direction.
ACKNOWLEDGEMENTS
This paper was supported in part by National Science
and Technology Council, Taiwan, under Grant
NSTC-111-2410-H-324-003.
REFERENCES
Alam, A. and Muqeem, M. (2022) Automatic Clustering
for Selection of Optimal Number of Clusters by K-
Means Integrated with Enhanced Firefly Algorithms,
2022 2nd International Conference on Technological
Advancements in Computational Sciences (ICTACS),
Tashkent, Uzbekistan, pp. 343-347.
AlRashidi, M. R. and El-Hawary, M. E. (2009) A Survey
of Particle Swarm Optimization Applications in
Electric Power Systems, IEEE Transactions on
Evolutionary Computation, vol. 13, no. 4, pp. 913-918.
Fiedler, D., Čertický, M. Alonso-Mora, J. and Čáp, M.
(2018). The Impact of Ridesharing in Mobility-on-
Demand Systems: Simulation Case Study in Prague,
2018 21st International Conference on Intelligent
Transportation Systems (ITSC), 2018, pp. 1173-1178.
Hsieh, F.S. (2022) A Theoretical Foundation for Context-
Aware Cyber-Physical Production Systems Applied
Sciences 12, no. 10: 5129.
Hsieh, F.S. (2022) An Efficient Method to Assess
Resilience and Robustness Properties of a Class of
Cyber-Physical Production Systems, Symmetry, vol. 14,
no. 11: 2327.
Hsieh, F.S. (2023) Improving Acceptability of Cost Savings
Allocation in Rides-haring Systems based on Analysis
of Proportional Methods, Systems, vol. 11, no. 4, pp.
187-218.
Hsieh, F.S. (2022) "Development and Comparison of Ten
Differential-Evolution and Particle Swarm-
Optimization Based Algorithms for Discount-
Guaranteed Ridesharing Systems" Applied Sciences,
vol.12, no. 19: 9544.
Hsieh, F.S. (2024) Comparison of a Hybrid Firefly–
Particle Swarm Optimization Algorithm with Six
Hybrid Firefly–Differential Evolution Algorithms and
an Effective Cost-Saving Allocation Method for
Ridesharing Recommendation Systems" Electronics 13,
no. 2: 324.
Hsieh, F.S. (2024) A Self-Adaptive Meta-Heuristic
Algorithm Based on Success Rate and Differential
Evolution for Improving the Performance of
Ridesharing Systems with a Discount Guarantee,
Applied Sciences, vol.17, no. 1: 9.
Hsieh, F.S. (2022) Trust-Based Recommendation for
Shared Mobility Systems Based on a Discrete Self-
Adaptive Neighborhood Search Differential Evolution
Algorithm" Electronics 11, no. 5: 776.
Li, J., X. Wei, B. Li, Z. Zeng (2022) A survey on firefly
algorithms, Neurocomputing, vol. 500, pp. 662-678.
Sarangi, S. K., R. Panda and A. Sarangi (2018) Design of
adaptive IIR filter with modified firefly algorithm for
parameter estimation, 2018 Technologies for Smart-
City Energy Security and Power (ICSESP),
Bhubaneswar, India, 2018, pp. 1-5.
Seah, M. S., W. L. Tung and T. Banks (2015 ) A Novel
Discrete Particle Swarm Optimization approach to
large-scale survey planning, 2015 11th International
Conference on Natural Computation (ICNC),
Zhangjiajie, China, pp. 261-268.
Shami, T.M., A. A. El-Saleh, M. Alswaitti, Q. Al-Tashi, M.
A. Summakieh and S. Mirjalili (2022) Particle Swarm
Optimization: A Comprehensive Survey, IEEE Access,
vol. 10, pp. 10031-10061.
Sulaiman, M. H., M. W. Mustafa, Z. N. Zakaria, O. Aliman
and S. R. Abdul Rahim (2012) Firefly Algorithm
technique for solving Economic Dispatch problem,
2012 IEEE International Power Engineering and
Optimization Conference Melaka, Malaysia, Melaka,
Malaysia, pp. 90-95.
Yang, X.S (2009) Firefly algorithms for multimodal
optimization, CONFERENCE 2009, LNCS, 5792, pp.
169–178.
Valarmathi, R. and T. Sheela (2017) A comprehensive
survey on Task Scheduling for parallel workloads based
on Particle Swarm optimisation under Cloud
environment, 2017 2nd International Conference on
Computing and Communications Technologies
(ICCCT), Chennai, India, pp. 81-86.
SEC-SCIS 2024 - Special Session on Soft Computing in Ethicity and Smart Cities Services
774