

Something in this[^] list might help. One thought would be to implement a BST as a base for this.





Extremely promising, thank you Pete.
Don't forget to vote if the response was helpful
Sig history
"dad" IshmailSamuel Mustafa
"There is no wealth like knowledge, no poverty like ignorance" Ali Ibn Abi Talib
Mustafa Ismail Mustafa wrote:
Keep it up.
Fool.
I now think of you as Mr. T!  Trollslayer





Can you tell me how can i make more efficient algorithm for this problems?
We have a directed graph and a function of weight w we know that there is only one edge with a negative weight and that there is no cycle in the graph with negative weight we have s a vertex
We have to find an algorithm that find the length of all the shortest paths from s to every vertex of G






Lol I didnt realize that all the threads next to this one are also linked with A* ;o
You might take a look at those too.





The following is the C codes ,you can refer to it if needed.
#include<stdio.h> #include<malloc.h> #define MAXV 20 #define INF 32767 typedef struct { int edges[MAXV][MAXV]; int n; } MGraph;
void Ppath(int path[],int i,int v) { int k; k=path[i]; if(k==v) return; Ppath(path,k,v); printf("%d,",k); } void PRINTF(int dist[],int path[],int s[],int n,int v) { int i; for(i=0;i<n;i++) { if(i==v) continue; if(s[i]==1) { printf("from%dto%d,the shortestpath is：%d\t：",v,i,dist[i]); printf("%d,",v); Ppath(path,i,v); printf("%d\n",i); } else printf("from%dto%ddoesn't exits a path\n",v,i); } } void Dijkstra(MGraph p,int v) { int dist[MAXV],path[MAXV]; int s[MAXV]; int mindis,i,j,u; for(i=0;i<p.n;i++) { dist[i]=p.edges[v][i]; s[i]=0; if(p.edges[v][i]<INF) path[i]=v; else path[i]=1; } s[v]=1;path[v]=0; for(i=0;i<p.n;i++) { mindis=INF; for(j=0;j<p.n;j++) { if(s[j]==0&&dist[j]<mindis) { u=j; mindis=dist[j]; } } s[u]=1; for(j=0;j<p.n;j++) { if(s[j]==0) { if(p.edges[u][j]<INF&&dist[u]+p.edges[u][j]<dist[j]) { dist[j]=dist[u]+p.edges[u][j]; path[j]=u; } } } } PRINTF(dist,path,s,p.n,v); } int main() { int i,j,n,x; MGraph p; printf("please input the number of the vertex of the directed graph："); scanf("%d",&n); while(n!=0) { printf("please input the adjacency matrix of the directed graph：\n"); for(i=0;i<n;i++) { for(j=0;j<n;j++) { scanf("%d",&p.edges[i][j]); } } p.n=n; printf("which vertex you want to search?(0%d):\n end inputing with%d\n",n1,n); scanf("%d",&x); while(x!=n) { Dijkstra(p,x);printf("\n"); printf("which vertex you want to search?(0%d):\n end searching with %d:\n",n1,n); scanf("%d",&x); } printf("over!\n"); printf("please input the number of the vertex of the directed graph, input 0 if you want to quit:\n"); scanf("%d",&n); } return 0; }






I'm trying to figure out how to minimize the size of the search space for the A* algorithm.
I'm trying to solve the nQueens problem using A*, and so, given a root and a goal, I create the intervening graph to be searched. That's fine, but the state space grows exponentially since its size in n^n (making n = 10 have a space of 10 billion items).
How could we deal with this?
Serialize and deserialize?
The object is I'm trying to see how to build the SMA* (Simplified Memory bounded A*).
Cheers
Don't forget to vote if the response was helpful
Sig history
"dad" IshmailSamuel Mustafa
"There is no wealth like knowledge, no poverty like ignorance" Ali Ibn Abi Talib
Mustafa Ismail Mustafa wrote:
Keep it up.
Fool.
I now think of you as Mr. T!  Trollslayer





The simplest way to restrict a search space is to introduce appropriate constraints.
Alternatively, you could minimize some kind of heuristic function (defined on a per node basis) to pick the best possible search direction from any given node. The heuristic function will therefore only pursue searches from nodes at which it is minimized.
I don't know if some kind of Rapidly Exploring Random Tree might also be of interest.





