亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? solution.cpp

?? vrpsd -tabu搜索求解!!!?。。。。。。。。。。。。。。。。。。?!
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
  costToGoMatrix[0][Q]= expectedCost; //costToGoMatrix

  return costToGo_j[Q]; 
}



//Given the cost-to-go vector from succ_j th customer, compute cost-to-go from j,
//in the hypothesis of going first to the depot for restocking
//and then to succ_jth customer.  
double 
Solution::computeCostIfPreventiveRestock(int j,int succ_j,const vector<double>& cost_succ_j){
  double temp = 0.0;
  vector<PossibleDemand>::iterator d;
  for(d= problem->customerDemand[(*this)[succ_j]].begin();
      d< problem->customerDemand[(*this)[succ_j]].end();
      d++ ){
    temp += cost_succ_j[problem->capacity - d->demand_ ] * d->probability_ ;
  }

  temp +=  problem->distanceMatrix[(*this)[j]][0] +
    problem->distanceMatrix[0][(*this)[succ_j]];
  //  return  temp + problem->distanceMatrix[(*this)[j]][0] +
  //  problem->distanceMatrix[0][(*this)[succ_j]];
  //  cout <<"computeCostIfPreventiveRestock()= " << temp << endl;//////////////////

  return temp;
}



//Given the cost-to-go vector from succ_j th, compute cost-to-go from jth,
//in the hypothesis of proceeding directly from the jth customer
//to the succ_jth customer.  
double 
Solution::computeCostIfProceed(int q, int j,int succ_j,const vector<double>& cost_succ_j){

  double temp = 0.0;
  vector<PossibleDemand>::iterator d;
  for(d= problem->customerDemand[(*this)[succ_j]].begin();
      d< problem->customerDemand[(*this)[succ_j]].end();
      d++ ){
    if(d->demand_ <= q)
      temp += cost_succ_j[q - d->demand_ ] * d->probability_ ;
    else 
      temp += (problem->distanceMatrix[(*this)[succ_j]][0] + 
	       problem->distanceMatrix[0][(*this)[succ_j]] + 
	       cost_succ_j[q + problem->capacity - d->demand_ ] ) * d->probability_;
  }

  temp += problem->distanceMatrix[(*this)[j]][(*this)[succ_j]];
  // cout <<"computeCostIfProceed(): q "<< q << " temp " << temp << endl ;/////////////
  return  temp;
}



//Compute the approximated variation in expected cost 
//due to the application of the current Oropt move to this solution
double 
Solution::computeProxyDelta(){
  int i = move[0];
  int k = move[1];
  int j = move[2];
  
  double PDS = computeProxyDeletionSaving(costToGoMatrix[i], costToGoMatrix[i+k+1] );
  double PIC =computeProxyInsertionCost(costToGoMatrix[j], 
					costToGoMatrix[(j+1)%(problem->numberOfCustomers)] );
  //cout <<"computeProxyDelta(): PIC= " << PIC << " PDS= " << PDS << endl  ;////////////
  //cout <<"computeProxyDelta()= " << PIC-PDS << endl;///////////
  return PIC - PDS;
}



//Compute the approximated saving  for deleting a string
//of consecutive customers, as given by the current Oropt
//move of this solution.
//Input parameter is the cost-to-go vector from the first node after 
//the string in the current move.
double
Solution::computeProxyDeletionSaving(const vector<double>& cost_prev ,
				     const vector<double>& cost_next ){
  int  Q = problem->capacity;
  double average=0.0;
  int i = move[0];
  int k = move[1];
  double cost_proceed;
  double cost_pruned;
  double cost_restock =  computeCostIfPreventiveRestock( i, i+k+1, cost_next );

  cost_pruned = cost_restock;
  if( i==0 ) average = cost_prev[Q]-cost_pruned; 
  
  else{
    for(int q=Q; q>=0; q--){
      cost_pruned = cost_restock;
      cost_proceed = computeCostIfProceed( q, i, i+k+1, cost_next ) ;
      if( !(cost_proceed > cost_restock) ) cost_pruned = cost_proceed;
      
      average += cost_prev[q] - cost_pruned; //update average
    }

    average = average/(double)(Q+1);
  }
  return average;
}



