import java.io.*; import java.util.*; import java.util.Arrays; import org.chocosolver.solver.Model; import org.chocosolver.solver.Solver; import org.chocosolver.solver.variables.IntVar; import org.chocosolver.solver.constraints.IIntConstraintFactory.*; import org.chocosolver.solver.search.strategy.Search; public class AllocateBP { Person person[]; // the employees to be allocated to cost centres int salary[]; // salary[i] of ith person Model model; // the model Solver solver; // the solver object IntVar employee[]; // employee[i] = j <-> ith employee is in cost centre j IntVar costCentre[]; // sum of salaries in cost centre int budget; // the budget for each cost centre int n; // number of employees int m; // number of cost centres String id; // an identification for the problem public AllocateBP(String fname,int numberOfPeople,int numberOfCostCentres,int budget) throws Exception { n = numberOfPeople; m = numberOfCostCentres; this.budget = budget; id = fname; person = new Person[n]; salary = new int[n]; model = new Model(id); solver = model.getSolver(); employee = model.intVarArray("employee",n,0,m-1); costCentre = model.intVarArray("cost centre",m,0,budget); Scanner sc = new Scanner(new File(fname)); for (int i=0;i