Problem with welfare loss

Hi all:

I establish a log linearized model. I try to calculate the welfare loss under different monetary policies and search for the opitmal policy. What kind of method can achieve this goal?How would the code look like?If there is an example, that will be better.
Thanks in advance

What exactly is your problem? And which type of optimal policy are you considering? The example

comes to mind.