Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: hello ,have a good day all , i need some answers of these questions...

1. ## hello ,have a good day all , i need some answers of these questions...

1. Operator effect definition:
oi,j ((a1 , a2 , . . . , a12 )) = (b1 , b2 , . . . , b12 )
k = 1, 2, . . . , 12
if (a1 , a2 , . . . , a12 ) ∈ dom(oi,j )
bk =
ak + j
ak + 120
if ∃l(al > ak ) ∨ (ak + ai = 0)
otherwise
Exercise 4. Create the Java implementation for the function above as a body of a void function!
We suppose that a1 , a2 , . . . , a12 are integers, and they are accessible in the function body as a[1], a[2],
. . ., a[12], and b1 , b2 , . . . , b12 are integers, and they are accessible in the function body as b[1], b[2], . . .,
b[12].

2.

Set of operators:
O = {o1,2 , o1,3 , o2,1 , o2,3 , o3,1 , o3,2 }
Domain of operators:
dom(oi,j ) = {(a1 , a2 , . . . , a12 ) ∈ N12 | ∀k((k = j) ⊃ (ak + i > aj )) ∧ ∃k∃l(a1 = ak ∗ al )}
Exercise 3. Create the Java implementation for the preconditions above as a body of a boolean
function! We suppose that a1 , a2 , . . . , a12 are integers, and they are accessible in the function body as a[1],
a[2], . . ., a[12].

3.

Set of goal states:
G = {(a1 , a2 , . . . , a12 ) ∈ N12 | ∀i∃j((ai + aj > 20) ⊃ (ai ∗ aj < 200))}
Exercise 2. Create the Java implementation for the goal condition above as a body of a boolean
function! We suppose that a1 , a2 , . . . , a12 are integers, and they are accessible in the function body as a[1],
a[2], . . ., a[12]

4.

∀i(∃j((aj < ai ) ∨ (aj = 1000)) ⊃ (ai > 0) ∨ ∃j(aj = 50))
where i ∈ {1, 2, . . . , 6} and j ∈ {1, 2, . . . , 6}
Exercise 1. Create the Java implementation for the formula above as a body of a boolean
function! We suppose that a1 , a2 , . . . , a6 are integers, and they are accessible in the function body as a[1],
a[2], . . ., a[6].

5.

1.all i exists j a[i] > a[j] or a[1] = a[4]

all i ( exists j ( (a[j] < a[i]) or not (a[j] = 1000) ) implies ( a[i] > 0 or exists j ( a[j] = 50 ) ) )

implementation in java :

------------------------------------------------------------------------------------------------

Complete the Java implementation of the Breadth-first search

Exercise 1. Initialize the database.
Exercise 2. Construct the solution as an operator list.
Exercise 3. Complete the code of the extension.

public interface Problem {
State startState();
Collection<Operator> operators();
}
public interface State {
boolean isGoal();
}
public interface Operator {
boolean isApplicable(State s);
State apply(State s);

}

public abstract class Solver {
private static class Node {
State state;
Operator creator;
Node parent;
int deep;
public Node(State state, Operator op, Node parent ) {
this.deep = parent == null ? 0 : parent.deep + 1;
this.creator = op;
this.parent = parent;
this.state = state;
}

}
public List<Operator> run(Problem p) {
/* Exercise 1: Initialize the database. */

while ( ! openNodes.isEmpty() ) {
Node node = openNodes.removeFirst();
if ( node.state.isGoal() ) {
/* Exercise 2: Construct the solution as an operator list. */

return solution;
}
for ( Operator op : p.operators() ) {
if ( op.isApplicable(node.state) ) {
State newState = op.apply(node.state);
/* Exercise 3: Complete the code of the extension

* (use the search function below when necessary). */
}
}
}
return null;
}
private static Node search(List<Node> nodeList, State state) {
for ( Node node : nodeList )
if ( state.equals(node.state) )
return node;
return null;
}
}

2. ## Re: hello ,have a good day all , i need some answers of these questions...

Welcome sahin11
Please see the Announcements page for the use of code tags when posting code to the forum.
If you have some questions of your own, and not those of your assignment, please post them.