This Prolog program is used for allocating a quantity of a certain part across multiple suppliers, with the objective to minimize the total cost of ownership (TCO). It also considers sourcing strategy constraints such as maximum allowed allocation per supplier, minimum and maximum possible allocations per supplier and part, and supplier capacity constraints.
To run this program, you will need a Prolog interpreter. This script was developed using SWI-Prolog.
- Download or clone this repository to your local machine.
- Open SWI-Prolog.
- Navigate to the directory containing the Prolog script using the
cd
command in the SWI-Prolog terminal. - Load the script by typing
['script.pl'].
, replacingscript.pl
with the filename of your script.
The main predicate in the program is global_allocate_with_constraints/2
. Here is how you can use it:
?- global_allocate_with_constraints(Allocation, MaxCost).
Allocation
is a list of quantities to be allocated to each supplier for each part.MaxCost
is the maximum allowed total cost. The program will find solutions where total cost is less than or equal to MaxCost.
Here's an example query:
?- global_allocate_with_constraints(Allocation, 20000).
This will find an allocation of parts across the suppliers, such that the total cost does not exceed 20000 and is as low as possible.
The procurement optimization program supports various constraints and features to fine-tune the allocation process:
-
Supplier Capacities and Costs: You can modify the capacities and costs of suppliers by using the
capacity/3
andcost/3
facts. The format iscapacity(Supplier, Part, Capacity)
andcost(Supplier, Part, Cost)
, whereSupplier
andPart
are atoms,Capacity
is an integer representing the maximum quantity that the supplier can provide, andCost
is the cost per unit from the supplier. -
Demand: Specify the demand for each part using
demand/2
(formatdemand(Part, Quantity)
). -
Global Supplier Capacity: Specify the global capacity of each supplier using
global_capacity/2
(formatglobal_capacity(Supplier, Capacity)
). -
Allocation Ranges: Specify the range of possible allocations for each supplier and part using
can/4
(formatcan(Part, Supplier, Min, Max)
). This helps enforce sourcing strategy rules like minimum or maximum allocation to a specific supplier for a part.
This project is licensed under the GPLv3 License.
Copyright (c) 2023 Ahmed Khalil Hafsi