Commit eda994db authored by robin.requadt's avatar robin.requadt
Browse files

Upload New File

parent b64c917c
"""
% GRAAL.m
% written on Aug 18, 2017 by
% Russell Luke
% Inst. Fuer Numerische und Angewandte Mathematik
% Universitaet Goettingen
%
% DESCRIPTION: user-friendly version of Malitskyi's Golden-Ratio algorithm
%
%
% INPUT: u, an array, and method_input, a data structure
%
% OUTPUT: method_input, an appended data structure with
% xnew = the algorithm fixed point
%
% USAGE: [xnew, method_input] = GRAAL_simple(x, method_input)
%
% Nonstandard Matlab function calls: method_input.Prox1 and .Prox2
%
% ---
% Golden Ratio Algorithm for the problem x = Tx
%
% T is the operator
% J is the energy which we want to check, like |x-x*|
% x0 is the starting point
%
% ---
"""
import numpy as np
from .GRAAL_F import GRAAL_F #GRAAL_F.py needed
from .SimpleAlgortihm import SimpleAlgorithm
class KM(SimpleAlgorithm):
def __init__(self,config):
"""
Parameters
----------
config : dict
Dictionary containing the problem configuration.
It must contain the following mapping:
Fx : float
"""
self.Fx = config['Fx']
if 'GRAAL_initialized' not in config:
self.bool = False
if 'phi' not in config:
phi = 1.4
self.phi = phi
else:
self.phi = config['phi']
phi = self.phi
if 'inv_Lipschitz_const' not in config:
la = 0.5
else:
self.inv_Lipschitz_const = config['inv_Lipschitz_const']
la = self.inv_Lipschitz_const
else:
self.bool = True
def evaluate(self, x):
if (self.bool == False):
self.x = x
self.xbar = self.x
self.tau = 1. / phi + 1. / phi**2
# F = lambda x: x - T(x)
# GRAAL_F does:
# Fx1 = x-T(x)
self.Fx= GRAAL_F.evaluate(x)
self.th = 1
self.inv_Lipschitz_const=la
self.GRAAL_initialized=True
x1=x
xnew=x1+999
else:
x1 = x - self.Fx
Fx1 = GRAAL_F.evaluate(x1)
# GRAAL_F does:
# Fx1 = x1-T(x1);
self.Fx=Fx1
xnew=x1
return xnew
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment