Shortest path problem in ABAP

Hi experts,
Is it possible to write the code for the "Shortest path problem" in ABAP?If yes, what is the code?
Moderator Message: Don't expect members to spoon-feed you
Edited by: Suhas Saha on Jul 25, 2011 11:13 AM

Hi munish,
I dont think there is any thing wrong with the ABAP code.
Try testing your ABAP mapping using transaction code SXI_MAPPING_TEST in XI.
Enter the Details asked and then enter TEst data in XML format.. 
Also, you can make use of the Trace element to find out if there is any thing wrong with the code.
Include the following Statements after every step in the ABAP code to ensure that the particular step is completed successfully.
data : l_trace type string.
concatenate l_trace '<Message you want to display>' into l_trace.
trace->trace(level = '<level>'
message =l_trace).  
The trace is visible in SXMB_MONI (click on "Trace" in the left pane to view).
using this you will get to know i the code is functioning as desired.
Regards,
Yashaswee.

Similar Messages

  • Shortest path problem

    hello,
    We have a street-layer (spatial). Now we should calculate the shortest path between two nodes. Does Oracle assist in this? Has anybody some experiences with this problem?
    Any help will be appreciated.
    regards
    Anna

    Well, I know there are several algorithms for this problem, but I wanted to know, if and how Oracle assist�s in this point. I get an answer from Oracle, that 10g include such functionality and now I am waiting on it.
    Thanks for your try to help.
    Monika-Anna

  • Help needed in a shortest path search problem..

    Basically the problem is that there is a network of nodes with different paths to other nodes and I am supposed to find a shortest path from a random node to another random node.There are other criteria like weight, capacity etc. but that shouldnt affect the search algorithm... What is the best way to do this type of problem? Example would be great,thanks!

    what about Breadth first search? Also for Dijkstra's, it seems to be dependent only on the weight of paths but if the paths have same weight, how do i go back to the previous node if a path wasn't found?

  • Finding the shortest path router for the router tracking purpose

    Hi all,
    A Question asking you regarding to routers' tracking information.
    We keeps all the router infomation of our subnet in a file name "routers.txt" in this format:
    1 2 1
    2 4 1
    4 3 1
    1 3 5
    This states there are four routers, the distance between routers 1 and 2 is 1, between 2 and 4 is 1, etc.
    I need to write a Java program to keep track the shortest path between routers, I would understand that we can get this done easily in Java, but I am not a Java Savvy. I'm new in Java, would somebody help me to the right direction?
    In order to keep track the routers in our subnet easily,the output would look something like:
    Router 1
    To Router Distance Vector
    2 1 2
    3 3 2
    4 2 2
    Thanks very much,
    Cait.

    Hi kksenji,
    Well, because of the webform, it's not obvious to see. The output would be simple. From the input, for router 1 to router 2, the shortest distance is 1. For router 1 to router 3, the shortest distance is 3, for router 1 to router 4, the shortest distance is 2 and so on. The middle vector that it went through is 2 for every route. Hope this makes sense.
    Just try to solve the problem with the shortest distance, and I have a hard time to figure out the algorithm for this as well as how to get this started.
    Thanks, Cait.

  • Finding the shortest path

    Hey guys,
    Im working on a solution to this problem below is a program to allow a user to draw straight line paths. What i'd like to do is allow the user to select two points on the path he has drawn and find the shortest path among all the interesecting lines.....im going crazy thinking of a solution for this.....im thinking bout steeping down a notch and just try to find just any path first.
    Will really appreciate any help.
    Thnx in advance,
    Vikhyat
    import java.applet.*;*
    *import java.awt.*;
    import java.awt.event.*;*
    *import javax.swing.*;
    import java.awt.geom.*;
    public class Lab11 extends Applet implements MouseListener, MouseMotionListener {
    int x0, y0, x1, y1;
    int mouseRelease=0;
    GeneralPath path = new GeneralPath();
    public Lab11()
    addMouseListener(this);
    addMouseMotionListener(this);
    public void mouseDragged(MouseEvent e)
    x1 = e.getX();
    y1 = e.getY();
    repaint();
    public void mouseMoved(MouseEvent e) { }
    public void mouseClicked(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) { }
    public void mouseExited (MouseEvent e) { }
    public void mousePressed(MouseEvent e) {
    x0 = e.getX();
    y0 = e.getY();
    System.out.println("Mouse pressed at: (" +
    x0 + ", " + y0 + ")" );
    public void mouseReleased(MouseEvent e) {
    x1 = e.getX();
    y1 = e.getY();
    System.out.println("Mouse released at: (" +
    x1 + ", " + y1 + ")" );
    mouseRelease = 1;
    this.repaint();
    public void paint(Graphics g)
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    RenderingHints.VALUE_ANTIALIAS_ON);
    //just for show not concerned with saving paths
    if(mouseRelease==1)
    path.moveTo(x0,y0);
    path.lineTo(x1,y1);
    mouseRelease = 0;
    g2.setPaint(Color.RED);
    g2.draw(path);
    g.setColor(Color.BLACK);
    g.drawLine(x0, y0, x1, y1);
    public static void main(String[] argv)
    JFrame f = new JFrame("Test");
    f.getContentPane().add(new Lab11());
    f.setSize(600,600);
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }Pictorially this is what im trying to do:
    User draws a path like so and selects two points as shown in blue
    [http://i48.photobucket.com/albums/f236/theforrestgump/select.jpg]
    The program should then proceed to highlighting the shortest path
    [http://i48.photobucket.com/albums/f236/theforrestgump/sp.jpg]
    Edited by: cannonball on Apr 1, 2008 7:58 PM

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class ShortPath extends JPanel {
        Path2D.Double path;
        Path2D.Double shortPath = new Path2D.Double();
        Point p1 = new Point();
        Point p2 = new Point();
        final double PROXIMITY = 5.0;
        public ShortPath() {
            path = new Path2D.Double();
            path.moveTo(145,80);
            path.lineTo(125,170);
            path.lineTo(190,200);
            path.lineTo(240,340);
            path.lineTo(285,220);
            path.lineTo(145,80);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(Color.blue);
            g2.draw(path);
            g2.setPaint(Color.green);
            g2.setStroke(new BasicStroke(2f));
            g2.draw(shortPath);
            g2.setPaint(Color.red);
            g2.fill(new Ellipse2D.Double(p1.x-2, p1.y-2, 4, 4));
            g2.setPaint(Color.orange);
            g2.fill(new Ellipse2D.Double(p2.x-2, p2.y-2, 4, 4));
        private void findShortPath() {
            if(!isPointOnLine(p1) || !isPointOnLine(p2)) {
                System.out.println("a point is not on the path");
                return;
            double d1 = getDistanceToPoint(p1);
            double d2 = getDistanceToPoint(p2);
            double pathLength = getDistanceToPoint(new Point());
            Point2D.Double start = new Point2D.Double();
            Point2D.Double end   = new Point2D.Double();
            if((d1 < d2 && d2 - d1 < pathLength - d2 + d1) ||
               (d1 > d2 && d1 - d2 > pathLength - d1 + d2)) {
                start.setLocation(p1);
                end.setLocation(p2);
            } else {
                start.setLocation(p2);
                end.setLocation(p1);
            generatePath(start, end);
        //                        145,80
        // leg distance = 92.2    125,170
        // leg distance = 71.6    190,200   163.8
        // leg distance = 148.7   240,340   312.5
        // leg distance = 128.2   285,220   440.7
        // leg distance = 198.0   145,80    638.7
        private double getDistanceToPoint(Point p) {
            PathIterator pit = path.getPathIterator(null);
            double[] coords = new double[2];
            double distance = 0;
            Point2D.Double start = new Point2D.Double();
            Point2D.Double end = new Point2D.Double();
            Line2D.Double line = new Line2D.Double();
            while(!pit.isDone()) {
                int type = pit.currentSegment(coords);
                switch(type) {
                    case PathIterator.SEG_MOVETO:
                        start.setLocation(coords[0], coords[1]);
                        pit.next();
                        continue;
                    case PathIterator.SEG_LINETO:
                        end.setLocation(coords[0], coords[1]);
                line.setLine(start, end);
                boolean onLine = line.ptSegDist(p) < PROXIMITY;
                if(onLine) {  // point is on this line
                    distance += start.distance(p);
                    break;
                } else {
                    distance += start.distance(end);
                start.setLocation(end);
                pit.next();
            return distance;
        private void generatePath(Point2D.Double first, Point2D.Double second) {
            Point2D.Double p = new Point2D.Double(first.x, first.y);
            Point2D.Double start = new Point2D.Double();
            Point2D.Double end = new Point2D.Double();
            Line2D.Double line = new Line2D.Double();
            boolean pathStarted = false;
            for(int j = 0; j < 2; j++) {
                PathIterator pit = path.getPathIterator(null);
                double[] coords = new double[2];
                while(!pit.isDone()) {
                    int type = pit.currentSegment(coords);
                    switch(type) {
                        case PathIterator.SEG_MOVETO:
                            start.setLocation(coords[0], coords[1]);
                            pit.next();
                            continue;
                        case PathIterator.SEG_LINETO:
                            end.setLocation(coords[0], coords[1]);
                            line.setLine(start, end);
                            boolean onLine = line.ptSegDist(p) < PROXIMITY;
                            if(onLine) {            // found point on line
                                Point2D.Double linePt = getClosestPoint(line, p);
                                Line2D.Double segment;
                                if(!pathStarted) {  // found first point
                                                    // both points on line
                                    if(line.ptSegDist(second) < PROXIMITY) {
                                        Point2D.Double secPt =
                                            getClosestPoint(line, second);
                                        segment = new Line2D.Double(linePt, secPt);
                                        shortPath.append(segment, false);
                                        return;
                                    } else {        // first point only
                                        segment = new Line2D.Double(linePt, end);
                                        shortPath.append(segment, false);
                                        p.setLocation(second);
                                        pathStarted = true;
                                } else {            // found second point
                                    segment = new Line2D.Double(start, linePt);
                                    shortPath.append(segment, false);
                                    return;
                            } else if(pathStarted) {
                                                    // add intermediate lines
                                Line2D.Double nextLine =
                                    new Line2D.Double(start, end);
                                shortPath.append(nextLine, false);
                    start.setLocation(end);
                    pit.next();
        private Point2D.Double getClosestPoint(Line2D.Double line,
                                               Point2D.Double p) {
            double minDist = Double.MAX_VALUE;
            Point2D.Double closePt = new Point2D.Double();
            double dy = line.getY2() - line.getY1();
            double dx = line.getX2() - line.getX1();
            double theta = Math.atan2(dy, dx);
            double length = line.getP2().distance(line.getP1());
            int limit = (int)(length+.05);
            for(int j = 0; j < limit; j++) {
                double x = line.getX1() + j*Math.cos(theta);
                double y = line.getY1() + j*Math.sin(theta);
                double distance = p.distance(x, y);
                if(distance < minDist) {
                    minDist = distance;
                    closePt.setLocation(x, y);
            return closePt;
        private boolean isPointOnLine(Point p) {
            Point2D.Double start = new Point2D.Double();
            Point2D.Double end = new Point2D.Double();
            Line2D.Double line = new Line2D.Double();
            PathIterator pit = path.getPathIterator(null);
            double[] coords = new double[2];
            while(!pit.isDone()) {
                int type = pit.currentSegment(coords);
                switch(type) {
                    case PathIterator.SEG_MOVETO:
                        start.setLocation(coords[0], coords[1]);
                        pit.next();
                        continue;
                    case PathIterator.SEG_LINETO:
                        end.setLocation(coords[0], coords[1]);
                        line.setLine(start, end);
                        if(line.ptSegDist(p) < PROXIMITY) {
                            return true;
                start.setLocation(end);
                pit.next();
            return false;
        public static void main(String[] args) {
            ShortPath test = new ShortPath();
            test.addMouseListener(test.ml);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(test);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
        private MouseListener ml = new MouseAdapter() {
            boolean oneSet = false;
            public void mousePressed(MouseEvent e) {
                Point p = e.getPoint();
                if(oneSet) {
                    p2 = p;
                    findShortPath();
                } else {
                    p1 = p;
                    shortPath.reset();
                oneSet = !oneSet;
                repaint();
    }

  • Aco  implemenataion for shortest paths.

    has anyone used ant colony optimization algorithm for finding shortest paths other than for the tsp? please i need some help and advice. thanks

    sorry for not being specific and the insubsequent reply. am just doing some research on aco, i want to try and implement it for best bath planning on a map/graph. I've been looking around for some example on such and noticed that this algorithm is mainly used for tsp problem which got me questioning the possibility of my task. I just want to know if it is definitely possible with aco as i will give it a go in this case. Implementing this algorthm successfully is the main challenge of my project so i cannot contemplate another algorithm option. Thanks for your time.

  • Shortest path issue

    Hey guys, first...Happy thanksgiving :)
    Ok, so I'm on my last assignment for my amazingly taught Data Structures class. I battled my way successfully through recursion, binary trees, redblack trees, 234 trees, B Trees, and heaps!...no issues at all!....but, now I have hit graphs. I understand the concept, but my latest assignment has me a bit frustrated..Im so close to finishing I can taste it!!....I just cant find the spoon..
    Here we go:
    We are given a graph on paper. It has circles (verteci) representing cities in the USA. These circles are connected by lines (edges) representing the distance between the cities. Also, the lines have arrows pointing the direction they may be traversed.
    We are to construct the graph in the computer, and then compute the shortest path from washington (Vertex 0) to every other city.
    I managed to construct the graph, and it will find the shortest path no problem. My only issue is that, it wants us to print the path it took, not just the destination and total distance....
    I have tried using a stack to push the verteci onto as theyre visited, but im not getting happy results.
    I should also mention, this code is taken out of the book with modifications by me so that it can add edges and verteci, and it now accepts String types for the vertex labels instead of characters.
    Here is my code
    PATH.JAVA (the important part)
    // path.java
    // demonstrates shortest path with weighted, directed graphs
    // to run this program: C>java PathApp
    import java.lang.*;
    import java.io.*;
    class DistPar               // distance and parent
    {                           // items stored in sPath array
        public int distance;    // distance from start to this vertex
        public int parentVert;  // current parent of this vertex
        public DistPar(int pv, int d)  // constructor
            distance = d;
            parentVert = pv;
    }  // end class DistPar
    class Vertex
        public String label;        // label (e.g. 'A')
        public boolean isInTree;
        public Vertex(String lab)   // constructor
            label = lab;
            isInTree = false;
    }  // end class Vertex
    class Graph
        private final int MAX_VERTS = 20;
        private final int INFINITY = 1000000;
        private Vertex vertexList[];    // list of vertices
        private int adjMat[][];         // adjacency matrix
        private int nVerts;             // current number of vertices
        private int nTree;              // number of verts in tree
        private DistPar sPath[];        // array for shortest-path data
        private int currentVert;        // current vertex
        private int startToCurrent;     // distance to currentVert
        private stack path_taken;       // stack to record path taken
        public Graph()                  // constructor
            vertexList = new Vertex[MAX_VERTS];
                                             // adjacency matrix
            adjMat = new int[MAX_VERTS][MAX_VERTS];
            nVerts = 0;
            nTree  = 0;
            for(int j=0; j<MAX_VERTS; j++)      // set adjacency
                for(int k=0; k<MAX_VERTS; k++)  //     matrix
                    adjMat[j][k] = INFINITY;    //     to infinity
            sPath = new DistPar[MAX_VERTS];     // shortest paths
            path_taken = new stack(MAX_VERTS);
        }  // end constructor
        public void addVertex(String lab)
            vertexList[nVerts++] = new Vertex(lab);
        public void addEdge(int start, int end, int weight)
            adjMat[start][end] = weight;  // (directed)
        public void path()                // find all shortest paths
            int startTree = 0;             // start at vertex 0
            vertexList[startTree].isInTree = true;
            nTree = 1;                     // put it in tree
          // transfer row of distances from adjMat to sPath
            for(int j=0; j<nVerts; j++)
                int tempDist = adjMat[startTree][j];
                sPath[j] = new DistPar(startTree, tempDist);
          // until all vertices are in the tree
            while(nTree < nVerts)
                int indexMin = getMin();    // get minimum from sPath
                int minDist = sPath[indexMin].distance;
                if(minDist == INFINITY)     // if all infinite
                {                        // or in tree,
                    System.out.println("There are unreachable vertices");
                    break;                   // sPath is complete
                else
                {                        // reset currentVert
                    currentVert = indexMin;  // to closest vert
                    startToCurrent = sPath[indexMin].distance;
                    // minimum distance from startTree is
                    // to currentVert, and is startToCurrent
                // put current vertex in tree
                vertexList[currentVert].isInTree = true;
                nTree++;
                path_taken.push(sPath[indexMin]);
                adjust_sPath();             // update sPath[] array
            }  // end while(nTree<nVerts)
            displayPaths();                // display sPath[] contents
            nTree = 0;                     // clear tree
            for(int j=0; j<nVerts; j++)
                vertexList[j].isInTree = false;
        }  // end path()
        public int getMin()               // get entry from sPath
        {                              //    with minimum distance
            int minDist = INFINITY;        // assume minimum
            int indexMin = 0;
            for(int j=1; j<nVerts; j++)    // for each vertex,
            {                           // if it's in tree and
                if( !vertexList[j].isInTree &&  // smaller than old one
                                   sPath[j].distance < minDist )
                    minDist = sPath[j].distance;
                    indexMin = j;            // update minimum
            }  // end for
            return indexMin;               // return index of minimum
         }  // end getMin()
        public void adjust_sPath()
          // adjust values in shortest-path array sPath
            int column = 1;                // skip starting vertex
            while(column < nVerts)         // go across columns
             // if this column's vertex already in tree, skip it
                if( vertexList[column].isInTree )
                    column++;
                    continue;
             // calculate distance for one sPath entry
                           // get edge from currentVert to column
                int currentToFringe = adjMat[currentVert][column];
                           // add distance from start
                int startToFringe = startToCurrent + currentToFringe;
                           // get distance of current sPath entry
                int sPathDist = sPath[column].distance;
             // compare distance from start with sPath entry
                if(startToFringe < sPathDist)   // if shorter,
                {                            // update sPath
                    sPath[column].parentVert = currentVert;
                    sPath[column].distance = startToFringe;
                column++;
             }  // end while(column < nVerts)
        }  // end adjust_sPath()
        public void displayPaths()
            for(int j=0; j<nVerts; j++) // display contents of sPath[]
                System.out.print(vertexList[j].label + "="); // B=
                if(sPath[j].distance == INFINITY)
                    System.out.print("inf");                  // inf
                else
                    System.out.print(sPath[j].distance);      // 50
                    String parent = vertexList[ sPath[j].parentVert ].label;
                    System.out.print(" (" + parent + ") ");       // (A)
            System.out.println("");
            System.out.println("PRINTING path_taken");
            DistPar thing = null;
            while((thing = path_taken.pop()) != null)
                System.out.println(" " + vertexList[thing.parentVert].label + " "+ thing.distance);
    }  // end class GraphSTACK.JAVA (my stack class)
    // stack.java
    // demonstrates stacks
    // to run this program: C>java StackApp
    class stack
        private int maxSize;        // size of stack array
        private DistPar[] stackArray;
        private int top;            // top of stack
        public stack(int s)         // constructor
            maxSize = s;             // set array size
            stackArray = new DistPar[maxSize];  // create array
            top = -1;                // no items yet
        public void push(DistPar j)    // put item on top of stack
            stackArray[++top] = j;     // increment top, insert item
        public DistPar pop()           // take item from top of stack
            return stackArray[top--];  // access item, decrement top
        public DistPar peek()          // peek at top of stack
            return stackArray[top];
        public boolean isEmpty()    // true if stack is empty
            return (top == -1);
        public boolean isFull()     // true if stack is full
            return (top == maxSize-1);
    }PATHAPP.JAVA (test program..builds the graph and calls path())
    class PathApp
        public static void main(String[] args)
            Graph theGraph = new Graph();
            theGraph.addVertex("Washington");
            theGraph.addVertex("Atlanta");
            theGraph.addVertex("Houston");
            theGraph.addVertex("Denver");
            theGraph.addVertex("Dallas");
            theGraph.addVertex("Chicago");
            theGraph.addVertex("Austin");
            theGraph.addEdge(0,1,600);
            theGraph.addEdge(1,0,600);
            theGraph.addEdge(0,4,1300);
            theGraph.addEdge(4,3,780);
            theGraph.addEdge(3,1,1400);
            theGraph.addEdge(1,2,800);
            theGraph.addEdge(2,1,800);
            theGraph.addEdge(4,5,900);
            theGraph.addEdge(4,6,200);
            theGraph.addEdge(6,4,200);
            theGraph.addEdge(6,2,160);
            theGraph.addEdge(3,5,1000);
            theGraph.addEdge(5,3,1000);
            System.out.println("Shortest Paths");
            theGraph.path();
            //theGraph.displayPaths();
            System.out.println();
    }Im mostly having trouble comprehending the Path.java file. A few friends and I stared at it for a few hours and couldnt get it to do what we wanted...
    path_taken is the stack I added in to try and push/pop the verteci as theyre traversed, but with what I stuck in right now, it still just prints the most recently visited vertex, and the sum of the distances.
    Any help is greatly appreciated!
    Thanks :)
    ----Arkhan

    If your graph is G(V, E), and you're trying to get to vertex v_end, then create a new graph G'(V', E') whereV' = (V x N) U {v_end'}
        (v_end' is a new object)
    E' = {((u, t), (v, t + f(u, v, t))) : (u, v) in E, t in N} U
         {((u, t), (u, t + 1)) : u in V, t in N} U
         {((v_end, t), v_end') : t in N}G' is infinite, so you'll need to use a lazy graph structure. Then just use Dijkstra from (v_start, 0) to v_end'.

  • Shortest path which includes all subset

    In graphs (V,E) with negative edge weights but with no negative cycles , X <V and s, t in V .I need an algorithm to decide if exist in the graph ,shortest path from s to t with which includes all the nodes from X

    Unfortunately the problem you are trying to solve in NP-complete (it means that the best known algorithm for doing this is exponential in time with respect to size of X) so the best solution is to check every possibility. But if your graph has some special form there may be efficient solution for this problem. In general it's special case is finding [Hamiltonian path|http://en.wikipedia.org/wiki/Hamiltonian_path].

  • Hoc can u find shortest path from a Map of a building

    i have to find a shortest path on a map of building how should i do it any good idea, i m newbee plz help me here

    This is not the proper forum for that sort of question. You should define your problem more clearly and post it to the New to Java forum

  • Shortest path between two arbitrary point in the network

    Hi All,
    In oracle NDM, it's possible to find shortest path between two nodes (e.g. using SDO_NET_MEM.NETWORK_MANAGER.SHORTEST_PATH), but I need to find shortest path between 2 points which are on the network edges. I suppose I should use (Interface SubPath) in network java apis. However I want to do it via PLSQL api. Should I code it myself or there exists a function?
    Any help is appreciated.
    Edited by: Fa on Dec 15, 2011 2:51 AM

    pritamg wrote:
    I have to build an application in which the user will draw the graph by creating nodes and edges.and then the start node will be marked.Then the shortest paths to other nodes will be displayed.Give me any possible clue how to start.I am in deep deep trouble.I have to use Dijkstra's Algorithm.
    please help some one...pleaseDo you know Dijkstra's Algorithm for shortest path? I believe that one was also called the traveling salesman problem. You can easily Google to find out what it is.
    Did you listen to your instructor when he/she did his/her lectures on recursion and halting contitions? If not, then please go talk to him/her and read your book, the forum is not a place to try to learn a basic concept that you should have paid attention in class for the first time.
    If you have code and you have specific questions post them and we will be glad to help, but we are not here to develop your homework solutions for you, no matter how that may affect your future.

  • Fitness for Shortest path using a genetic algorithm

    Hi.
    I have this problem:
    I'm doing a program that has a map and two points. the map has wall that are not valid positions.
    I have used a A* algorithm to calculate the shortest path and is working fine.
    now i'm implementing a genetic algorithm to solve the problem but i'm not having sucess.
    My genetic operator are directions (left, right, up and down).
    I'm not being able to find a goodfitness function to solve the problem.
    can someone tell me a god function or here I can found information about that?
    I have been searching on google and I have not yet had sucess.
    I have tryed two diferent fitness tecniques:
    - add 1 for each step and if it finds a wall or gets out of the map add the maximum value (mapsize*mapsize).
    - the other one is add the valid steps and if it finds a wall or gets out of the map add the number of necessary steps to gets to destination. the valid steps has a weight of 30% and the necessary steps has a weight of 70% (i have tryed to use diferent weight).
    Can someone help me?
    thanks

    How about adapting your TSP code as follows. Your graph G(V, E) has two special vertices: v_s and v_d (start and destination). Let a candidate solution consist of a permutation of V\{v_s, v_d}u{v_m} where v_m is a new marker vertex whose purpose is to allow you to treat part of the candidate solution as irrelevant. Given candidate solution v_0 v_1 v_2 ... v_n v_m v_n+1 ... the weight is c(v_s, v_0) + c(v_0, v_1) + ... + c(v_n-1, v_n) where c(v_a, v_b) is the cost of the edge ab.

  • Shortest Path Algorithm:

    Hi,
    I have about 20,000 (double) points and trying to find a shortest path between any two. I know that the best algorithm for doing that is Dijkstra's one. What is the best data structure for this? I read that usually heaps but the time it needs to sort the list is too long, maybe some one knows a better way? Maybe there is another algorithm that solves this problem? Please give me any suggestion about anything that I said above.
    Thank you in advance.

    I don't know no Dijkstra's algorithm for this problem. The only algorithm of Dijkstra for something like that that I know is to find the shortest path between two nodes in a weight network.
    I think that the lower bound for what you are trying to do is the same lower bound for sorting the points, so I think that the best you can do is to apply a good sorting algorithm (like quicksort, mergesort, heapsort or shellsort).
    The best data structure depends about how much info do you have previously about the number of points and memory that you have available. If you know that the max number of points that you'll work can be fit in the available memory, then the best data holder to use is an array (it's aways the fastest). If you'll see it as an array or as stack (for example) depends on the algorithm that you'll choose to sort the points.
    One last tip: if you choose using a List, prefer the ArrayList over LinkedList. LinkedList is slower than ArrayList for almost all kind of operations. If you'll work with a lot of elemts, do some testing before pick one of the two.
    Hope it helps,
    RGB

  • Shortest Path Algorithm. Need help.

    Hey, Im having trouble coming up with an algorithm for a shortest path. I have an NxN weighted matrix and need to get from the upper left corner to the lower right corner. The length of the path must be the shortest possible for the number of moves and total weight (ie. a 3X3 matrix would use 4 moves, a 4X4 uses 6 and a 5X5 uses 8).
    im using a 2-dimensional array like matrix[x][y] with the storage at this location being a random integer.
    I came up with some guidelines:
    1) the path can never move left because it would break the shortest moves requirement.
    2) the path can never move up for the same reason.
    when traversing through the matrix if x == N then go down to N,N. If y == n go right until N,N.
    I can visualize how to do it. Its just putting my algorithm into a program is beyond me right now.
    Any help would be appreciated greatly.

    Dijkstra's algorithm only works on a weighted graph.
    I have a weighted matrix.
    Its like a chess board where every square has a
    number on it. I have to get from the upper left to
    the lower right using as little squares as possible
    and then amongst those paths find the one with the
    smallest weight or total.So something where individual squares have a certain toughness to get through, then?
    Yeah, A* will own that...
    I really don't want to write a tutorial on how to find the shortest path. But basically, you need to have a queue of paths. For each iteration until you find your goal, you pop the path with the least cost and you find the four paths you could get from it (move up, down, left, and right).
    The key here is the cost function (heuristic). It must approximate the actual cost of a path WITHOUT over-approximating.
    For your problem, you should probably factor in cost of the path so far, and the lowest possible expectable distance from the end of the path you're considering to the goal (think "distance formula").
    Also, since these are general algorithms, you should probably code them up to work with an arbitrary start/end, instead of concrete values.
    ~Cheers

  • Problem with ABAP proxies - HTTP connection to R/3 is not working

    Hi guys!
    I'm setting up a connection from XI to R/3 , because I'm using proxy objects. Our DEV is working fine. Now I have moved the objects to QA and since the HTTP connection is not there, I need to set it up.
    I have created a service user on R/3, activated ICF service on R/3 and created a HTTP to abap type connection in XI. When I test the connection I get a new logon screen. Why? I have provided information about logon user, client, ....
    Thank you! Olian

    Hi,
    this logon screen populated when the RFC User ID is locaked. ask your basis team to release it.
    also refer below links if in case of any other problem
    Actiave ABAP Proxies -- /people/vijaya.kumari2/blog/2006/01/26/how-do-you-activate-abap-proxies
    Setting Up Point-to-Point Connections with proxy
    http://help.sap.com/saphelp_nw04s/helpdata/en/85/78af1bf407434796aaf8dbd6d4e7b7/frameset.htm
    Thanks
    Swarup

  • Path problem for "Load VRML File.vi" in EXE

    Hello,
    The new integrated 3d Picture Control functionality in LabVIEW 8.20 is amazing.  It is a really easy to use implementation of OpenGL.  I've discovered one bug/issue when building VI's to an exe that includes the 3d Picture Control:
    If "Load VRML File.vi" is used, in the executable, you will encounter a LabVIEW Error 7 due to a path problem in the following vi:
    NI_3D Picture Control.lvlib:Load VRML File.vi->NI_3D Picture Control.lvlib:NI_Old 3D Toolkit.lvlib:Read WRL file.vi->NI_3D Picture Control.lvlib:NI_Old 3D Toolkit.lvlib:Initialize.vi
    The File Not Found problem will prevent the vrml file from loading.  Navigating down into the subVI's of the "Load VRML File.vi" shown above easily reveals the problem.  I've included a screenshot of the diagram of that VI.  The relative
    path resulting from the double "Strip Path" operation is not valid
    in the executable.  I'm not sure where that "definitions" file resides
    in the runtime deployment or if it's even included, so fixing the path to account for the differences in the exe vs. development environment path is not an option.   I'm also usually very hesitant to make any mods to anything in vi.lib.
    For the development environment, the "definitions" file can be found at: [LabVIEW 8.2 dir]\vi.lib\picture\3D Picture Control
    The easy fix is to include the "definitions" file in the same directory as your exe when you build.  Fortuitously, this does the trick because the first strip path gives the path to the exe and then the second strip path results in the path to the directory where the exe resides.
    Hopefully NI will fix this path reference properly in future revisions.
    Enjoy!
    Attachments:
    WRL Debug.jpg ‏77 KB

    Hi Chris,
    Thanks a lot for the feedback!  This was reported to R&D (# 47F9DJIQ) for further investigation.
    Regards,
    Justin D

Maybe you are looking for

  • Dunning letter with smartform

    Hi experts, I have to create a form for dunning letter with (smartforms) for the transaction F150 and really I don't know how I will do it. I don't know how to pass the fields run on, identification customer to the formulaire for getting data for dis

  • Upgrade from 10.2 to Tiger 10.4.11

    I don't want to upgrade to Leopard. I want Tiger 10.4.11 to run on my PowerBook G4 17inch (running on 10.2)... (This computer is not on line.) Is Tiger 10.4.11 still on the market to purchase? Can I take my PB G4 into an Apple store and have Tiger 10

  • How to fix Personal Hotspot

    Hey all, If like many people you're having problems connecting to Personal Hotspot (especially from an iPad) read up! I was getting really frustrated with connecting my iPad to my 4S via Personal Hotspot. After a fresh boot of the phone it would work

  • Rollovers with .swf

    I'm new to Dreamweaver...pardon the newbie question. Is there a way to create a rollover with and image and .swf movie? Basically I want to have the .swf playing, and when you rollover a box with text appears. Any thoughts? And...if this is possible,

  • Yahoo email not working with 8.1.1

    I upgraded to iOS 8.1.1 this morning on my iPhone 6 and iPad Air 2.  Since then neither has been able to get any new mail from Yahoo.  Is there a problem with this upgrade and Yahoo email?  I've received lots of mail today, just not on my iPhone/iPad