For several years, we have been witnessing an increase in pollution and traffic jams in large cities. Research has therefore focused on the development of new, greener, and more flexible means of transport to complement the existing static transport offer. These means of transport are intended to be shared and dynamic to attract more people. One of these promising means of transportation is dynamic multi-hop ridesharing which makes it possible to route a rider through several drivers for a more flexible ridesharing offer. While the majority of papers on this topic deal with the global optimality of the system, we are interested in a preferential optimization for each individual in the system. In this context, this paper addresses an innovative solution to the on-demand multi-hop dynamic ridesharing problem where each actor (driver or rider) is represented by an autonomous and interactive entity called an “agent.” This ridesharing system is, therefore, a multi-agent system (MAS) in which each agent has a limited rationality. This MAS permits us to define the communications, perceptions, and preferences of drivers and riders. We detail a preference-weighted objective function for riders that allows the simulation of a wide range of behaviors. We propose the use of R-trees to optimize the computational cost of identifying candidate drivers and the best associated transfer nodes. We present various simulation scenarios by varying user preferences and instance parameters. Our experiments show that our model can efficiently simulate real-world behaviors and is able to optimize ridesharing on a case-by-case basis.