A flexible hierarchical model for project selection and budget allocation*