Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code contribution #5

Open
normvcr opened this issue Oct 10, 2013 · 1 comment
Open

Code contribution #5

normvcr opened this issue Oct 10, 2013 · 1 comment

Comments

@normvcr
Copy link

normvcr commented Oct 10, 2013

Here are two routines for the LBFGS project, to be incorporated as seen fit by the project maintainers.

-- Converts LBFGS error codes to short strings.
-- Pretty-prints the LBFGS parameters

//*******************************************************************
// Copyright 2013 Norman J. Goldstein
//
// License:
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program. If not, see
// http://www.gnu.org/licenses/.
//
// Author: Norman J. Goldstein ([email protected],
// [email protected])

include "MthConfigLBFGS.h"

include

const char* LBFGS_ERR_str( int val )
{
switch( val )
{
case LBFGS_CONVERGENCE:
{
return "CONVERGENCE";
}

case LBFGS_STOP:
{
  return "STOP";
}

case LBFGS_ALREADY_MINIMIZED:
{
  return "ALREADY_MINIMIZED";
}

case LBFGSERR_UNKNOWNERROR:
{
  return "UNKNOWNERROR";
}

case LBFGSERR_LOGICERROR:
{
  return "LOGICERROR";
}

case LBFGSERR_OUTOFMEMORY:
{
  return "OUTOFMEMORY";
}

case LBFGSERR_CANCELED:
{
  return "CANCELED";
}

case LBFGSERR_INVALID_N:
{
  return "INVALID_N";
}

case LBFGSERR_INVALID_N_SSE:
{
  return "INVALID_N_SSE";
}

case LBFGSERR_INVALID_X_SSE:
{
  return "INVALID_X_SSE";
}

case LBFGSERR_INVALID_EPSILON:
{
  return "INVALID_EPSILON";
}

case LBFGSERR_INVALID_TESTPERIOD:
{
  return "INVALID_TESTPERIOD";
}

case LBFGSERR_INVALID_DELTA:
{
  return "INVALID_DELTA";
}

case LBFGSERR_INVALID_LINESEARCH:
{
  return "INVALID_LINESEARCH";
}

case LBFGSERR_INVALID_MINSTEP:
{
  return "INVALID_MINSTEP";
}

case LBFGSERR_INVALID_MAXSTEP:
{
  return "INVALID_MAXSTEP";
}

case LBFGSERR_INVALID_FTOL:
{
  return "INVALID_FTOL";
}

case LBFGSERR_INVALID_WOLFE:
{
  return "INVALID_WOLFE";
}

case LBFGSERR_INVALID_GTOL:
{
  return "INVALID_GTOL";
}

case LBFGSERR_INVALID_XTOL:
{
  return "INVALID_XTOL";
}

case LBFGSERR_INVALID_MAXLINESEARCH:
{
  return "INVALID_MAXLINESEARCH";
}

case LBFGSERR_INVALID_ORTHANTWISE:
{
  return "INVALID_ORTHANTWISE";
}

case LBFGSERR_INVALID_ORTHANTWISE_START:
{
  return "INVALID_ORTHANTWISE_START";
}

case LBFGSERR_INVALID_ORTHANTWISE_END:
{
  return "INVALID_ORTHANTWISE_END";
}

case LBFGSERR_OUTOFINTERVAL:
{
  return "OUTOFINTERVAL";
}

case LBFGSERR_INCORRECT_TMINMAX:
{
  return "INCORRECT_TMINMAX";
}

case LBFGSERR_ROUNDING_ERROR:
{
  return "ROUNDING_ERROR";
}

case LBFGSERR_MINIMUMSTEP:
{
  return "MINIMUMSTEP";
}

case LBFGSERR_MAXIMUMSTEP:
{
  return "MAXIMUMSTEP";
}

case LBFGSERR_MAXIMUMLINESEARCH:
{
  return "MAXIMUMLINESEARCH";
}

case LBFGSERR_MAXIMUMITERATION:
{
  return "MAXIMUMITERATION";
}

case LBFGSERR_WIDTHTOOSMALL:
{
  return "WIDTHTOOSMALL";
}

case LBFGSERR_INVALIDPARAMETERS:
{
  return "INVALIDPARAMETERS";
}

case LBFGSERR_INCREASEGRADIENT:
{
  return "INCREASEGRADIENT";
}

default:
{
  return "Not a valid LBFGS error code";
}

}
}

using namespace std;

ostream& operator<<( ostream& os,
const lbfgs_parameter_t& params )
{

define POUT(v) os << #v << "= " << params.v << endl

POUT(m);
POUT(epsilon);
POUT(past);
POUT(delta);
POUT(max_iterations);
POUT(linesearch);
POUT(max_linesearch);
POUT(min_step);
POUT(max_step);
POUT(ftol);
POUT(wolfe);
POUT(gtol);
POUT(xtol);
POUT(orthantwise_c);
POUT(orthantwise_start);
POUT(orthantwise_end);

undef POUT

return os;
}// operator<<

@cynthia
Copy link
Collaborator

cynthia commented Jun 4, 2019

Sorry this took so long. The patch you have sent is somewhat challenging to use as it got formatted into markdown, which I can potentially work around but brings up a different issue:

It's GPLv3. The project is currently licensed as MIT, and landing a GPL dependency effectively taints it - so unless you intend to relicense with a more permissive license, I'm afraid landing this would be problematic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants