def get_average_mos(solution, ignore_non_served=False):
  """Returns the average MOS of a solution.
  """
  smos = 0
  nserved = 0
  for u in solution["users"]:
    if "mos" in u:
      smos += u["mos"]
      nserved += 1
  if ignore_non_served:
    # only take into account users that get some video
    return smos/nserved
  else:
    # calculate avg QoE across all users
    return smos/len(solution["users"])