Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/ruqihuang/AdjointFmaps
28 May 2025, 19:07:31 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
Revision d41efaa1636fb8cc0da8f09d89f4a1cae0172320 authored by ruqihuang on 24 August 2017, 07:39:27 UTC, committed by ruqihuang on 24 August 2017, 07:39:27 UTC
Update readme
claim that the package is only pre-compiled for Mac
1 parent 702a390
  • Files
  • Changes
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • d41efaa1636fb8cc0da8f09d89f4a1cae0172320
    No releases to show
  • cece858
  • /
  • external
  • /
  • minconf
  • /
  • minConf_QNST.m
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
  • snapshot
origin badgerevision badge
swh:1:rev:d41efaa1636fb8cc0da8f09d89f4a1cae0172320
origin badgedirectory badge Iframe embedding
swh:1:dir:dffdf7fcd64597f4a2afc0afdee7259cccaf948d
origin badgecontent badge Iframe embedding
swh:1:cnt:4d930dd864e81abf2d7b296a3b46e112b6882188
origin badgesnapshot badge
swh:1:snp:f8058bb26ca7dfa4e9342cbbd0758552e7f5f26e
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: d41efaa1636fb8cc0da8f09d89f4a1cae0172320 authored by ruqihuang on 24 August 2017, 07:39:27 UTC
Update readme
Tip revision: d41efaa
minConf_QNST.m
function [x,f,funEvals] = minConf_QNST(funObj1,funObj2,x,funProj,options)

nVars = length(x);

if nargin < 5
    options = [];
end

[verbose,numDiff,optTol,progTol,maxIter,maxProject,suffDec,corrections,adjustStep,bbInit,...
    BBSToptTol,BBSTprogTol,BBSTiters,BBSTtestOpt] = ...
    myProcessOptions(...
    options,'verbose',2,'numDiff',0,'optTol',1e-5,'progTol',1e-9,'maxIter',500,'maxProject',100000,'suffDec',1e-4,...
    'corrections',10,'adjustStep',0,'bbInit',0,'BBSToptTol',1e-6,'BBSTprogTol',1e-10,'BBSTiters',10,'BBSTtestOpt',0);

% Output Parameter Settings
if verbose >= 3
   fprintf('Running QNST...\n');
   fprintf('Number of L-BFGS Corrections to store: %d\n',corrections);
   fprintf('Spectral initialization of BBST: %d\n',bbInit);
   fprintf('Maximum number of BBST iterations: %d\n',BBSTiters);
   fprintf('BBST optimality tolerance: %.2e\n',BBSToptTol);
   fprintf('BBST progress tolerance: %.2e\n',BBSTprogTol);
   fprintf('PQN optimality tolerance: %.2e\n',optTol);
   fprintf('PQN progress tolerance: %.2e\n',progTol);
   fprintf('Quadratic initialization of line search: %d\n',adjustStep);
   fprintf('Maximum number of function evaluations: %d\n',maxIter);
   fprintf('Maximum number of projections: %d\n',maxProject);
end

if verbose
    fprintf('%10s %10s %10s %15s %15s\n','Iteration','FunEvals','Projections','Step Length','Function Val');
end

% Evaluate Initial Objective
[f1,g] = funObj1(x);
f = f1+funObj2(x);
funEvals = 1;
projects = 0;

% Check optimality
optCond = max(abs(x-funProj(x-g,1)));
projects = 1;
if optCond < optTol
    if verbose >= 1
        fprintf('First-Order Optimality Conditions Below optTol at Initial Point\n');
    end
    return;
end

