Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
M

Member_15814673

@Member_15814673
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Python Code Heuristic Algorithm
    M Member_15814673

    Me enviaron hacer que el algorimo heruistico que esta de forma lineal sea dinamico, osea que el cambio de posicion lo genere de forma dinamica mediante el ingreso del tamaño del array, pero no me sale me podrian ayudar??? solo he logrado que imprima el array pero no me sale el cambio de posicion

    Google translate:

    They sent me to make the heruistic algorithm that is linearly dynamic, that is, the change of position is generated dynamically by entering the size of the array, but it doesn't work out, could you help me??? I have only managed to print the array but I do not get the change of position

    # Puzle Lineal con heurística
    from re import I
    from ClaseNodo import Nodo
    def buscar_solucion_heuristica(nodo_inicial, solucion, visitados):
    visitados.append(nodo_inicial.get_datos())
    if nodo_inicial.get_datos() == solucion:
    return nodo_inicial
    else:
    # expandir nodos sucesores (hijos)
    dato_nodo = nodo_inicial.get_datos()
    i=0
    while i < tamaño :
    hijo=[]
    hijo.append(dato_nodo)
    i=i+1
    hijo=[dato_nodo[1], dato_nodo[0], dato_nodo[2], dato_nodo[3], dato_nodo[4], dato_nodo[5]]
    hijo_izquierdo = Nodo(hijo)
    hijo=[dato_nodo[1], dato_nodo[0], dato_nodo[3], dato_nodo[2], dato_nodo[4], dato_nodo[5]]
    hijo_central = Nodo(hijo)
    hijo=[dato_nodo[1], dato_nodo[0], dato_nodo[3], dato_nodo[2], dato_nodo[5], dato_nodo[4]]
    hijo_derecho = Nodo(hijo)
    nodo_inicial.set_hijos([hijo_izquierdo, hijo_central, hijo_derecho])
    for nodo_hijo in nodo_inicial.get_hijos():
    if not nodo_hijo.get_datos() in visitados and mejora(nodo_inicial, nodo_hijo):
    # llamada recursiva
    sol= buscar_solucion_heuristica(nodo_hijo, solucion, visitados)
    if sol != None:
    return sol

            return None
    

    def mejora(nodo_padre, nodo_hijo):
    calidad_padre=0
    calidad_hijo=0
    dato_padre = nodo_padre.get_datos()
    dato_hijo = nodo_hijo.get_datos()
    for n in range(1,len(dato_padre)):
    if (dato_padre[n]>dato_padre[n-1]):
    calidad_padre = calidad_padre + 1;
    if (dato_hijo[n]>dato_hijo[n-1]):
    calidad_hijo = calidad_hijo + 1;

    if calidad\_hijo>=calidad\_padre:
    
    Python python algorithms data-structures help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups