Ejemplo n.º 1
0
def main(wScaleBound, setUpCost, crBound, ranSeed ):

	
	nComponents = 3					#input: number of components
	nStages = 6						#input: planning horizon: t = 1, 2, ..., T
	T = nStages;					#remaining time horizon
	R = T + 1;						#number of individuals
	nScenarios = 910;				#input: number of scenarios
	cS = setUpCost					#setup cost	
	intvl = 1;						#input: inspection interval
	
	sysInfo = class_info.system_info(nComponents, T, intvl, cS, nScenarios, ranSeed);
	
	kesi = [0]*nComponents;
	age = [0]*nComponents;
	cPR = [0]*nComponents;
	cCR = [0]*nComponents;
	w_shape = [0]*nComponents;
	w_scale = [0]*nComponents;

	for i in range(nComponents):
		#input: initial failure state kesi
		if i==0:
			kesi[i] = 1;
		#input: initial age
		age[i] = 2;
		#input: preventive replacement cost 
		cPR[i] = 1;
		#cCR
		random.seed(i*30);
		temp = random.uniform(crBound[0], crBound[1]);
		cCR[i] = round(temp,1);			
		#input: shape parameter
		random.seed(i*20)   
		temp = random.uniform(4,7)
		w_shape[i] = round(temp,1);			
		#scale
		random.seed(i*10)   
		temp = random.uniform(wScaleBound[0], wScaleBound[1])#(4,11)
		w_scale[i] = round(temp,1);		
		comInfo = class_info.component_info(i, w_shape[i], w_scale[i], age[i], kesi[i], \
											intvl, cCR[i], cPR[i], cS, nScenarios,R);
											# LT is initialized to be empty.
		sysInfo.add_com(comInfo);
		sysInfo.comInfoAll[i].create_LifeTime(sysInfo.ranSeed);
		#print (sysInfo.comInfoAll[i].LT);
        
	retCost = 0;
	## solve current stage problem
	PH_alg(sysInfo);

					
	return sysInfo.objValue
Ejemplo n.º 2
0
    temp = random.uniform(tmp[0], tmp[1])
    w_shape[i] = round(temp, 1)

    #input: Weibull scale parameters
    random.seed(i * 10)
    high = [5, 10]
    low = [1, 5]
    tmp = high
    temp = random.uniform(tmp[0], tmp[1])  #(1,5)
    w_scale[i] = round(temp, 1)

    #high = 100;
    #low = 5;
    #cS = low;				#fix setup cost

    #input: CR cost
    random.seed(i * 30)
    high = [17, 27]
    low = [6, 16]
    tmp = high
    temp = random.uniform(tmp[0], tmp[1])
    #(6,16) (17,27)
    cCR[i] = round(temp, 1)

    comInfo = class_info.component_info(i, w_shape[i], w_scale[i], age[i],
                                        kesi[i], intvl, cCR[i], cPR[i], cS)
    sysInfo.add_com(comInfo)

sysInfo1 = copy.deepcopy(sysInfo)
main_dynamic_solver.main(sysInfo1)
Ejemplo n.º 3
0
        #for PM
        ranSeed = (i + 1) * baseSeedPM + rep + nComponents
        #random seeds!!!!!!!!!!!!!remember to change it
        random.seed(ranSeed)
        tmp = np.random.normal(20, 25, 1)
        #cPM.append(tmp[0]);
        cPM.append(5)
        #for randomize initial age
        ranSeed = (i + 1) * baseSeedT + rep + nComponents
        #random seeds!!!!!!!!!!!!!remember to change it
        random.seed(ranSeed)
        tmp = random.uniform(1, 14)
        initAge.append(tmp)
    #initState = [5,4,7];
    for i in range(nComponents):
        comInfo = class_info.component_info(i, gam_a, gam_b, nStates,\
              S[i], initState[i], initAge[i], inspInterval, cCM[i], cPM[i], cS)
        sysInfo.add_com(comInfo)

    #get the multi-stage solution.
    #[t]:[0]:x[\omega]
    #[t]:[1]:y[\omega]
    #[t]:[3]:z

    #sysInfo1 = copy.deepcopy(sysInfo);
    #main_dynamic_solver.main(sysInfo1);

    nRep1 = 1
    cost1 = 0
    time1 = 0
    expCost1 = 0
    expTime1 = 0
