Forum Discussion
FICO
5 years agoCommunity Manager
Hi, I am in the process of developing a simple optimization model for a supply chain. Two of the constraints relate to suppliers and the kitting facility.
The two constraints are: 1) Only one kitting facility can be chosen 2) Only one (or a variable number) of suppliers of one ingredient needs to be chosen. Why don't the constraints expressed on lin...
FICO
5 years agoCommunity Manager
Good evening,
Can you point me to a resource or explain to me how I can set the ranges for suppliers, possible kitting facilities and copackers based on the data read in from the Excel file?
Currently, it is hard-coded and thus not very flexible. I will eventually also encode each of the suppliers with key to correspond to an ingredient but that is the next step.
I have copied part of the code below. Note that I have left out the Excel file because it is calling an API through a macro.
model Model_v7
!options noimplicit
!Changes from v1: Data points read rather than entered
!Ingredients added to the model
uses "mmxprs"
uses "mmsheet"
! uses "mminsight" ! uncomment this line for an Xpress Insight model
parameters
dataSource = "dataCapstone.xlsm" ! Use Excel spreadsheet `dataCapstone.xlsx'
end-parameters
! Declaration of sets. This is will eventually be a list
declarations
Supplier_sites = 1..16 !Defines the supplier sites
Potential_kf = 1..11 !Defines the potential kitting facilities
Copackers = 1..6 ! Defines the copackers
Ingredients = 1..8 ! Defines the number of ingredients
test_Supplier_sites: array(Ingredients) of list of integer
!...
end-declarations
!Declaration of parameters
declarations
DISTANCES_M1: dynamic array (Supplier_sites,Potential_kf ) of real ! Distances from sp sites to potential kfs
DISTANCES_M2: dynamic array(Potential_kf, Copackers) of real ! Distances from sp sites to potential kfs
! INGREDIENT_DEMAND: array(Ingredients) of real
end-declarations
!read data from file
initializations from "mmsheet.excel:"+dataSource
DISTANCES_M1 as 'Supplier_PotentialKf'
DISTANCES_M2 as 'Possiblekf_Copacker'
end-initializations
declarations
supplier_kf: array(Supplier_sites,Potential_kf) of mpvar
kf_copacker: array(Potential_kf, Copackers) of mpvar
kf: array(Potential_kf) of mpvar
!sp: array(Supplier_sites) of mpvar
end-declarations
! Objective: Minimize the overall cost of the new supply chain
MinCost := sum(i in Supplier_sites, j in Potential_kf )supplier_kf(i,j)*DISTANCES_M1(i,j) + sum(i in Potential_kf, j in Copackers) kf_copacker(i,j)*DISTANCES_M2(i,j)
test_Supplier_sites :: [[1],[2,3],[4],[5],[6],[7,8],[9,10],[11,12,13,14,15,16]]Lines 17,18 and 19 restricts the input to the specific range which makes it rigid.
Thanks again @Tristan Gally and @Susanne Heipcke for all the input.

