예제 #1
0
Created on Mon Jun 10 21:39:13 2019

@author: mauri
"""

# -*- coding: utf-8 -*-
"""
Created on Wed Jun  5 15:24:40 2019

@author: mauri
"""
import numpy as np
from modelos.CFLPProblem import CFLPProblem
from algoritmos.TabuSearch import TabuSearch

prob1 = CFLPProblem()
prob1.loadTransportCost("datos/cflp/TC.csv")
prob1.loadFacilityCost("datos/cflp/FC.csv")
prob1.loadDemand("datos/cflp/dem.csv")
prob1.loadCapacity("datos/cflp/cap.csv")
algorithmT = TabuSearch(prob1, maximize=False, numIter=100)
print("comienzo optimizacion")
algorithmT.optimize(winSize=0.2, epochs=2, maxRetry=10)
print("fin optimizacion")
totalCostT = algorithmT.getBestCost()
solutionT = algorithmT.bestState
execTimeT = algorithmT.execTime
iterationsT = algorithmT.iterations

print("fin de ejecución")
print("costo total cflp tabu: {}".format(totalCostT))
예제 #2
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 10 19:49:30 2019

@author: mauri
"""

from modelos.CFLPProblem import CFLPProblem
from algoritmos.HillClimbing import HillClimbing
import numpy as np

cflp = CFLPProblem()
cflp.loadTransportCost("datos/cflp/TC500.csv")
cflp.loadFacilityCost("datos/cflp/FC500.csv")
cflp.loadDemand("datos/cflp/dem500.csv")
cflp.loadCapacity("datos/cflp/cap500.csv")

algorithmH = HillClimbing(cflp, maximize=False, numIter=50)
print("comienzo optimizacion")
algorithmH.optimize(winSize=0.05)
print("fin optimizacion")

totalCost = algorithmH.getBestCost()
solution = algorithmH.bestState
#print(knapSack.getFactibility(solution))
execTime = algorithmH.execTime
iterations = algorithmH.iterations

#print("costo total knpsack hill climbing: {}".format(totalCost))