Ask Computer Engineering Expert

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 http://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

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91844562

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As