//Compute the approximated cost for inserting a string
//of consecutive customers, as given by the current Oropt
//move of this solution.
//Input parameter is the cost-to-go vector from the customer 
//after which the string would be inserted, according to this solution 
//Oropt move.
double 
Solution::computeProxyInsertionCost(const vector<double>& cost_prev,
				    const vector<double>& cost_next){
  double average=0.0;
  int n = problem->numberOfCustomers;
  int  Q = problem->capacity;
  int j = move[2];
  int i = move[0];
  int k = move[1]; //String length.

  //Initialization of cost-to-go vector as initial data of the Dynamic programming
  //iteration.
  vector<double> costToGo_jplus1(Q+1);
  for(int q=0; q<=Q; q++){
      if( j < n -1 ) costToGo_jplus1[q] = cost_next[q];
      else
	costToGo_jplus1[q]=problem->distanceMatrix[ (*this)[i+k] ][0];
    }
  //cout <<"init costToGo_jplus1[0]"<<  costToGo_jplus1[0] << endl;//////////////

  //Number of Dynamic programming iterations.
  int iter;
  if(j < n-1) iter = k;
  else iter = k-1;

  //Dynamic programming recursion.
  double costRestock;
  double costNoRestock;
  vector<double> costToGo_j(Q+1);

  for(int l=iter; l>=1; l--){
    int next = -1;
    if(l == k) next = (j+1)%n;    //Next is first customer after the inserted string.
    else next = i+l+1;            //Next is inside the string.
    costRestock = computeCostIfPreventiveRestock(i+l,next,costToGo_jplus1);
    //cout << i+l <<" h' " << costRestock << endl;//////////////
    
    for(int q=Q; q>=0; q--){
      //compute costToGo in case of proceeding to the next customer
      costNoRestock = computeCostIfProceed(q,i+l,next,costToGo_jplus1);

      //cout << j <<" h(" << q << ")= "<< costNoRestock ;//////////////
      
      //choose smaller cost btw preventiveRestock and Proceed, and set threshold
      if(costRestock < costNoRestock)
	costToGo_j[q]= costRestock;
      else 
	costToGo_j[q] = costNoRestock;
      // cout << i+l <<" f(" << q << ")= "<<  costToGo_j[q] << endl;//////////////
    }
    
    //store chosen cost vector in costToGo_jplus1   
    for(int q=Q; q>=0; q--)
      costToGo_jplus1[q] = costToGo_j[q];
  }  
  
  //customer = j: costToGo from the customer after which the string is inserted
  costRestock = computeCostIfPreventiveRestock(j,i+1,costToGo_jplus1);
  for(int q=Q; q>=0; q--){
    costNoRestock = computeCostIfProceed(q,j,i+1,costToGo_jplus1);
    if(costRestock < costNoRestock)
      costToGo_j[q]= costRestock;
    else 
      costToGo_j[q] = costNoRestock;
    //cout << j <<" f(" << q << ")= " << costToGo_j[q] << endl;/////////////
    //    cout  <<" cost_prev(" << q << ")= " << cost_prev[q] << endl;/////////////
    average+= costToGo_j[q]-cost_prev[q];
  }

  average = average/(Q+1);

  return average;
}



