Homework

Nectar storage vs. hive expansion in a bee colony

A bee colony operates throughout a flowering season of length t_\mathrm{f}. During this period, the colony must allocate its foraging effort between two key activities

  • Hive expansion: Increasing the number of worker bees to support future nectar collection (e.g., raising brood and constructing comb).
  • Nectar collection: Gathering nectar to convert into honey, which serves as the colony’s energy reserve for the coming non-flowering season.

At any time t \in \left[0, t_\mathrm{f}\right], the colony allocates a fraction u(t) \in [0, 1] of its foraging effort toward hive expansion, with the remaining fraction 1 - u(t) used for nectar collection. The hive’s ability to perform either task depends on its current size, and bees die at a natural rate proportional to their population.

Let

  • x_1(t) denote the effective hive size (i.e., the number of active foragers), and
  • x_2(t) the cumulative amount of nectar collected by time t.

The system dynamics are governed by

\begin{aligned} \dot{x}_1(t) &= 2u(t)x_1(t) - x_1(t),\\ \dot{x}_2(t) &= (1 - u(t))x_1(t). \end{aligned}

The hive size and nectar reserves are assumed to remain non-negative throughout the season, consistent with their physical interpretation. Also assume nonzero hive size at the beginning of the season, i.e., x_1(0) > 0.

Your objective

Find the optimal allocation strategy u(t) that maximizes the total nectar stored by the end of the season, i.e., maximize x_2(t_\mathrm{f}) for a fixed t_\mathrm{f}.

Note

Similar problems may appear on the final exam, so focus on understanding what you are doing and why.

Your tasks

  1. Formulate the Hamiltonian, derive the state and co-state equations.
  2. Use Pontryagin’s maximum principle to determine the optimal control strategy u^\star as a function of the co-states, i.e., u^\star(\lambda_1, \lambda_2). What can be immediately concluded about the optimal control?
  3. Solve the co-state equations, to determine the co-states \boldsymbol{\lambda}(t) on the interval [0, t_\mathrm{f}].
  4. Use the co-states to express u^\star as purely a function of time (and t_\mathrm{f}).
Hints for solving the co-state equations
  1. There is a way to determine the terminal condition \boldsymbol{\lambda}(t_\mathrm{f}).
  2. This allows you to immediately determine the value of one of the co-states.
  3. From \boldsymbol{\lambda}(t_\mathrm{f}), you can also determine u^\star(t_\mathrm{f}) using your earlier result.
  4. Since all necessary information is given at the end of the control interval rather than the beginning, you’ll need to solve the co-state equations backwards in time. This can be done by reversing time and solving the system as a standard initial value problem.

Upload the following files as a single .zip file to BRUTE system.

  • hw.pdf containing your derivation of the problem solution. We do not require a \LaTeX report; handwritten notes suffice, but they must be readable.
  • hw.jl, based on the template below, containing a function u_opt(t, tf) that implements the final closed-form expression for your derived optimal control u^\star(t).
function u_opt(t, tf)
    return 1
end

Your homework will be automatically evaluated by the BRUTE system based on your Julia implementation, so you can immediately see if you have arrived at the correct solution. However, full point will be awarded only after a manual review of the derivation by us.

Back to top