73Zeppelin wrote: The simplest way to restrict a search space is to introduce appropriate constraints.
You mean like a maximum height for example? Or should I be thinking about generating them on the fly?
Like for example, where n == 4, if say the heuristics included that any queen should be in a column by itself, then the current node can generate 4 other nodes only if we follow the heuristic that one and one queen only will be moved up and down the column. This can be aided by the cost function, specifying a node with a greater number of constraints satisfied costing less.
Maybe the diagram expresses it better:
0 = empty
X = queen
when n == 4
A B C D
0 0 0 X 0
1 X 0 0 0
2 0 0 0 0
3 0 X 0 X
(1303 in compressed form)
Can generate any of 16 states (4 queens * 4 potential locations) or 12 states (4 queens * 3 potential locations if we decide that if a queen is chosen it must be moved to a location other than its present one)
So if we chose file D, the generated states to chose from are (generated states = n1 heuristic):
(original)
A B C D A B C D  A B C D A B C D
0 0 0 X 0  0 0 0 X X  0 0 0 X 0  0 0 0 X 0
1 X 0 0 0  1 X 0 0 0  1 X 0 0 X  0 X 0 0 0
2 0 0 0 0  2 0 0 0 0  2 0 0 0 0  0 0 0 0 X
3 0 X 0 X  3 0 X 0 0  3 0 X 0 0  0 0 X 0 0
(1303) (1300) (1301) (1302)
1302, the last one would have the smallest cost because it has the least number of conflicts, i.e. greatest number of constraints satisfied and it happens that it actually is a solution.
The closed queue's size can be maintained so that the search won't run to infinity.
Am I making sense? To me it seems like a viable solution.
Don't forget to vote if the response was helpful
Sig history
"dad" IshmailSamuel Mustafa
"There is no wealth like knowledge, no poverty like ignorance" Ali Ibn Abi Talib
Mustafa Ismail Mustafa wrote:
Keep it up.
Fool.
I now think of you as Mr. T!  Trollslayer