double 
Solution::computeExactDelta(){
  int n = problem->numberOfCustomers;
  int  Q = problem->capacity;
  int j = move[2];
  int i = move[0];
  int k = move[1]; //String length.

  // cout << "compExactDelta(): " << i << k << j << endl;////////////

  //Initialization of cost-to-go vector, either from j+1 or from the
  //last customer of the string.
  vector<double> costToGo_jplus1(Q+1);
  for(int q=0; q<=Q; q++){
    if( j < n -1 ){
      costToGo_jplus1[q] = costToGoMatrix[j+1][q];
      //    cout << j+1 << " " << (j+2)%n << endl;//////////////
    }
    else{
      costToGo_jplus1[q]=problem->distanceMatrix[ (*this)[i+k] ][0];
      //cout << i+k << " " << 0 << endl;//////////////
    }
  }
  

  //Number of Dynamic programming iterations.
  int iter;
  if(j < n-1) iter = k;
  else iter = k-1;

  //Recursion backwards in the string.
  double costRestock;
  double costNoRestock;
  vector<double> costToGo_j(Q+1);

  for(int l=iter; l>=1; l--){
    int next = -1;
    if(l == k) next = (j+1)%n;    //Next is first customer after the inserted string.
    else next = i+l+1;            //Next is inside the string.
    costRestock = computeCostIfPreventiveRestock(i+l,next,costToGo_jplus1);
    //  cout << i+l << " " << next << endl;//////////////
    
    for(int q=Q; q>=0; q--){
      //compute costToGo in case of proceeding to the next customer
      costNoRestock = computeCostIfProceed(q,i+l,next,costToGo_jplus1);

      //cout << j <<" h(" << q << ")= "<< costNoRestock ;//////////////
      
      //choose smaller cost btw preventiveRestock and Proceed, and set threshold
      if(costRestock < costNoRestock)
	costToGo_j[q]= costRestock;
      else 
	costToGo_j[q] = costNoRestock;
      // cout << i+l <<" f(" << q << ")= "<<  costToGo_j[q] << endl;//////////////
    }
    
    //store chosen cost vector in costToGo_jplus1   
    for(int q=Q; q>=0; q--)
      costToGo_jplus1[q] = costToGo_j[q];
  }  
  
  //Recursion from the beginning of the string back to j.
  costRestock = computeCostIfPreventiveRestock(j,i+1,costToGo_jplus1);
  for(int q=Q; q>=0; q--){
    costNoRestock = computeCostIfProceed(q,j,i+1,costToGo_jplus1);
    if(costRestock < costNoRestock)
      costToGo_j[q]= costRestock;
    else 
      costToGo_j[q] = costNoRestock;
  }
  //store chosen cost vector in costToGo_jplus1   
  for(int q=Q; q>=0; q--)
    costToGo_jplus1[q] = costToGo_j[q];

  //cout << j << " " << i+1 << endl;//////////////

  //Recursion from j back to  i+k+1.
  for(int l=j; l>i+k+1; l--){
    costRestock = computeCostIfPreventiveRestock(l-1,l,costToGo_jplus1);
    //cout << l-1 << " " << l << endl;//////////////
    
    for(int q=Q; q>=0; q--){
      //compute costToGo in case of proceeding to the next customer
      costNoRestock = computeCostIfProceed(q,l-1,l,costToGo_jplus1);

      //cout << j <<" h(" << q << ")= "<< costNoRestock ;//////////////
      
      //choose smaller cost btw preventiveRestock and Proceed, and set threshold
      if(costRestock < costNoRestock)
	costToGo_j[q]= costRestock;
      else 
	costToGo_j[q] = costNoRestock;
      // cout << i+l <<" f(" << q << ")= "<<  costToGo_j[q] << endl;//////////////
    }
    
    //store chosen cost vector in costToGo_jplus1   
    for(int q=Q; q>=0; q--)
      costToGo_jplus1[q] = costToGo_j[q];
  }  

  //Last itaration from i+k+1 back to i.
  if(i==0) {//Last iteration.
    costToGo_j[Q] = computeCostIfProceed(Q,i,i+k+1,costToGo_jplus1);
    //cout << i << " " << i+k+1 << endl;//////////////
    return costToGo_j[Q]-expectedCost;
  }

  else{//i>0.
    //Single itaration from i+k+1 back to i.
    costRestock = computeCostIfPreventiveRestock(i,i+k+1,costToGo_jplus1);
    // cout << i << " " << j << endl;//////////////
    for(int q=Q; q>=0; q--){
      costNoRestock = computeCostIfProceed(q,i,i+k+1,costToGo_jplus1);
      if(costRestock < costNoRestock)
      costToGo_j[q]= costRestock;
      else 
	costToGo_j[q] = costNoRestock;
    }
    //store chosen cost vector in costToGo_jplus1   
    for(int q=Q; q>=0; q--)
      costToGo_jplus1[q] = costToGo_j[q];

    //Iterations from i back to the depot.
    for(int cr=i-1; cr>=1; cr-- ){
      costRestock = computeCostIfPreventiveRestock(cr,cr+1,costToGo_jplus1);
      //cout << j <<" h' " << costRestock << endl;//////////////
      //cout << cr << " " << cr+1 << endl;//////////////	
      
      for(int q=Q; q>=0; q--){
	//compute costToGo in case of proceeding to the next customer
	costNoRestock = computeCostIfProceed(q,cr,cr+1,costToGo_jplus1);
	//cout << j <<" h(" << q << ")= "<< costNoRestock ;//////////////
	
	//choose smaller cost btw preventiveRestock and Proceed, and set threshold
	if(costRestock < costNoRestock)
	  costToGo_j[q]= costRestock;
	else 
	  costToGo_j[q] = costNoRestock;
	//cout << " f(" << q << ")= "<<  costToGo_j[q] << endl;//////////////
      }
      
      //store chosen cost vector in costToGo_jplus1   
      for(int q=Q; q>=0; q--)
	costToGo_jplus1[q] = costToGo_j[q];
    }  
  
    //cr==0: costToGo from the depot on (last iteration)
    costToGo_j[Q] = computeCostIfProceed(Q,0,1,costToGo_jplus1);
    //cout << 0 << " " << 1 << endl;//////////////
    //cout << " costToGo_j[Q]= " << costToGo_j[Q] << endl;/////////////
    
    return costToGo_j[Q]-expectedCost;
    
  }

}



