%---------------------------------------------------------------------- % Example for basic use of ECLiPSe/CPLEX/XPRESS-MP interface % This code uses array notation and requires ECLiPSe 7.0 or later. % % A tiny transportation problem: 3 plants with certain capacity, % 4 clients with certain demands, transport costs between them. % Organise the supply such that the transport costs are minimal. %---------------------------------------------------------------------- :- lib(eplex). main3(Cost, Supply) :- data(PlantCapacities, ClientDemands, TranspCosts), dim(TranspCosts, [NClients,NPlants]), % get dimensions dim(Supply, [NClients,NPlants]), % make variables Supply :: 0.0..inf, % initial bounds ( for(J,1,NClients), param(ClientDemands,Supply) do sum(Supply[J,*]) $= ClientDemands[J] ), ( for(I,1,NPlants), param(PlantCapacities,Supply) do sum(Supply[*,I]) $=< PlantCapacities[I] ), Objective = sum(concat(TranspCosts)*concat(Supply)), optimize(min(Objective), Cost). % solve data( [](500, 300, 400), % PlantCapacities [](200, 400, 300, 100), % ClientDemands []([](10, 7, 11), % TranspCosts []( 8, 5, 10), []( 5, 5, 8), []( 9, 3, 7)) ).