Ejemplo n.º 4
0
def main(wShapeBound, wScaleBound, setUpCost, crBound, ranSeed ):

	nComponents = 8			#input: number of components
	nStages = 20			#input: planning horizon: t = 1, 2, ..., T
	T = nStages;			#remaining time horizon
	R = T + 20;				#number of individuals
	nScenarios = 250;		#input: number of scenarios
	cS = setUpCost			#input:setup cost	
	intvl = 1;				#input: inspection interval
	
	sysInfo = class_info.system_info(nComponents, T, intvl, cS, nScenarios, ranSeed);
	
	kesi = [0]*nComponents;	
	age = [0]*nComponents;
	cPR = [0]*nComponents;
	cCR = [0]*nComponents;
	w_shape = [0]*nComponents;
	w_scale = [0]*nComponents;

	for i in range(nComponents):
		#input: initial failure state kesi
		if i==0:
			kesi[i] = 0;
		#input: initial age
		age[i] = 0;
		#input: PR cost
		cPR[i] = 1;
		#input: CR cost
		random.seed(i*30);
		temp = random.uniform(crBound[0], crBound[1]);
		cCR[i] = round(temp,1);			
		#input: Weilbull shape parameter
		random.seed(i*20)   
		temp = random.uniform(wShapeBound[0],wShapeBound[1])
		w_shape[i] = round(temp,1);			
		#input: Weibull scale parameter
		random.seed(i*10)   
		temp = random.uniform(wScaleBound[0], wScaleBound[1])#(4,11)
		w_scale[i] = round(temp,1);		
		comInfo = class_info.component_info(i, w_shape[i], w_scale[i], age[i], kesi[i], \
											intvl, cCR[i], cPR[i], cS, nScenarios,R);
											# LT is initialized to be empty.
		sysInfo.add_com(comInfo);
		sysInfo.comInfoAll[i].create_LifeTime(sysInfo.ranSeed);
		#print (sysInfo.comInfoAll[i].LT);
	retCost = 0;

	for t in range(nStages):
		print ("t=",t);
		#sTime = time.clock();
		if t == nStages - 1:
			tmp = 0;
			for i in range(sysInfo.nComponents):
				if sysInfo.comInfoAll[i].initFail == 1:
					tmp += sysInfo.comInfoAll[i].cCR
					print ("fail",i);
				
			if tmp > 0:
				tmp += sysInfo.cS;	
			retCost += tmp;
		else:
			## solve current stage problem
			#flag = False;
			#if t == 6:
				#flag = True;
				#print("LT[0]", sysInfo.comInfoAll[0].LT);
				#print("LT[1]", sysInfo.comInfoAll[1].LT);
			x = PH_alg(sysInfo);	
			#print ("x=",x);
			res = copy.deepcopy(x);
			for i in range(sysInfo.nComponents):
				if sysInfo.comInfoAll[i].initFail == 1:
					res[i] = 2;
			print ("res=",res);
			x = [round(x[i]) for i in range(len(x))];	
			
			#calculate cost at current stage
			tmp = 0;
			for i in range(sysInfo.nComponents):
				tmp += sysInfo.comInfoAll[i].cPR*x[i];
				tmp += (sysInfo.comInfoAll[i].cCR - sysInfo.comInfoAll[i].cPR)*\
					sysInfo.comInfoAll[i].initFail;
				#if (x[i] == 1):
					#print (sysInfo.comInfoAll[i].initFail);
			if tmp > 0:
				tmp += sysInfo.cS;
			retCost += tmp;
			
			## prepare next stage:
			#generate the failure
			ageAfterMx = [sysInfo.comInfoAll[i].initAge*(1-x[i]) \
							for i in range(sysInfo.nComponents)];
			failProb = [sysInfo.comInfoAll[i].cond_fail_prob(ageAfterMx[i],ageAfterMx[i]+1) \
						for i in range(sysInfo.nComponents)];
			
			randProb = [];
			for i in range(sysInfo.nComponents):
				random.seed(ranSeed + t*100 + i);
				randProb.append(random.uniform(0,1));
			
			failState =  [int(randProb[i]<failProb[i]) for i in range(sysInfo.nComponents)];
			ageAfterMx = [ageAfterMx[i]+1 for i in range(sysInfo.nComponents)];
			
			#sysInfo.nStages += -1;
			sysInfo.nStages = max(sysInfo.nStages, 10)
			#R = sysInfo.nStages + 1;

			for i in range(sysInfo.nComponents):
				sysInfo.comInfoAll[i].initAge = ageAfterMx[i];
				sysInfo.comInfoAll[i].initFail = failState[i];
				#sysInfo.comInfoAll[i].nIndividuals = R;
				sysInfo.comInfoAll[i].create_LifeTime(sysInfo.ranSeed + t*100);
		#print("failProb", failProb);
		#print("randProb", randProb);
		#print("failState,", failState);
		#print("LT[0]", sysInfo.comInfoAll[0].LT);
		#print("LT[1]", sysInfo.comInfoAll[1].LT);
		#eTime = time.clock();
		#print ("time=", eTime-sTime);
							
	return retCost