i = 1;
while 1
    
    if 0 % BBST
        if i == 1
            alpha = 1;
        else
            y = g-g_old;
            s = x-x_old;
            alpha = (s'*s)/(s'*y);
            if alpha <= 1e-10 || alpha > 1e10
                alpha = min(1,1/sum(abs(g)));
            end
        end
        p = funProj(x-alpha*g,alpha);
        projects = projects+1;
        
    else % QNST
        if i == 1
            p = funProj(x-g,1);
            projects = projects+1;
            S = zeros(nVars,0);
            Y = zeros(nVars,0);
            Hdiag = 1;
        else
            y = g-g_old;
        s = x-x_old;
        [S,Y,Hdiag] = lbfgsUpdate(y,s,corrections,verbose==3,S,Y,Hdiag);

        % Make Compact Representation
        k = size(Y,2);
        L = zeros(k);
        for j = 1:k
            L(j+1:k,j) = S(:,j+1:k)'*Y(:,j);
        end
        N = [S/Hdiag Y];
        M = [S'*S/Hdiag L;L' -diag(diag(S'*Y))];
        HvFunc = @(v)lbfgsHvFunc2(v,Hdiag,N,M);
        
        if bbInit
            % Use Barzilai-Borwein step to initialize sub-problem
            alpha = (s'*s)/(s'*y);
            if alpha <= 1e-10 || alpha > 1e10
                alpha = 1/norm(g);
            end
            
            % Solve Sub-problem
            xSubInit = funProj(x-alpha*g,alpha);
            projects = projects+1;
        else
            xSubInit = x;
        end
        % Solve Sub-problem
        [p,subProjects] = solveSubProblem(x,g,HvFunc,funObj2,funProj,BBSToptTol,BBSTprogTol,BBSTiters,BBSTtestOpt,xSubInit);
        projects = projects+subProjects;
        end
    end
    
   d = p-x;
   g_old = g;
   x_old = x;
    
   % Bound Step length on first iteration
   t = 1;
   if i == 1
      t = min(1,1/sum(abs(g)));
   end
   
   if t == 1
       x_new = p;
   else
    x_new = x+t*d;
   end
    [f1_new,g_new] = funObj1(x_new);
    f_new = f1_new + funObj2(x_new);
    funEvals = funEvals+1;

    f_old = f;
    while f_new > f
        if verbose
            fprintf('Backtracking\n');
        end
        t = t/2;
        x_new = x+t*d;
        [f1_new,g_new] = funObj1(x_new);
        f_new = f1_new + funObj2(x_new);
        funEvals = funEvals+1;
    end
    x = x_new;
    f = f_new;
    g = g_new;

        % Check Optimality
    optCond = max(abs(x-funProj(x-g,1)));
    projects = projects+1;
    
    if verbose
        fprintf('%10d %10d %10d %15.5e %15.5e %15.5e\n',i,funEvals,projects,t,f,optCond);
    end
    
    if optCond < optTol
        if verbose
            fprintf('First-order optimality below optTol\n');
        end
        break;
    end
    
    if max(abs(x-x_old)) < progTol
        if verbose >= 1
            fprintf('Step size below progTol\n');
        end
        break;
    end

    if abs(f-f_old) < progTol
        if verbose >= 1
            fprintf('Function value changing by less than progTol\n');
        end
        break;
    end

    if funEvals > maxIter
        if verbose
        fprintf('Exceeded maxIter funEvals\n');
        end
        break
    end

    i = i + 1;
end
end

function [p,subProjects] = solveSubProblem(x,g,H,funObj2,funProj,optTol,progTol,maxIter,testOpt,x_init)
% Uses BBST to solve for quasi-Newton soft-threshold direction
options.verbose = 0;
options.optTol = optTol;
options.progTol = progTol;
options.maxIter = maxIter;
options.testOpt = testOpt;

funObj = @(p)subHv(p,x,g,H);
[p,f,funEvals,subProjects] = minConf_BBST(funObj,funObj2,x_init,funProj,options);
end

function [f,g] = subHv(p,x,g,HvFunc)
d = p-x;
Hd = HvFunc(d);
f = g'*d + (1/2)*d'*Hd;
g = g + Hd;
end
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API