//Print on output stream the solution 
void
Solution::printOn( ostream &os ) {
	os << "#sequence of "<< size()<< " customers:" << endl;
	for( iterator i = begin(); i != end(); i++ )
	  //os << (*this)[*i] << " ";
	  os << *i << " ";
	os << endl;
	
}



//Print on output stream the solution and the thresholds
void
Solution::printOn( ostream &os,const vector<int>& thresholds ) {
	os << "#sequence of "<< thresholds.size()<< " couples (customer,threshold):"
	   << endl;
	for( iterator i = begin(); i != end(); i++ )
		os << *i << "," << thresholds[*i] << "   ";
	os << endl;
	
}


//Print on output stream the costToGo matrix given in input
void
Solution::printOn( ostream &os,const vector<vector<double> >& costToGoMatrix ) {
  if (!computedExpectedCost) cout <<"PrintOn():Warning! printing not up-to-date data! " << endl;
	os << "#costToGo matrix" << endl;

	for( int i =0 ; i <= problem->numberOfCustomers-1; i++ ){
	  cout << i <<"th customer: " ;
	  for(int q = 0; q <= problem->capacity ; q++)
	    cout << costToGoMatrix[i][q] << " ";
	  cout << endl;
	}
}



//Copy a Solution into this one.
void
Solution::copySolution(const Solution& orig ) {
  //(*this) = orig;
  for(int i=0; i< problem->numberOfCustomers; i++) (*this)[i] = orig[i];
  for(int s=0; s<3; s++) move[s] = orig.move[s];
  expectedCost = orig.expectedCost;
  computedExpectedCost = orig.computedExpectedCost;
  rg = orig.rg;
  control_ = orig.control_;
}



//Get the pointer to the problem.
Problem*
Solution::getProblem( ) {
  return problem;
}



//Get the current move of the solution
vector<int>
Solution::getMove( ) {
  return move;
}



