Question

In: Computer Science

(Artificial Intelligence) Write a pseudo code for the following: Regular Hill Climbing with steepest ascent

(Artificial Intelligence)

Write a pseudo code for the following:

Regular Hill Climbing with steepest ascent

Solutions

Expert Solution

As per the question, you have asked only the Pseudo code. So I have provided a running code which will help you to test and run the program and I have marked the main logic. Please refer to the image attached for proper indentation.

As the steepest ascent Hill Climbing is the variation of the simple hill-climbing the program is written below:

import random 
import string 
#  Package Imported

# for the best solution to get in
def random_data(length=13): 
    return [random.choice(string.printable) for _ in range(length)] 
 
 #Pseudo code for the main method to get implement
def data_evaluate(solution): 
    outcome = list("Hill, Climb") 
    diff = 0
    for i in range(len(outcome)): 
        s = solution[i] 
        t = outcome[i]
        diff += abs(ord(s) - ord(t)) 
        return diff 
 #data_evaluate provide the distance between two string --> Hill and Climb
 
def data_best(solution): 
    number = random.randint(0, len(solution) - 1) 
    solution[number] = random.choice(string.printable) 
 
 #basis structure or Skeleton of the code
best = random_data() 
data_score_best = data_evaluate(best) 
 
while True: 
    print('Best Score', data_score_best, 'Outcome', "".join(best)) 
 
    if data_score_best == 0: 
        break
 
    data_sol = list(best) 
    data_best(data_sol) 
 
    Score_output = data_evaluate(data_sol) 
    if data_evaluate(data_sol) < data_score_best: 
        best = data_sol 
        data_score_best = Score_output

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

Hope you got it!! You can try different string for different distance. Thank you


Related Solutions

Use the method of steepest ascent to approximate the optimal solution to the following problem: max⁡...
Use the method of steepest ascent to approximate the optimal solution to the following problem: max⁡ z=-(x1-2)^2-x1-(x2)^2 . Begin at the point(2.5,1.5) (p.s. The answer already exists on the Chegg.Study website is incorrect)
What are the trends of Automation and Artificial Intelligence in the Automotive Industry? Write down in...
What are the trends of Automation and Artificial Intelligence in the Automotive Industry? Write down in at least 1000 words with references.
What will be the expected output of the following pseudo code? Write exactly what would display...
What will be the expected output of the following pseudo code? Write exactly what would display when you execute the statements. Module main() Declare Integer a = 5 Declare Integer b = 2 Declare Integer c = 3 Declare Integer result = 0 Display "The value of result is" Display result Set result = a + b * c - a Display "Changed value is: ", result End Module
For the following program descriptions, write step by step pseudo code that shows you understand the...
For the following program descriptions, write step by step pseudo code that shows you understand the problem and what it takes to solve it. The first one is done for you as an example. Please answer the questions in the same format as the example problem below so it is the same. Example #1 Problem A customer is purchasing five items. Design a program where you collect the amount of each item, calculate the subTotal of the items, the tax...
Write 10 pages on the role that play the artificial intelligence in the healthcare patient management...
Write 10 pages on the role that play the artificial intelligence in the healthcare patient management systems.
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x +...
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x + y – z + A[j] x and y should be in reserved memory words using the .word directive and labeled as x and y. Initialize x=10 and y=200. Read in z from the console. Input the value -8. This is the value for z, not for –z. Store this value in memory with the label z. To begin, you could just initialize z to...
A customer in a grocery store is purchasing three items. Write the pseudo code that will:...
A customer in a grocery store is purchasing three items. Write the pseudo code that will: • Ask the user to enter the name of the first item purchased. Then ask the user to enter the cost of the first item purchased. Make your program user friendly. If the user says the first item purchased is milk, then ask: “What is the cost of milk.” [This should work no matter what item is entered by the user. I might buy...
Artificial Intelligence Opinion Paper For this assignment I want you to write an opinion paper on...
Artificial Intelligence Opinion Paper For this assignment I want you to write an opinion paper on whether you believe AI - artificial intelligence, is ever going to become as sophisticated as the human mind. In your paper you should cite 2-3 sources (websites, research articles, etc) that help support your thought process. The paper should be 2-3 pages long, 12-point font, double spaced.
Write pseudo-code to solve the following problem using MapReduce and explain how it works. Each line...
Write pseudo-code to solve the following problem using MapReduce and explain how it works. Each line in the file lists a user ID, the ID of the movie the user watched, the rating the user gave for the movie, and the timestamp. For example line 1 indicates that the user’s ID is 196, the movie ID is 242, the user gave this movie a rating of 3, and the timestamp is 881250949. Given the file, find out the top similar...
Write a recursive algorithm in pseudo-code to compute the “power list” of a given list of...
Write a recursive algorithm in pseudo-code to compute the “power list” of a given list of integers. Assume that the List type has members: int List.length returns the length of the list. void List.push(T n) pushes an element n to the front of the list T List.pop() pops an element from the front of the list. List$$ List$$.concat(List$$ other) returns the concatenation of this list with other. Explain in plain English the reasoning behind your algorithm. Power Lists should be...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT