Tutorial 6 | Vehicle Routing Problem | Cplex & Python [ VRP]

  Рет қаралды 24,703

sergio correa

sergio correa

Күн бұрын

VRP Cplex & Python. This is a tutorial about how to solve a VRP problem using python and Cplex.
contact:
sergio.correa@ucn.cl
scorrea@mit.edu

Пікірлер: 66
@sebastianandresrodriguezro3379
@sebastianandresrodriguezro3379 4 жыл бұрын
Después de algunas semanas de estudio y gracias a tu ayuda Profesor Sergio pude terminar de realizar los tutoriales de tu canal, gracias por tus respuestas ante las dudas, un material muy sólido e interesante para seguir profundizando, Saludos cordiales.
@danielsan6676
@danielsan6676 3 жыл бұрын
Súper bien explicado, gracias Sergio, me ayudó mucho para mi trabajo final, saludos desde Colombia
@brianhoward6850
@brianhoward6850 4 жыл бұрын
Don Sergio, muchas gracias por la serie de videos. Le acabo de enviar un correo. Saludos.
@MegaLobo000
@MegaLobo000 4 жыл бұрын
Excelente material, muchas gracias. Saludos
@agustinguerra6692
@agustinguerra6692 4 жыл бұрын
Excelente contribucion muchas gracias
@AlexGonzalez-lp3hd
@AlexGonzalez-lp3hd 5 жыл бұрын
Buen material , bien explicado, me sirvió , muchas gracias
@priscilladesouzasilva4903
@priscilladesouzasilva4903 5 жыл бұрын
This video is help a lot.
@julioeduardomonterollanca6090
@julioeduardomonterollanca6090 5 жыл бұрын
Buenismo el video , gracias por tu ayuda comapañero .
@AvatarJJJ
@AvatarJJJ 5 жыл бұрын
Hola Sergio, primero quiero agradecerle por el video. Tengo un problema en la siguiente linea de código: mdl.add_indicator_constraints(mdl.indicator_constraint(x[i, j], u[i] + q[j] == u[j]) for i, j in arcs if i != 0 and j != 0) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in 7 #indConstraint = mdl.indicator_constraint(x[i, j], u[i] + q[j] == u[j]) for i, j in arcs if i != 0 and j != 0 8 ----> 9 mdl.add_indicator_constraints(mdl.indicator_constraint(x[i, j], u[i] + q[j] == u[j]) for i, j in arcs if i != 0 and j != 0) 10 11 mdl.add_constraints(u[i] >= q[i] for i in customers) /usr/local/lib/python3.6/dist-packages/docplex/mp/model.py in add_indicator_constraints(self, indcts) 2913 :func:`indicator_constraint` 2914 """ -> 2915 ind_indices = self.__engine.create_batch_indicator_constraints(indcts) 2916 self._register_block_cts(self._indicator_scope, indcts, ind_indices) 2917 add_indicator_constraints_ = add_indicator_constraints /usr/local/lib/python3.6/dist-packages/docplex/mp/engine.py in create_batch_indicator_constraints(self, indicators) 431 432 def create_batch_indicator_constraints(self, indicators): --> 433 return self.create_batch_cts(indicators) 434 435 def create_quadratic_constraint(self, ind): /usr/local/lib/python3.6/dist-packages/docplex/mp/engine.py in create_batch_cts(self, ct_seq) 415 def create_batch_cts(self, ct_seq): 416 old_ct_count = self._ct_counter --> 417 self._increment_cts(len(ct_seq)) 418 return range(old_ct_count, self._ct_counter) 419 TypeError: object of type 'generator' has no len() He intentado encontrar la solución sin dar con ella. Me sería muy útil saber que pasa aquí y dar con la solución.
@mariapaulazambranou4225
@mariapaulazambranou4225 4 жыл бұрын
Muy bueno el vídeo, me gustaría saber si en lugar de coordenadas en x y y se puede hacer ya teniendo una matriz de distancias. Muchas gracias.
@martinpratto1475
@martinpratto1475 3 жыл бұрын
Excelente Sergio! Acabo de terminar el video y logre entender el problema! Ahora, una pregunta, como podría aplicar esta optimización a un conjunto de vuelos por ejemplo. Tengo x nodos a recorrer con una determinada demanda a satisfacer en cada nodo, con una capacidad limitada y quiero optimizar las rutas. Gracias cualquier ayuda que me puedas brindar. Felicitaciones por la explicación y por ayudar a quienes como yo no tenemos fácil acceso a investigación operativa practica. Gracias
@sergiocorrea1179
@sergiocorrea1179 2 жыл бұрын
Martin, el problema es exactamente igual que el video. Solo debes remplazar ( o leer tus datos) en la misma estructura de datos y listo. Ahora puede modificar alguna restricción para que la flota que utilices sea fija o en este caso, selección la mínima cantidad posible de rutas ( vehículos).
@davidsanchez4015
@davidsanchez4015 4 жыл бұрын
Hola, primero que nada gracias por compartir tan valioso video. Me gustaría saber si hay alguna forma de en lugar de tomar distancias, puedo meter una matriz de tiempos y limitar las rutas a una cantidad de tiempo recorrido máximo. Una vez mas te agradezco, saludos.
@juanleonjacome3180
@juanleonjacome3180 5 жыл бұрын
Quiero aplicar este ruteo a Un problema de Ruteo de Camiones recolectores de residuos, por arcos CAPACITADOS!, Puedo realizar este problema con ARCGIS???
@genuiskids3362
@genuiskids3362 4 жыл бұрын
Great Job! Thanks a lot. I work on a similar related problem. I want to strengthen my code. I have a list of infeasible Arcs that should not be considered by the program "Arc Elimination" , any idea on how to do it. Any hint will be useful
@Chopin64000
@Chopin64000 3 жыл бұрын
Hola que tal¡ Felicidades por tu video. Tengo una duda ojalá me contestes hoy, ya que es urgente: al yo replicar tu código en Jupyter notebook me genera el siguiente error "no cplex version found, using default parameter version: 20.1.0.0".¿Cómo lo puedo solucionar? Gracias
@sergiocorrea1179
@sergiocorrea1179 3 жыл бұрын
Fabricio acabo de ver tu mensaje. Puedes probar está alternativa, es generar el python path utilizando el siguiente código: sys.path.append('/Applications/CPLEX_studio128/cplex/python/3.6/x86-64_osx') Debes modificar el path a donde tú tienes instalado Cpex. Este código está desarrollo para mac, así que revisa el archivo que estas buscando para conectar python con cplex. Por último lo debes correr cada vez que quieres utilizar cplex ( lo puedes correr una vez y luego utilizar cplex varias veces obvimente, pero si abres un nuevo proyecto, debes volver a agregarlo y correrlo). Cuentame como te va con la conexión.
@harishankar6496
@harishankar6496 5 жыл бұрын
Can you please tell how to add the subtour elimination constraints in docplex
@sergiocorrea1179
@sergiocorrea1179 5 жыл бұрын
Dear Hari, if you want to add subtour elimination constraints dependent of the problem that you are working on. In this case, a CVRP, instead to use the Sum(xij) >= r(s), I used the MTZ-formulation. This one include a new variable u = accumulative capacity and creating indicator constraints. All of this is explained on this tutorial. Sorry for making in Spanish, but the decision it was made because there are more material available in English rather in Spanish .If you have doubt you may check this channel: kzbin.info/www/bejne/Y5mqfWZvn8mnh6c Hernán is a college of mine at UCN, PhD on Operation Research and expert on VRP. Good luck and thank you for watching !!!!
@javierwilches7
@javierwilches7 3 жыл бұрын
profe tengo un problema TypeError ModuleNotFoundError Traceback (most recent call last) in ----> 1 from docplex.mp.model import Model 2 mdl=Model('CVRP') ModuleNotFoundError: No module named 'docplex' le he dado 50 vueltas y no se que puedo tener mal?
@sergiocorrea1179
@sergiocorrea1179 3 жыл бұрын
Primero me disculpo por la demora. Eso indica que no esta instalado el docplex. Puede que ser que no este instalado o que no este en la carpeta que corresponde.
@anapaulapedrazzoli1450
@anapaulapedrazzoli1450 3 жыл бұрын
HOLA! no hay un ejemplo de vrppd '?
@sergiocorrea1179
@sergiocorrea1179 2 жыл бұрын
No por el momento, pero si tienes algún ejemplo, me lo puedes compartir para preparar un video con eso. Saludos !
@wildonrp
@wildonrp 5 жыл бұрын
Muy interesante, para leer detenidamente, tienes alguna Web para hacer lectura. Gracias
@sergiocorrea1179
@sergiocorrea1179 5 жыл бұрын
Estimado @Wion R. lamentablemente no tengo web. Espero que te hayan ayudado en algo. Muchas Gracias por ver y si tienes alguna consulta, me puedes escribir.
@manuelpatricioacuna59
@manuelpatricioacuna59 3 жыл бұрын
Hace clases en la ucn Coquimbo?? :O
@sergiocorrea1179
@sergiocorrea1179 3 жыл бұрын
En la de coquimbo y antofagasta, por qué??
@nicolasvegasoto7340
@nicolasvegasoto7340 2 жыл бұрын
Hola, como puedo asignar valores a la demanda de manera que no sea aleatoria?
@sergiocorrea1179
@sergiocorrea1179 2 жыл бұрын
Debes tener los valores reales y puedes utilizar la misma estructura de datos del video pero leyendo tus valores.
@AleProgramadorRunner
@AleProgramadorRunner 5 жыл бұрын
Hola vi el video es perfecto para el calculo de rutas, pero no me dice cuantos vehículos óptimos por ruta.
@sergiocorrea1179
@sergiocorrea1179 5 жыл бұрын
Alejandro es un vehículo por ruta y la cantidad de vehículos ( o rutas) depende de la capacidad de los vehículos.
@quangphamngoc7701
@quangphamngoc7701 5 жыл бұрын
i don't know much about the results of your numpy.hypot, I think it is incorrect
@sergiocorrea1179
@sergiocorrea1179 5 жыл бұрын
Dear Quang, why numpy.hypot may be incorrect?. Thank you for watching !
@quangphamngoc7701
@quangphamngoc7701 5 жыл бұрын
@@sergiocorrea1179 Dear correa, your loc_x[0] = 191.57790603, loc_x[1] = 106.63305699 , loc_y[0]= 92.7508580, loc_y[1]=34.7765859. your first distance (0,1) should be sqrt ( (loc_x[0]-loc_x[1])^2+(loc_y[0]-loc_y[1])^2) = 102.8428102, not 77.4 in your video ? Am I right ?
@sergiocorrea1179
@sergiocorrea1179 5 жыл бұрын
Dear @@quangphamngoc7701, thank you for you interest. I check the video and the result 77.4 is correct, because after showing the coordinate I run the cell again, and the random number changed, loc_x[0]=83.40, loc_x[1]=144.06, loc_y[0]=68.52, loc_x[1]=20.44. In fact, in order to get always the same coordinate, we should add a np.random.seed(1) over the coordinate creation. Thank you for watching
@maregmarye6443
@maregmarye6443 4 жыл бұрын
Hello, could I get the English version please?
@kelixoderamirez
@kelixoderamirez 2 жыл бұрын
permission to learn sir
@godoy32
@godoy32 5 жыл бұрын
Estoy teniendo un error cuando defino la restriccion para los subtours, la libreria me tira un warning al definir el modelo dice "docplex is not officially supported on 32 bits. Use it at your own risk." y luegp al correr la restriccion dice "TypeError: object of type 'generator' has no len()" sabes que podría ser? Muchas gracias
@sergiocorrea1179
@sergiocorrea1179 5 жыл бұрын
Si, la versión de Cplex que tiene es de 64 bits y estas utilizando un PC con 32 bits. No son compatibles. Sobre la segunda, me podrías enviar una captura de pantalla o pdf del código y puedo ver porque no encuentra un len()
@godoy32
@godoy32 5 жыл бұрын
@@sergiocorrea1179 finalmente logre solucionarlo agregando unos [ ] entre la formulación del conjunto de la restricción. Pero estoy teniendo algunos problemas al usar CPLEX, según lo que vi no está disponible para python 3.7.2, que versión usaste en el video? Muchas gracias por el contenido, todo muy claro
@soderlove42
@soderlove42 5 жыл бұрын
Same problem here with the "TypeError: object of type 'generator' has no len()". I checked the docplex documentation and sadly can't figure out why this is error keeps showing up. Thanks by advance, and I have to say your video was still very helpful. Edit : After further checking, add_indicator_constraints requires a sequence of indicator constraints, so i tried enclosing the constraint with [ ] brackets so that : mdl.indicator_constraint(x[i,j], u[i]+q[j]==u[j]) for (i,j) in arcos if i != 0 and j != 0 becomes [mdl.indicator_constraint(x[i,j], u[i]+q[j]==u[j]) for (i,j) in arcos if i != 0 and j != 0] and it seems to work, I'm not getting any errors and the print(mdl.export_to_string()) gave me something similar to what's in the video. So maybe try that, I'm not an expert by any means but this should probably work.
@sergiocorrea1179
@sergiocorrea1179 5 жыл бұрын
@@godoy32 La versión de python debería ser 3.6. Se pueden descargar versiones pasadas de Anaconda desde la pagina - cuesta llegar un poco. Lo otro es que desde Anaconda Promt desintales python 3.7 e instales python 3.6.
@sergiocorrea1179
@sergiocorrea1179 5 жыл бұрын
@@soderlove42 , should be like that: mdl.add_indicator_constraints ( several indicator constraints) mdl.add_indicator_constraints ( something for (i,j) in arcos if i !=0 and j !=0) here there are several something. So we replaces something for an indicator constraint. mdl.add_indicator_constraints ( mdl.indicator_constraint( x[i,j], u[i]+q[j]==u[j] ) for (i,j) in arcos if i != 0 and j != 0) Using ( ) or [ ], it shouldn't make any difference in this case. ( ) this is a tuple and this [ ] is a list. Both have similar method regarding to our implementation for CPLEX. Although tuples are faster.
@kelixoderamirez
@kelixoderamirez 2 жыл бұрын
permisiion to learn sir
Tutorial -1 | Cplex & Python | Introducción
20:37
sergio correa
Рет қаралды 10 М.
Reinforcement for Solving VRP
3:00
Mohammadreza Nazari
Рет қаралды 7 М.
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,1 МЛН
Men Vs Women Survive The Wilderness For $500,000
31:48
MrBeast
Рет қаралды 98 МЛН
The Joker wanted to stand at the front, but unexpectedly was beaten up by Officer Rabbit
00:12
escape in roblox in real life
00:13
Kan Andrey
Рет қаралды 72 МЛН
Gurobi & Python. Capacitated vehicle routing problem
26:46
Hernán Cáceres
Рет қаралды 66 М.
Tutorial Cplex & Python - 4 | Travel Salesman Problem [ TSP]
40:41
sergio correa
Рет қаралды 12 М.
Tutorial 13: Multi-Vehicle Routing with Time Windows - Day 4 - Thursday, July 26
1:23:07
INDE 4003: 105 Vehicle Routing Problem
27:47
İsmail Başoğlu
Рет қаралды 2,5 М.
Pixtral is REALLY Good - Open-Source Vision Model
11:15
Matthew Berman
Рет қаралды 37 М.
Tutorial Cplex & Python - 5 | Travel Salesman Problem | Google | Excel
1:00:45
CPLEX & Python. Capacitated vehicle routing problem
29:57
Hernán Cáceres
Рет қаралды 67 М.
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,1 МЛН