void
Solution::allocateCostToGoMatrix(){
  int n = problem->numberOfCustomers;
  int Q = problem->capacity;

  costToGoMatrix = vector< vector<double> > ( n );
  for( int i=0; i< n ; i++ )
    costToGoMatrix[i] = vector<double>( Q+1, -1.0 );
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲视频在线一区| 天天操天天色综合| 欧美性色黄大片手机版| 老司机精品视频在线| 亚洲视频你懂的| 欧美tickling挠脚心丨vk| 成人av网址在线| 久久成人久久爱| 亚洲一区中文在线| 国产欧美一区二区精品性色超碰| 欧美日韩亚洲综合| 97se亚洲国产综合在线| 国模冰冰炮一区二区| 视频一区视频二区在线观看| 国产精品久久久久一区| 精品国产乱码91久久久久久网站| 欧美午夜精品久久久| av电影一区二区| 国产福利91精品一区| 久久97超碰国产精品超碰| 成人国产一区二区三区精品| 国产在线播放一区三区四| 日本大胆欧美人术艺术动态| 亚洲综合小说图片| √…a在线天堂一区| 国产日韩视频一区二区三区| 精品三级在线看| 欧美一区二区高清| 欧美久久久久久久久中文字幕| 一本在线高清不卡dvd| 国产成人99久久亚洲综合精品| 久久国产日韩欧美精品| 日日欢夜夜爽一区| 亚洲成人动漫在线观看| 亚洲高清视频在线| 一区二区三区免费网站| 综合电影一区二区三区| 综合婷婷亚洲小说| 亚洲色图欧美在线| 亚洲色欲色欲www| 亚洲欧美乱综合| 亚洲女与黑人做爰| 亚洲精品视频一区| 一区二区成人在线| 亚洲大片一区二区三区| 日韩av在线免费观看不卡| 日韩制服丝袜av| 看电影不卡的网站| 国产精品一区二区男女羞羞无遮挡 | 成人午夜视频在线观看| 国产成人精品免费一区二区| 国产精品99久久久久久似苏梦涵| 极品少妇xxxx精品少妇偷拍| 国产成人免费在线视频| 不卡一卡二卡三乱码免费网站| 成人免费视频一区二区| 成人高清视频在线观看| 91色在线porny| 欧美在线免费播放| 91精品国产高清一区二区三区 | 免费成人你懂的| 麻豆国产91在线播放| 国产在线精品不卡| 丁香亚洲综合激情啪啪综合| 99久久精品免费| 欧美日韩中文字幕一区二区| 777精品伊人久久久久大香线蕉| 日韩视频不卡中文| 久久天天做天天爱综合色| 国产精品理论在线观看| 一个色在线综合| 蜜桃在线一区二区三区| 国产激情一区二区三区桃花岛亚洲| 成人免费av资源| 在线精品视频一区二区| 日韩欧美国产麻豆| 国产精品久久久久久久浪潮网站| 一区二区激情小说| 久草热8精品视频在线观看| 成人国产亚洲欧美成人综合网| 欧美色图12p| 久久久国产一区二区三区四区小说| 亚洲色图第一区| 麻豆一区二区三区| 99久久er热在这里只有精品15| 欧美性欧美巨大黑白大战| 久久综合999| 一区二区三区不卡视频在线观看| 麻豆精品一区二区| 99re这里只有精品首页| 日韩欧美卡一卡二| 亚洲激情成人在线| 国产精品一区在线| 欧美久久久一区| 最新国产精品久久精品| 美国三级日本三级久久99| av福利精品导航| 日韩精品一区二区三区四区视频| 亚洲三级在线播放| 国产在线不卡一卡二卡三卡四卡| 欧美亚洲动漫精品| 国产精品久久久久aaaa樱花| 五月天欧美精品| 91视视频在线观看入口直接观看www| 欧美一二三在线| 亚洲国产精品久久久久秋霞影院| 国产精品996| 日韩欧美专区在线| 亚洲夂夂婷婷色拍ww47| 成人激情免费网站| 亚洲精品在线一区二区| 日韩av在线发布| 91福利视频在线| 国产精品日韩成人| 精品制服美女丁香| 在线不卡一区二区| 亚洲国产毛片aaaaa无费看| 成人免费视频app| 久久免费精品国产久精品久久久久 | 国产午夜一区二区三区| 奇米色一区二区| 欧美美女一区二区三区| 一区二区三区.www| 91香蕉视频在线| 中文字幕一区二区视频| 国产精品一区二区三区网站| 日韩精品综合一本久道在线视频| 天天综合日日夜夜精品| 欧美日韩一级二级| 亚洲精品视频一区| 在线精品亚洲一区二区不卡| 亚洲美女免费在线| 91小视频在线| 一区二区高清在线| 欧美性生活大片视频| 亚洲va中文字幕| 欧美群妇大交群中文字幕| 亚洲狠狠爱一区二区三区| 欧美中文一区二区三区| 亚洲午夜电影网| 欧美日韩国产精选| 日韩精品一区第一页| 777色狠狠一区二区三区| 日韩 欧美一区二区三区| 91精品国产免费久久综合| 免费高清不卡av| 精品国产一区二区三区忘忧草| 久热成人在线视频| 久久夜色精品国产噜噜av | 国产成人综合自拍| 中文字幕不卡在线播放| av爱爱亚洲一区| 一区二区三区欧美激情| 欧美精品色综合| 精品一区免费av| 国产日产欧美一区| 99国产精品视频免费观看| 依依成人综合视频| 欧美男女性生活在线直播观看| 奇米影视7777精品一区二区| 欧美不卡一区二区三区| 国产91清纯白嫩初高中在线观看| 国产精品欧美精品| 在线视频一区二区免费| 日韩电影在线观看电影| wwwwww.欧美系列| av在线综合网| 日韩中文字幕亚洲一区二区va在线| 欧美一区二区女人| 大尺度一区二区| 亚洲大片在线观看| 精品免费99久久| 91丨九色丨蝌蚪丨老版| 五月激情综合婷婷| 久久久777精品电影网影网 | 亚洲欧洲国产专区| 欧美美女bb生活片| 国产乱码精品一区二区三区忘忧草| 国产精品丝袜一区| 欧美日韩一二三区| 丁香网亚洲国际| 五月天久久比比资源色| 亚洲国产高清在线观看视频| 欧美日韩一区二区欧美激情| 国产精品小仙女| 午夜欧美大尺度福利影院在线看| 精品国产人成亚洲区| 色婷婷香蕉在线一区二区| 美脚の诱脚舐め脚责91| 亚洲欧美日韩久久| 精品国产91亚洲一区二区三区婷婷| 91在线一区二区| 寂寞少妇一区二区三区| 亚洲精品自拍动漫在线| 精品久久久久99| 欧美性三三影院| 成人开心网精品视频| 奇米精品一区二区三区在线观看| 亚洲欧洲av在线| www激情久久|