Which optimization method acheieves the best performance

Assignment Help Computer Engineering
Reference no: EM131097833

E19: Numerical Methods for Engineering Applications Spring 2016 - PROJECT 4

Project: Benchmarking gradient-free optimizers

OVERVIEW

In this project, you will investigate the effectiveness of several gradient-free optimization techniques in solving a particular optimization problem: lossy image compression.

BACKGROUND

For this project, we will approximate a grayscale image using a sum of k 2D Gaussian functions. Each Gaussian function has six parameters influencing its shape, size, location, rotation, and intensity. Therefore, the overall image may be approximated by 6k numbers. Contrast this to the "traditional" method of representing a w-by-h image as a list of pixel intensities - if our Gaussian functions approximate the image well, and if 6k << w x h, we have effectively compressed the image by representing it with a much smaller list of numbers.

Our objective function f(x) for this optimization problem will be the sum of squared differences in pixel values between the original image and the Gaussian reconstruction. We will investigate how this objective is minimized by three different optimization methods: greedy hill climbing2, the Nelder-Mead method (which we discussed in class), and finally, Powell's method (which you will research on your own). Furthermore, since the objective function allows us to select different values of k, we can investigate how each method's performance scales with problem size.

Your goal is to generate a number of random intial x vectors for a variety of values of k, and test the performance of all of the methods on each vector. FYI, the function scipy.optimize.minimize() can be used to run either Nelder-Mead or Powell by passing in the appropriate method parameter.

DISCLAIMER

Real-life image compression (e.g. JPEG) doesn't work this way - it's much cleverer. We are just hacking together a silly representation of a compressed image that lets us play with optimizers!

TASKS

Download the starter code from the course website. It contains a very useful base for generating and visualizing sums of Gaussian functions as images.

Implement the objective function. Look at the portion of the starter code which maps the vector of parameters x to the resulting objective function value (on lines 167-174).

Your first task should be to wrap up all of the variables besides x (e.g. xmesh, ymesh, target) into a Python lambda object f which accepts x as input and provides the objective function value as output. Remember, since we are using lambdas, there is no need to define any new functions with the def keyword to define a function, or to use global variables anywhere!

Implement a mutation function, and run the hill climbing algorithm. Now create a lambda object called mutate which takes single parameter vector x as input and which outputs a perturbed version by calling the perturb_params function (your lambda should wrap up the w and h parameters required by this function).

Once you have f and mutate, you should be able to do the hill climbing method by passing these lambdas to the greedy_random_hillclimbing function. Try running it on a smallish (k = 5) parameter vector for a small number of iterations (perhaps 100 or so). Although the results will not substantially resemble the input image, you should at least be able to verify that the objective function is decreased by this function.

Benchmark the three methods on the image problem for k = 8, 16, and 32. For each value of k, test each algorithm 10 times on a new initial randomly generated vector. You should limit the number of function evaluations to 10,000. For hill climbing, this is passed in as a parameter to the function; for the others, you should provide options=dict(maxfev=10000) to the scipy.optimize.minimize function.

The results of your benchmarks should be summarized by including all of the following in your PDF write up:

  • a set of bar graphs (with standard error bars) showing the mean runtimes of each optimization method as k is varied
  • a set of bar graphs (with standard error bars) summarizing the objective function values obtained by each method as k is varied
  • a set of representative images of the best and worst outputs of each optimization method (you can use matplotlib.pyplot.savefig to save figures)

Go further Take your lab a bit further by trying out one of the following ideas (or approach me if you are interested in coming up with your own idea):

  • Research one of the other methods implemented by scipy.optimize.minimize and tell me what you discovered.
  • Try out these optimizers on your own Engineering-inspired unconstrained multivariable minimization problem.
  • Try to modify the program to compress a color image (see me for help).

WHAT TO TURN IN