Generating on the fly using current available information about the state space is quite efficient (may or may not be "optimal", I'm not sure), in my opinion.
And it seems viable. It will, of course, require a bit of testing to make sure but offhand, it looks good.





Hello all.
I'm working on program decoding mpeg streams, decoding itself is performed on hardware  my code passes frames read from a file.
The problem is that I need recongnize iframes. Is that information
contained in every frame or the frequency of iframes in the stream is
in file header? I would appreciate any suggestions, links etc. (complete solution too).





that information is in the header of each Group Of Pictures,
MPEG TS {
Packet Elementary Stream (Video){
GOP {
### start code
header information < your mission, should you choose to accept it.
...
}
}
}
sorry for the late reply.





Hello everyone! I am a fourth year IT student and I am now currently making my thesis. By this time, I am in the process of building a mathematical model in helping to identify the right products to be purchased as well as its corresponding quantity to meet the desired goals like having an increase of sales and minimization of product purchasing costs. By the way, my study is all about Decision Support Sytem applying the goalseeking analytical modeling technique. Is there anyone who can help me on how to build the model??? I really need your expertise on this matter. Please help me to deal with this...





If it's a thesis project, you should really be consulting with your thesis supervisor. Soliciting help from the internet could end up with you using somebody else's work in your thesis and claiming it to be yours; a big nono.
Unless you have a specific question or programming issue, I suggest you consult with your supervisor first as to the best method by which to proceed.





For an incompletelyunderstood complex problem, I like to initially "push" the problem and see how it pushes back. This gives insights as to the issues the ultimate solution needs to address.
Since you're meeting goals while minimizing costs, one way to push the problem is to examine Linear Programming http://en.wikipedia.org/wiki/Linear_programming[^], which is a simple, effective, wellknown approach to this type of problem.
Although Linear Programming probably won't meet your needs, the value here is in analyzing why it doesn't work for your problem. The answer to that will provide clues to coming up with a more sophisticated solution. Repeat as needed.





how to connect crystal report with ASP 2.0





I've been tasked by my AI Professor to create a solution for the nQueens problem, using A* and GA, and maintaining Constraint Satisfaction.
Basically, is this possible? If so, how's the mix? I know I should have asked the Professor these questions in class, but he was in a rush to leave because he his wife was delivering and it did not click at the time in my head.





Isn't A* a path finding algorithm? In that sense using both A* and GA seems a little redundant. Just to take a whack at it, I would suggest using A* to search a possible population of paths generated by the GA.
Alternatively, you could use the GA to position the queen and then A* to calculate the paths.
Like I said, either algorithm should be sufficient, I'm not sure why you need to use both. Any more recent developments since posting the original question?
(I've been absent from the forums as I was taking a Christmas break. )





I called the Prof this morning and I explained to him that what I understood made the assignment a load of rubbish. It turns out I misunderstood. He wants two assignments, both solutions to the nQueens problem, one using SMA* (simplified memory bounded A*) and the other using GA.
Cheers.





Mustafa Ismail Mustafa wrote: He wants two assignments, both solutions to the nQueens problem, one using SMA* (simplified memory bounded A*) and the other using GA.
Ah, that would make more sense. Seems unnecessary (and possibly difficult) to mix the two.





Precisely.
I couldn't understand how he wanted the mix. It does make a lot more sense.
Cursed MSc.





Mustafa Ismail Mustafa wrote: Cursed MSc.
You have much to learn yet, young Masters Student.





Actually, I'm top of my class
It didn't register at the time but I got suspicious when I started reading for the assignment. Didn't make sense, so I posted here and then I called the Prof and he set the record straight.
I'm aiming for the PhD at Queens, I really hope it works out. Computational Biology or Financial Engineering.





Mustafa Ismail Mustafa wrote: Financial Engineering
Interesting you brought that up  since I am a "financial engineer". I would counsel you not to go into it. There have been huge layoffs (150,000+) in the wake of the financial crisis and investment banks are decreasing their activity in this area as most are being merged with their deposit side activities. Combine that with calls for increased regulation of the financial markets and derivatives and the number of jobs available for financial engineers will see a marked decrease.
I am trying to get out of the field myself and it is proving very difficult to find a job. The profession is currently very unpopular  nobody wants to be associated with those thought to be behind the credit crisis.





Really?
I'd have thought that it would pick up after the recession, besides, wouldn't that actually help the financial institutions get back on their feet faster?
I prefer going into Computational Biology, specifically into the modeling and forecasting of diseases and/or chemical reactions in biological entities systems.
You've given me food for thought.
In either case, because of the financial crisis, in the States, many universities have cut down the number of PhD students that they're willing to take on, but come this summer, I'm leaving Jordan to either carry on with the PhD or to get a better paying job in [western] Canada.





Yes. All investment banks are cutting back their quantitative positions. The increased regulation will mean more routine uses of derivative products and less need for people with quantitative backgrounds to invent new products.
It's already happening. In Zurich, for example, there are thousands with backgrounds in financial engineering on the job market. For each job posting they are getting so many applications they can't handle them all. Even the headhunter organizations are telling me not to expect anything until late next year at the soonest and, even then, there will be huge competition for limited positions  those with the most experience will be taken first. It's terrible. Most banks are waiting to see what the "new system" will mean for their risk management operations. That could be two years or more before there's a solid draft and implementation.
I'm trying to get into financial regulation so that when the banks start hiring I'll have some experience.
And it's worse in the U.S. The number of unemployed is in excess of 150,000.





Would you mind if I emailed you later on tonight when I get back home? I'd like to discuss this in greater detail if you don't mind. I would so totally appreciate it.





No problem. I'm GMT+1, so my response could be delayed due to time difference.





Great, I'm GMT +2 so we should be fine





how to calculate shortest path between houses. answer must take into account fully laden sleigh and naughty/nice rating of occupants. urgent!
CODE PLEASE!
Merry Christmas CodeProject





Mark Churchill wrote: how to calculate shortest path between houses
Dijkstra's algorithm for the nice! The longest path algorithm for the naughty!
( Is this a homework question? )
It's a bit past Christmas, so Happy Holidays, Mark!





modified on Monday, February 9, 2009 7:30 PM





I have a problem I can't seem to figure out. I'm trying to code an algorithm which calculates the longest path(s) from a given list of nodes and their neighbor nodes. I've learned a little bit about Djikstra's and the "traveling salesman" algorithms but those are both meant to calculate the shortest distance between two points. The problem statement would basically be "Given a list of nodes and their neighboring nodes (all one unit away), calculate the longest path(s) that can be taken using any given 'segment' only once in each path."
Here's an example. Given this list:
Node : Neighboring Node,Neighboring Node,Neighboring Node
0 : 1,2,9
1 : 0,5,6
2 : 0,3,1
3 : 2,4,1
4 : 3,5,1
5 : 4,1,1
6 : 1,7,1
7 : 6,8,1
8 : 7,9,1
9 : 8,0,1
('1' means no neighboring node)
the algorithm should output:
"015432098761"
"016789023451"
"023451098761"
"023451678901"
"098761023451"
"098761543201"
"102345167890"
"109876154320"
"154320167890"
"154320987610"
"167890154320"
"167890234510"
I've been trying to code this in VB6 but it's gotten very messy and I think I'd like to try coding it in Python to get it working and then convert it to VB6.
My current method starts at a node and "jumps" to a neighbor node until it reaches a node that's already been used once in the current path, and then jumps backwards until it reaches a threeneighbornode and takes the second "fork" of that node until it reaches that end. It does this until it's jumped all the way back to the starting node, and then it chooses another starting node and runs again until all threeneighbor nodes have been started from. I guess it's similar to a treesearching algorithm except the branches can connect to each other.
I've spent a while Googling and haven't found much  most articles I've found deal with finding the shortest path. Any help would be appreciated!





Since you are using a sequence of nodes, you can use the constraint that no node in a potential path can be the same as the previous node. Then objective function is the length of the path.
I dug up some pseudocode:
Pseudocode for Longest Path
Nodes of graph have integer names
Node Extensible( sequence s )
Boolean found, Node endpoint
p = EndOfPath(s)
Set Inpath(x) = true for any x in s
y = LastUsed(p)+1
found = false, q = y
While q <= number of vertices And Not found
found = Not InPath(q) And IsEdge(p, i)
If Not found Then q = q + 1
End While
If Not found Then
Extensible = 1
Else
Extensible = q
End If
Sequence Truncate( sequence s )
'Reset Lastused for EndofPath of s and remove EndofPath
p = EndOfPath(s)
// p will be removed so reset Lastused
Lastused(p) = 0
If s.length = 1 then
// choose new start vertex
Truncate = s+1 // s is integer name for old start
Else
Truncate = all but last node of s
End If
Sequence Extend( sequence s )
p = EndOfPath(s)
q = Extensible(s)
If q = 1 Then
If s.Length > s*.Length Then s* = s
// backtrack
Extend = Truncate( s )
Else
Lastused(p) = q
Extend = s + q
End If
End If





In your pseudocode, when finding the next node to jump to, it says:
73Zeppelin wrote: // now find first vertex which is :
// not in use in s
// adjacent to p
// >= y
If I'm reading that correctly it will only use nodes which have not already been used in the current path. However, it shouldn't matter how many times any particular node is used but rather how many times each "road" between nodes is used.
In my example, "015432098761" was a valid path. Node '0' is used twice, but each "road" leading to each of its three neighbors is used only once (01,20,09). Am I understanding your pseudocode correctly?
One more question  what does
73Zeppelin wrote: If s.Length > s*.Length Then s* = s
do? Thanks!





zenerguy32 wrote: If I'm reading that correctly it will only use nodes which have not already been used in the current path. However, it shouldn't matter how many times any particular node is used but rather how many times each "road" between nodes is used.
In my example, "015432098761" was a valid path. Node '0' is used twice, but each "road" leading to each of its three neighbors is used only once (01,20,09). Am I understanding your pseudocode correctly?
Ah, okay. Yes, the algorithm allows traversal through a vertex only one time. You are allowing multiple traversals?
zenerguy32 wrote: 73Zeppelin wrote:
If s.Length > s*.Length Then s* = s
do? Thanks!
This is just used for backtracking.





Correct  I am allowing multiple traversals through each node, but only one traversal using each "road" (for any given path).





hi
I want to implement data versioning in a application...
I need a Delta algorithm component.
where can I find it?
thanks.





mkhansari wrote: hi
I want to implement data versioning in a application...
I need a Delta algorithm component.
where can I find it?
thanks.
Google, maybe?





thanks very very very much
who can help me such as you?
Mohammad Khansari





Hi,
I have a double value describing rotation angle for a text box object. I need to convert it to quaternion. I have searched the web, and all I get is converters that conver Euler angle to Quaternion.
I would appreciate any formulae or algorithm.
And this double value is the only information I have for rotation.
Regards,
Shoaib
Its never over !





shaibee wrote: have a double value describing rotation angle for a text box object. I need to convert it to quaternion. I have searched the web, and all I get is converters that conver Euler angle to Quaternion.
I would appreciate any formulae or algorithm.
And this double value is the only information I have for rotation.
You want to convert an axis angle, for example? A rotation around an axis in space can be converted to a quaternion Q(w,x,y,z) . If the rotation is given by a unit vector (ax, ay, az) and the angle theta is in radians, then the conversion is:
w = cos(theta/2)
x = ax * sin(theta/2)
y = ay * sin(theta/2)
z = az * sin(theta/2)
Make sure the axis is normalized before conversion. If there is no rotation, the quaternion is the rotation identity quaternion.





73Zeppelin wrote: rotation is given by a unit vector (ax, ay, az) and the angle theta is in radians
I believe I have theta , but I dont see any vector provided along with in the information object that I have. All it says is "angle in radians rotated from +ve world xaxis". Does this indicate any default vector that I can use for this conversion?
Its never over !





So it's a rotation about the xaxis? This means the rotations around the other axes can be taken as zero. So your rotation vector would be:
(ax, ay, az) = (theta, 0, 0)
Don't forget to convert to a unit vector[^] if necessary.





Semantics:
write_item(X): is the operation of writing the value of record X in the database read_item(X): is the operation of reading the value of record X in the database TS(T) : is the Time Stamp of a transaction in the database, each transaction may include many operations before it is either committed or rolledback, e.g. write_item(X), read_item(Z), write_item(W) write_TS(X): is the TS(T) of transaction T that has successfully written record X read_TS(X): is the TS(T) of transaction T that has successfully read record X
Strict time stamp ordering
// read_item(X) by T read_item(X) {
while(true) { if( write_TS(X) > TS(T) ) { abort(T); // break or return } else if( write_TS(X) < TS(T) ) { wait until the transaction T', which TS(T) > TS(T'), has either committed or aborted; // write_TS(X) == TS(T') continue; } else { read_item(X); read_TS(X) = max{ read_TS(X), TS(T) }; break; // or return } } }
// write_item(X) by T
write_item(X) { while(true) { if( write_TS(X) > TS(T)  read_TS(X) > TS(T) ) { abort(T); // break or return } else if( write_TS(X) < TS(T) ) { wait until the transaction T', which TS(T) > TS(T'), has either committed or aborted; // write_TS(X) == TS(T') continue; } else { write_item(X); write_TS(X) = TS(T); break; // or return } } }
<div class="ForumMod">modified on Wednesday, December 17, 2008 4:16 PM</div>





What do you want help with? You didn't actually ask a question.





I apologize for not providing the question.
The question is:
Is this pseudocode correct regarding the strict time stamp ordering protocol ? ( Strict TS protocol is used for ensuring conflict serializability, recoverability and cascade less rollbacks )
Some background knowledge ( I hope this to clarify things):
1 ) Conflict serializability > This is ensured by the basic time stamp protocol 2 ) But the basic TS protocol does not ensure (1) recoverability and (2) cascadeless rollbacks. 3 ) This is were "strict" steps in and ensures the aforementioned 2 features.
e.g. Transactions TS(T1)<TS(T2)<TS(T3)
Assume that TS(T2) has performed a write_item(X) and has committed. Additionally, let us assume that TS(T3) performed the following 2 operations after the previous commit: Y=Y+X write_item(Y) but has not committed yet.
Then, transaction T1 does attempt to perform a write_item(X).
The basic time stamp protocol will force transaction T1 to abort (rollback), because TS(T1) < write_TS(X), write_TS(X) == TS(T2)
However, since the transaction T2 has committed it is not recoverable through a rollback anymore. Furthermore, transaction T3 has to be rolledback as well. If another transaction T4 had based its writes on T3 then it should also be rolledback. This is were cascading rollbacks happen.
Thanks, for using your time to answer my question.





/ write_item(X) by T
write_item(X)
{
while(true)
{
if( write_TS(X) > TS(T)  read_TS(X) > TS(T) ) {
abort(T); }
else if( write_TS(X) < TS(T) )
{
wait until the transaction T', which TS(T) > TS(T'), has
either committed or aborted; continue;
}
else
{
write_item(X);
write_TS(X) = TS(T);
break; }
}
}
Hmmm, on the indicated line above, shouldn't that be AND and not OR? Also, you might want to consider what would happen if the timestamps were equal.
Also, just to be clear, to avoid cascading rollbacks, you should only be reading committed values. So, given all that, shouldn't the pseudocode look more like this:
if t >= wmax(X)
rmax(X) < max(t, rmax(X))
wait for a committed value of X
perform read
else
abort
if t >= rmax(X) and t >= wmax(X)
wmax(X) < t
wait until X value is a committed value and
pending reads are done
perform write
else
if t < rmax(X)
abort
else
do nothing





I have studied your answer carefully and your remarks are quite insightful. I will incorporate them while implementing the algorithm.
Your willingness to answer my question is greatly appreciated.
Thanks!




