(Cplex) 지역적으로 제한된 P-Median Cplex 코드 입력

쉬운 목차

모델

고객: 수요

중량 : 소요지역의 소요수량

WellfareCenters: 후보 사이트

int P = ...;
{string} Customers = ...;
{int} WellfareCenters = ...;
int Weight(Customers) = ...;
float Distance(Customers)(WellfareCenters) = ...;
{Point} Region = ...;

혼동을 피하기 위해 고객은 문자열로 설정됩니다.

//Variables
dvar boolean OpenWellfareCenters(WellfareCenters);
dvar boolean AllocToCustomer(Customers)(WellfareCenters);
//Objective
minimize 
  sum( c in Customers , w in WellfareCenters ) 
    Weight(c)*Distance(c)(w)*AllocToCustomer(c)(w);

튜플을 만들고 붙여넣기

영역 내에 입력해야 하는 시설에 유의하십시오.

전. 한 부위에 3회, 4회, 5회

tuple Point {
  int x; 
  int y; 
}

//Constraints
subject to {
  forall( c in Customers )
    ctAlloc:
      sum( w in WellfareCenters ) 
        AllocToCustomer(c)(w) == 1;

    ctOpen:
      sum( w in WellfareCenters ) 
        OpenWellfareCenters(w) == P;

  forall( point in Region )
    ctRegion:
      sum( w in point.x..point.y ) 
        OpenWellfareCenters(w) == 1;

  forall( c in Customers , w in WellfareCenters )
    ctAllocOpen:
      AllocToCustomer(c)(w) <= OpenWellfareCenters(w);
}

저것

부지 시설 수 P

P=15; //입지할 시설 개수 p

수요면적(362)

Customers = {aware	,intention	,glide	,diagram	,magnetic	,harmful	,clear	,guarantee	,wave	,moving	,insert	,neglect	,beam	,linear	,sail	,annual	,argument	,tissue	,functional	,leadership	,indirect	,panic	,advice	,throne	,pitch	,anger	,night	,offensive	,sacrifice	,strong	,cheque	,qualification	,coat	,comedy	,devote	,jealous	,security	,absent	,pawn	,location	,hit	,arrow	,cope	,flourish	,version	,win	,established	,colony	,excitement	,entertain	,space	,shatter	,reverse	,reproduction	,hang	,high	,elite	,use	,fuss	,demonstrator	,sausage	,farewell	,lost	,embarrassment	,trunk	,neck	,decrease	,explode	,convince	,suitcase	,fair	,dangerous	,publish	,forward	,reach	,sum	,biscuit	,corpse	,parallel	,river	,alcohol	,chin	,sun	,debt	,routine	,chain	,scandal	,rage	,job	,pity	,revive	,impact	,bird	,wing	,waist	,embryo	,call	,second	,national	,consideration	,jest	,hike	,justify	,deteriorate	,fame	,obese	,formula	,activate	,lip	,dive	,pack	,border	,sun	,figure	,guideline	,bird	,digress	,advocate	,script	,address	,glasses	,unity	,import	,FALSE	,progress	,clay	,coast	,secure	,approval	,axis	,ally	,load	,amputate	,equinox	,horizon	,cinema	,devote	,acceptable	,viable	,surround	,initial	,referral	,sunrise	,reflect	,offender	,ideology	,memory	,pop	,squash	,misplace	,medieval	,foreigner	,crown	,despair	,function	,follow	,win	,beam	,descent	,sickness	,complete	,education	,measure	,mutter	,stuff	,inflate	,invite	,cultural	,promote	,hero	,suffer	,exit	,outlook	,predator	,island	,movement	,present	,nun	,position	,norm	,wake	,misery	,request	, qewrewrwe	,cycle	,sandwich	,module	,instinct	,dressing	,tender	,dividend	,notice	,pier	,few	,muggy	,observation	,stand	,borrow	,missile	,teacher	,jest	,bar	,replacement	,fever	,pot	,drain	,slot	,mutual	,decide	,navy	,slide	, asdf	,serious	,loose	,tooth	,undress	,way	,hell	,implicit	,production	,motorcycle	,to	,assembly	,effect	,air	,acute	,age	,compact	,action	,qualification	,accent	,well	,omission	,quest	,flush	,bush	,watch	,cook	,rage	,behead	,ignite	,enemy	,winner	,sell	,tournament	,hostility	,cable	,advance	,scheme	,mirror	,lane	,remedy	,star	,depend	,log	,avant-garde	,doctor	,skilled	,chase	,sock	,history	,deter	,secular	,mouse	,food	,determine	,possibility	,bread	,salad	,peak	,cute	,house	,snub	,loud	,cunning	,corner	,character	,engine	,wonder	,defeat	,tight	,charity	,vigorous	,scenario	,employ	,unlike	,fold	,forbid	,duck	,sweet	,abnormal	,vision	,bed	,sticky	,commission	,ward	,precision	,pursuit	,confession	,leader	,vegetation	,warn	,edge	,clue	,contrast	,meal	,confidence	,block	,company	,rear	,bait	,strategic	,beautiful	,basket	,withdraw	,pan	,tax	,month	,full	,shock	,realize	,good	,belong	,closed	,basic	,temple	,man	,end	,displace	,outside	,afford	,flourish	,pattern	,personal	,tasty	,satisfaction	,voyage	,build	,appearance	,trunk	,crash	,studio	,cold	,item	,population	,banish	,butterfly	,text	,tenant	,vertical	,technique	,neglect	,anger	,ditch	,applied	,duty	,licence	,glimpse	,lobby	,sister	,railcar	,satellite}; // 수요지

필요면적의 필요수량 => 중량(362개)

Weight = (279 , 422 , 150, ... , 1);

사이트 후보(102)

WellfareCenters = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101}; // 입지 후보지

거리 행렬(102*362 = 36924)

Distance = (
(~~~, ~~~, ... , ~~~), 
(~~~, ~~~, ... , ~~~), 
...
(~~~, ~~~, ... , ~~~), 
(~~~, ~~~, ... , ~~~)
);