You should submit all of your source code along with a PDF write-up containing your plots and answers to these questions (a few sentences on each should suffice).

  • Which optimization method acheieves the best performance, and why? You may find it instructive to flip through the first few slides at https://informatik.unibas.ch/fileadmin/Lectures/HS2013/CS253/PowellAndDP1.pdf to learn a bit about Powell's method in order to explain the results.
  • Which method is slowest? Fastest? Explain why you think that might be the case.
  • Would it be theoretically possible to use a non-linear least-squares solver such as the Gauss-Newton method to solve this image compression problem? If so, why might we still prefer to use a method like Powell or Nelder-Mead? If not, why not?

Attachment:- Assignment.zip

Reference no: EM131097833

Questions Cloud

What is the efficient level of production of the public good : There are three consumers of a public good. The marginal willingness-to-pay for the consumers are as follows: What is the efficient level of production of the public good?  What is the efficient level of production of the public good? Propose an alte..
Discount on trade credit agreement : Alternative A: Forgo the discount on its trade credit agreement, wait and pay the full $12,500 in one month.
What are the implications for the client : Do you need anymore information? If so, what - should you send the client to a mental hospital for a psychological evaluation? If you do, what are the implications for the client?
Learned about the rhetorical triangle : Read this Smithsonian.com article by LyNell Hancock. Then use what you have learned about the Rhetorical Triangle, the four lines of argument, and the Lesson on Focus to write an analysis of its rhetoric in 1.5 pages or less.
Which optimization method acheieves the best performance : E19: Numerical Methods for Engineering Applications Spring 2016 - PROJECT 4. Which method is slowest? Fastest? Explain why you think that might be the case. Which optimization method acheieves the best performance, and why
First monthly payment will go toward the principal : Solve the problem. Round to the nearest cent as needed. The monthly payments on a $80,000 loan at 10% annual interest are $859.68. How much of the first monthly payment will go toward the principal?
Billy bob wants to gain some weight : Billy Bob wants to gain some weight so that he can play football. Billy eats only milkshakes and spinach. Milkshakes cost him $1 each and spinach costs $2 per serving. A milkshake has 850 calories and a serving of spinach has 200 calories. Billy Bob ..
Working capital management : Why is working capital management one of the most important time - consuming activities of the financial mangar? What is net working capital?
Create a presentation about a career-interest area : Create a multimedia presentation in which you will present information about a career-interest area or field of study interest. In addition, write a reflective paragraph about the product and process.

Reviews

Write a Review

Computer Engineering Questions & Answers

  What stack elements remain

suppose a stack-oriented processor that includes the stack operations PUSH and POP. Arithmetic operations automatically involve the top one or two stack elements. Begin with an empty stack.

  Illustrate the control flow graph

Illustrate the control flow graph

  Evaluate the usability of the online questionnaire website

Write clearly and concisely about human-computer interaction topics using proper writing mechanics and technical style conventions.

  What are two merits and two challenges which might be faced

based on the barr 2013 article what are three possible ways that streaming media can be used to accomplish the

  Questionmake an xml file in visual studio that contains the

questionmake an .xml file in visual studio that contains the exact same information. name files

  Prepare a program to sorts the array into decreasing order

Write a program that inputs the 20 incomes into an array and then sorts the array into decreasing order - Prepare a program to sorts the array into decreasing order.

  How many independent memory channels should be provided

how many independent memory channels should be provided so the system is not limited by memory bandwidth if the bandwidth required is sometimes twice the average?

  Choose third-party control available for visual basic.net

choose a third-party control available for Visual Basic.NET. Discuss how this control is used in an application. What are the advantages and disadvantages of using third-party controls in your applications.

  Discuss the facilities and services provided by pioneer

I'm having a trouble with a local Pioneer hospital that has just moved to the brand new location. The Pioneer hospital has decided to use Windows 2003 for its computing environment. I have been hired to lead  implementation, management, and mainte..

  What are the ramifications of the parts that are missing

What are the ramifications of the parts that are missing? What should be done to improve the process (if anything)?

  Questiona assume a computer has a maximum memory size of

questiona assume a computer has a maximum memory size of 4mb. what is essential address field width?b assume a computer

  Describe a process of making it more widely

Conflict-management techniques allow managers to control conflict levels (not only decrease but also increase them). choose a problem that disturbs you and is not solved.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd