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
@Susanne Heipcke
Hi!
I attempted to implement your suggestion and realized my Excel sheet is not set up to read in the index values. As far as your explanation, that makes sense since my named ranges consist of pairs.
To address this issue, I decided to instead go ahead and create named/dynamic ranges simply for the index and then read it in. Sort of like this:
model Model_v9
!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 = array(Supplier_list) of integer !Defines the supplier sites
Potential_kf = array(Potentialkf_list) of integer !Defines the potential kitting facilities
Copackers = array(Copackers_list) of integer ! Defines the copackers
Ingredients = array(Ingredients_list) of integer ! 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
end-declarations
!read data from file
initializations from "mmsheet.excel:"+dataSource
DISTANCES_M1 as 'Supplier_PotentialKf'
DISTANCES_M2 as 'Possiblekf_Copacker'
Supplier_list as !Named range for index
Potentialkf_list !Named range for index
Copackers_list !Named range for index
Ingredients_list !Named range for index
end-initializations
!DISTANCES_M2(4,1) := 1000000 Uncomment this line to obtain the second optimal city to locate the possible facility location - Big M method
!DISTANCES_M2(8,1) := 1000000 Uncomment this line to obtain the third optimal city to locate the possible facility location - Big M method
declarations
supplier_kf: array(Supplier_sites,Potential_kf) of mpvar
kf_copacker: array(Potential_kf, Copackers) of mpvar
kf: array(Potential_kf) of mpvar
end-declarations
forall(i in Supplier_sites,j in Potential_kf) do
writeln(DISTANCES_M1(i,j))
writeln("Index: "+i+" "+j)
end-doI have not been able to prove that this works yet. I intended to do so tomorrow morning.
I hope you can provide some input on whether I am on the right track.
Sincerely,
Kibrom

