SHOGUN
v2.0.0
|
00001 /*----------------------------------------------------------------------- 00002 * libqp.h: Library for Quadratic Programming optimization. 00003 * 00004 * The library provides two solvers: 00005 * 1. Solver for QP task with simplex constraints. 00006 * See function ./lib/libqp_splx.c for definition of the QP task. 00007 * 00008 * 2. Solver for QP task with box constraints and a single linear 00009 * equality constraint. 00010 * See function ./lib/libqp_gsmo.c for definiton of the QP task. 00011 * 00012 * Copyright (C) 2006-2008 Vojtech Franc, xfrancv@cmp.felk.cvut.cz 00013 * Center for Machine Perception, CTU FEL Prague 00014 * 00015 * This program is free software; you can redistribute it and/or 00016 * modify it under the terms of the GNU General Public 00017 * License as published by the Free Software Foundation; 00018 * Version 3, 29 June 2007 00019 *-------------------------------------------------------------------- */ 00020 00021 #ifndef libqp_h 00022 #define libqp_h 00023 00024 #include <math.h> 00025 00026 #include <shogun/lib/common.h> 00027 namespace shogun 00028 { 00029 #define LIBQP_PLUS_INF (-log(0.0)) 00030 #define LIBQP_CALLOC(x,y) calloc(x,y) 00031 #define LIBQP_FREE(x) SG_FREE(x) 00032 #define LIBQP_INDEX(ROW,COL,NUM_ROWS) ((COL)*(NUM_ROWS)+(ROW)) 00033 #define LIBQP_MIN(A,B) ((A) > (B) ? (B) : (A)) 00034 #define LIBQP_MAX(A,B) ((A) < (B) ? (B) : (A)) 00035 #define LIBQP_ABS(A) ((A) < 0 ? -(A) : (A)) 00036 00037 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00038 00039 typedef struct { 00041 uint32_t nIter; 00043 float64_t QP; 00045 float64_t QD; 00047 int8_t exitflag; /* -1 ... not enough memory 00048 0 ... nIter >= MaxIter 00049 1 ... QP - QD <= TolRel*ABS(QP) 00050 2 ... QP - QD <= TolAbs 00051 3 ... QP <= QP_TH 00052 4 ... eps-KKT conditions satisfied */ 00053 } libqp_state_T; 00054 #endif 00055 00057 libqp_state_T libqp_splx_solver(const float64_t* (*get_col)(uint32_t), 00058 float64_t *diag_H, 00059 float64_t *f, 00060 float64_t *b, 00061 uint32_t *I, 00062 uint8_t *S, 00063 float64_t *x, 00064 uint32_t n, 00065 uint32_t MaxIter, 00066 float64_t TolAbs, 00067 float64_t TolRel, 00068 float64_t QP_TH, 00069 void (*print_state)(libqp_state_T state)); 00070 00072 libqp_state_T libqp_gsmo_solver(const float64_t* (*get_col)(uint32_t), 00073 float64_t *diag_H, 00074 float64_t *f, 00075 float64_t *a, 00076 float64_t b, 00077 float64_t *LB, 00078 float64_t *UB, 00079 float64_t *x, 00080 uint32_t n, 00081 uint32_t MaxIter, 00082 float64_t TolKKT, 00083 void (*print_state)(libqp_state_T state)); 00084 00085 } 00086 #endif /* libqp_h */