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
@sebastianandresrodriguezro33794 жыл бұрын
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.
@danielsan66763 жыл бұрын
Súper bien explicado, gracias Sergio, me ayudó mucho para mi trabajo final, saludos desde Colombia
@brianhoward68504 жыл бұрын
Don Sergio, muchas gracias por la serie de videos. Le acabo de enviar un correo. Saludos.
@MegaLobo0004 жыл бұрын
Excelente material, muchas gracias. Saludos
@agustinguerra66924 жыл бұрын
Excelente contribucion muchas gracias
@AlexGonzalez-lp3hd5 жыл бұрын
Buen material , bien explicado, me sirvió , muchas gracias
@priscilladesouzasilva49035 жыл бұрын
This video is help a lot.
@julioeduardomonterollanca60905 жыл бұрын
Buenismo el video , gracias por tu ayuda comapañero .
@AvatarJJJ5 жыл бұрын
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.
@mariapaulazambranou42254 жыл бұрын
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.
@martinpratto14753 жыл бұрын
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
@sergiocorrea11792 жыл бұрын
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).
@davidsanchez40154 жыл бұрын
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.
@juanleonjacome31805 жыл бұрын
Quiero aplicar este ruteo a Un problema de Ruteo de Camiones recolectores de residuos, por arcos CAPACITADOS!, Puedo realizar este problema con ARCGIS???
@genuiskids33624 жыл бұрын
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
@Chopin640003 жыл бұрын
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
@sergiocorrea11793 жыл бұрын
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.
@harishankar64965 жыл бұрын
Can you please tell how to add the subtour elimination constraints in docplex
@sergiocorrea11795 жыл бұрын
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 !!!!
@javierwilches73 жыл бұрын
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?
@sergiocorrea11793 жыл бұрын
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.
@anapaulapedrazzoli14503 жыл бұрын
HOLA! no hay un ejemplo de vrppd '?
@sergiocorrea11792 жыл бұрын
No por el momento, pero si tienes algún ejemplo, me lo puedes compartir para preparar un video con eso. Saludos !
@wildonrp5 жыл бұрын
Muy interesante, para leer detenidamente, tienes alguna Web para hacer lectura. Gracias
@sergiocorrea11795 жыл бұрын
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.
@manuelpatricioacuna593 жыл бұрын
Hace clases en la ucn Coquimbo?? :O
@sergiocorrea11793 жыл бұрын
En la de coquimbo y antofagasta, por qué??
@nicolasvegasoto73402 жыл бұрын
Hola, como puedo asignar valores a la demanda de manera que no sea aleatoria?
@sergiocorrea11792 жыл бұрын
Debes tener los valores reales y puedes utilizar la misma estructura de datos del video pero leyendo tus valores.
@AleProgramadorRunner5 жыл бұрын
Hola vi el video es perfecto para el calculo de rutas, pero no me dice cuantos vehículos óptimos por ruta.
@sergiocorrea11795 жыл бұрын
Alejandro es un vehículo por ruta y la cantidad de vehículos ( o rutas) depende de la capacidad de los vehículos.
@quangphamngoc77015 жыл бұрын
i don't know much about the results of your numpy.hypot, I think it is incorrect
@sergiocorrea11795 жыл бұрын
Dear Quang, why numpy.hypot may be incorrect?. Thank you for watching !
@quangphamngoc77015 жыл бұрын
@@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 ?
@sergiocorrea11795 жыл бұрын
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
@maregmarye64434 жыл бұрын
Hello, could I get the English version please?
@kelixoderamirez2 жыл бұрын
permission to learn sir
@godoy325 жыл бұрын
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
@sergiocorrea11795 жыл бұрын
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()
@godoy325 жыл бұрын
@@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
@soderlove425 жыл бұрын
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.
@sergiocorrea11795 жыл бұрын
@@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.
@sergiocorrea11795 жыл бұрын
@@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.