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.
Write a pseudo code for an O (n7log3n) algorithm. Please write in C++.
Write a pseudo code for an O (n7log3n) algorithm. Please write in C++.
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...
1. Write an algorithm to calculate the Matrix multiplication (or write with pseudo code) 2. Write...
1. Write an algorithm to calculate the Matrix multiplication (or write with pseudo code) 2. Write an algorithm to calculate the recursive Matrix multiplication (or write with pseudo code) 3. Find the time complexity of your pseudo code and analyze the differences
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...
Given a BST and a sum, write pseudo code to determine if the tree has a...
Given a BST and a sum, write pseudo code to determine if the tree has a root- to-leaf path such that adding up all the values along the path equals the given sum. Given the below BST and sum = 49, the array is (8, 4, 10, 1, 0, 3, 9, 15, 16). Return true, as there exist a root-to-leaf path 8− > 10− > 15− > 16 which sum is 49.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT