A heuristic function for 3 Water Jug [closed] - artificial-intelligence

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I've question to ask you guys.
I'm a newbie in Artificial Intelligence. I want to solve water jug problem(3 jugs - 3 lt, 5lt, 9lt - Trying to get 7lt) using A* search.
I need a heuristic function to implement the solution, but I can't find a good heuristic f(n) so that the algorithm will find the least steps to the solution.

So given your parameters the non-heuristic way of solving this problem is:
0) Fill the 9 liter jug
1) Pour the 9 liter jug into the 5 liter jug, this leaves 4 liters in the 9 liter
2) Fill the 3 liter jug
3) Pour the 3 liter jug into the 9 liter jug and the problem is solved
So looking at this you will have a graph that has nodes that can be in one of two states: Pour or Fill . You then assign to each node a weight that represents the amount of liquid you will get from it, 1,2,3,etc . There should be no division involved, you just need to make it "expensive" to use specific operations.

Related

How to implement Foulke's algorithm in C [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Foulke's algorithm is defined by
(In + U)2 = In+ U + U2
with:
In : the identity matrix
U : square adjacent matrix
I want to implement this algorithm in C by recurrence.
Any help is appreciated.
Your formula is wrong. Substitute U with identity matrix and you will see that the equality does not hold. You need to change it to (In + U)^2 = In+ 2*U + U^2. Just like numbers. Makes sense, huh?
Otherwise all you need to do is to implement a function that multiplies to two-dimensional matrices and returns the result in a two-dimensional array. I don't think using recursion for this problem is a good option.
I recommend you to use BLAS library. Or you want to make all yourself without any algebra-library?

How to write a C program of two bodies exerting a gravitational force on each other? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I 've been set the following problem and don't have a clue how to start any help would be much appreciated.
In 2-D, read in the initial positions, velocities and masses of two bodies (suns, stars etc) . You will need to define suitable units for these. Then using the gravitational equation, calculate the force on each body from the other, and use Newton’s 3rd law to calculate the acceleration of that body. Generate a file with the positions of both bodies at each timestep for a long time period. Use this file to plot the paths of the two bodies.
Store the initial position, velocity and masses.
Calculate the magnitude and direction of the gravitational force.
Knowing the force, you can calculate the acceleration of each body.
Knowing the acceleration you can calculate the new velocity.
Knowing the velocity you can calculate the new position.
Using suitably small time steps you can get a reasonably good approximation to continuous motion.

database design and algorithm for Public Transport? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
We want to implement Public Transport Guide for Android.
Inputs will be beginning and destination point. Outputs will be the directives that
tell how can be gone to the destination with using buses, subways,... e.c
This is not easy for big cities and we must have a well-designed database for quick answer. Tranport algorithm must give optimum lines to the passanger.
I wanna see your precious ideas for database and algorithm design.
Thank you very much for answers.
Most likely you will need a graph there to calculate shortest path.
Your graph will be G=(V,E) such that V = {all possible stations} and E = {(u,v) | there is a transport connecting station u to station v}.
If your graph cannot fit into memory [which is probably the case for a big city], you might want to make a function successors(u) = { v | (u,v) in E } which will allow you to calculate the graph on the fly.
In this older question there is some discussion how to efficiently find a path between two vertices in a dynamic environment similar to the one you are describing.

database size question [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
How much database space would you need to hold user information for 100,000 users?
That depends heavily upon what information you hold.
If it's a username, an MD5 of a password, and a few short fields, I'd say:
6 + 32 + 5 x 200 = 1,038 bytes ~ 1,040 bytes
So for 100,000 records, I'd say that:
1,040 x 100,000 = 104,000,000 ~ 100,000,000 bytes
Which is around 100 mb.
Not that much.
100,000 times the amount of database space you would need for 1 user.

C: Multiple timers [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I want to have more than two timers. Each timer has its own precision. I have read that I can just have one timer, is this accurate? Is there any way to have more than one?
You can multiplex a single timer to simulate multiple timers.
You will need program the real timer to go off at the GCD (greatest common denominator) of the times you require:
For example:
timer1 - every 12 seconds
timer2 - every 18 seconds
GCD(12,18) = 6
realtimer - every 6 seconds
if (time % 12 == 0)
{
invoke_timer_1();
}
if (time % 18 == 0)
{
invoke_timer_2();
}
// if neither, do nothing

Resources