25 std::vector<int> machines = {0,1};
26 std::vector<int> jobs = {0,1};
28 std::vector<std::vector<int>> cost(2, std::vector<int>(2));
33 auto costf = [&](
int i,
int j) {
return cost[i][j]; };
35 std::vector<std::vector<int>> time(2, std::vector<int>(2));
40 auto timef = [&](
int i,
int j) {
return time[i][j]; };
42 std::vector<int> T = { 2, 2 };
43 auto Tf = [&](
int i) {
return T[i]; };
45 std::vector<std::pair<int, int>> jobs_to_machines;
49 machines.begin(), machines.end(), jobs.begin(), jobs.end(), costf,
50 timef, Tf, std::back_inserter(jobs_to_machines));
53 if (result.first == paal::lp::OPTIMAL) {
54 for (
auto jm : jobs_to_machines) {
55 std::cout <<
"Job " << jm.first <<
" assigned to Machine "
56 << jm.second << std::endl;
58 std::cout <<
"Cost of the solution: " << *(result.second) << std::endl;
60 std::cout <<
"The instance is infeasible" << std::endl;
62 paal::lp::glp::free_env();
IRResult generalised_assignment_iterative_rounding(MachineIter mbegin, MachineIter mend, JobIter jbegin, JobIter jend, const Cost &c, const ProceedingTime &t, const MachineAvailableTime &T, JobsToMachinesOutputIterator jobs_to_machines, Components components=Components(), Visitor visitor=Visitor())
Solves the Generalised Assignment problem using Iterative Rounding.
int main()
[Generalised Assignment Example]