Initializing help system before first use

Recurse - A successive linear programming model


Type: Recursion
Rating: 3
Description: A non-linear problem (quadratic terms in the constraints) is modeled as a successive linear programming (SLP) model. (SLP is also known as 'recursion'.) The constraint coefficients are changed iteratively. Shows how to save and re-load an LP basis.
File(s): xbrecurs.c


xbrecurs.c
/********************************************************
  BCL Example Problems
  ====================

  file xbrecurs.c
  ```````````````
  Recursion solving a non-linear financial planning problem
  The problem is to solve
  	net(t) = Payments(t)  - interest(t)
  	balance(t) = balance(t-1) - net(t)
  	interest(t) = (92/365) * balance(t) * interest_rate
  where
        balance(0) = 0
        balance[T] = 0
  for interest_rate

  (c) 2008 Fair Isaac Corporation
      author: S.Heipcke, 2001, rev. Mar. 2011
********************************************************/

#include 
#include 
#include 
#include "xprb.h"
#include "xprs.h"

#define T 6

/****DATA****/
double X = 0.00;                /* An INITIAL GUESS as to interest rate x */
double B[] = /* {796.35, 589.8918, 398.1351, 201.5451, 0.0, 0.0}; */
             {1,1,1,1,1,1};     /* An INITIAL GUESS as to balances b(t) */
double P[] = {-1000, 0, 0, 0, 0, 0};                 /* Payments */
double R[] = {206.6, 206.6, 206.6, 206.6, 206.6, 0}; /*  "       */
double V[] = {-2.95, 0, 0, 0, 0, 0};                 /*  "       */

XPRBvar b[T];                   /* Balance */
XPRBvar x;                      /* Interest rate */
XPRBvar dx;                     /* Change to x */
XPRBctr interest[T], ctrd;
 
/***********************************************************************/

void modfinnlp(XPRBprob prob)
{
 XPRBvar i[T];                  /* Interest */
 XPRBvar n[T];                  /* Net */
 XPRBvar epl[T], emn[T];        /* + and - deviations */
 XPRBctr cobj, bal, net;  
 int t;
 
/****VARIABLES****/
 for(t=0;t0) XPRBaddterm(bal, b[t-1], -1);
  XPRBaddterm(bal, n[t], 1);
 }

 for(t=1;t0.000001)
 {
  ct++;
  basis=XPRBsavebasis(prob);       /* Save the current basis */

                                   /* Get the solution values for b and x */
  for(t=1;t