The survival of many ecological communities relies on the symbiotic relationships formed by various organisms. An example of a symbiotic association that is often described as mutualistic is the one between corals and algae. Since the algae are located within coral epidermis, they are referred to as "endosymbiont" (more generally "symbiont") whereas the corals are referred to as "host." This association is based on the exchange of photosynthetically fixed carbon from algae to corals and inorganic nutrients, acquired from animal waste metabolites or directly from seawater, from corals to algae. The evolution of this symbiotic relationship has enabled the emergence of highly productive and diverse coral reef ecosystems in nutrient-poor waters of the tropical oceans. Here we present an adaptive, trait-based model that describes the temporal dynamics of this association. Given that corals control the flux of inorganic nutrients to the algae, we focus on the adaptation of a hypothetical trait expressed by the coral population: investment of energy in the symbiotic relationship. Investment of energy produces losses for the corals that reflect costs for algal photosynthetic efficiency and for sustaining and maintaining the symbiont population. The fitness of the coral is modeled as the net benefit obtained by the symbiotic association. The model features a decrease in the fraction of energy invested by the corals with increasing symbiont to host biomass ratio. Our sensitivity analyses show that the best conditions for the survival of the simulated coral-algae community occur for a broad range of symbiont to host biomass ratio if the costs of symbiosis are low. With increasing costs, the survival region narrows down to a smaller range of symbiont to host biomass ratio. Finally, a break down of the symbiotic relationship and a consequent collapse of the coral-algae system occur under shock changes in algal abundance.