<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Playing with the PyUNLocBoX
https
Step1:  1 Solve an optimization problem
Following is a typical usage example who solves an optimization problem composed by the sum of two convex functions. The functions and solver objects are first instantiated with the desired parameters. The problem is then solved by a call to the solving function.
Step2:  2 Define your own objective function
In addtion to the functions available in pyunlocbox.functions, you can define your owns like below.
Step3:  Likewise, you can implement your owns solvers and acceleration schemes by sub-classing pyunlocbox.solvers.solver and pyunlocbox.acceleration.accel.
3 Tutorials
Try our tutorials.
Step4:  4 Playground
Try something of your own!
The API reference is your friend.
Step5:  If you miss a package, you can install it with
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from pyunlocbox import functions, solvers
plt.rcParams['figure.figsize'] = (17, 5)
Explanation: Playing with the PyUNLocBoX
https://github.com/epfl-lts2/pyunlocbox
End of explanation
f1 = functions.norm_l2(y=[4, 5, 6, 7])
f2 = functions.dummy()
solver = solvers.forward_backward()
ret = solvers.solve([f1, f2], [0., 0, 0, 0], solver, atol=1e-5)
ret['sol']
plt.semilogy(np.array(ret['objective'])[:, 0], '.-');
Explanation: 1 Solve an optimization problem
Following is a typical usage example who solves an optimization problem composed by the sum of two convex functions. The functions and solver objects are first instantiated with the desired parameters. The problem is then solved by a call to the solving function.
End of explanation
class myfunc(functions.func):
    def __init__(self, myparam=1, **kwargs):
        self.myparam = myparam
        super(myfunc, self).__init__(**kwargs)
    def _eval(self, x):
        return 0  # Function evaluated at x.
    def _grad(self, x):
        return x  # Gradient evaluated at x, if available.
    def _prox(self, x, T):
        return x  # Proximal operator evaluated at x, if available.
f = myfunc(myparam=2)
f.cap([0, 0])
Explanation: 2 Define your own objective function
In addtion to the functions available in pyunlocbox.functions, you can define your owns like below.
End of explanation
# Your code here.
Explanation: Likewise, you can implement your owns solvers and acceleration schemes by sub-classing pyunlocbox.solvers.solver and pyunlocbox.acceleration.accel.
3 Tutorials
Try our tutorials.
End of explanation
# Your code here.
Explanation: 4 Playground
Try something of your own!
The API reference is your friend.
End of explanation
%pip install numpy
Explanation: If you miss a package, you can install it with:
End of explanation
<END_TASK>