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.java


xbrecurs.java
/********************************************************
  Xpress-BCL Java Example Problems
  ================================

  file xbrecurs.java
  ``````````````````
  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
********************************************************/

import java.lang.*;
import com.dashoptimization.*;

public class xbrecurs
{
 static final int T=6;

/****DATA****/
 static double X = 0.00;         /* An INITIAL GUESS as to interest rate x */
 static final 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) */
 static final double[] P = {-1000, 0, 0, 0, 0, 0};            /* Payments */
 static final double[] R = {206.6, 206.6, 206.6, 206.6, 206.6, 0}; /*  "  */
 static final double[] V = {-2.95, 0, 0, 0, 0, 0};                 /*  "  */

 static XPRBvar[] b;             /* Balance */
 static XPRBvar x;               /* Interest rate */
 static XPRBvar dx;              /* Change to x */
 static XPRBctr[] interest;
 static XPRBctr ctrd;
 static XPRB bcl;
 static XPRBprob p;

/***********************************************************************/

 static void modFinNLP() throws XPRSexception
 {
  XPRBvar[] i;                   /* Interest */
  XPRBvar[] n;                   /* Net */
  XPRBvar[] epl, emn;            /* + and - deviations */
  XPRBexpr cobj, le;
  int t;

  bcl = new XPRB();              /* Initialize BCL */
  p = bcl.newProb("Fin_nlp");    /* Create a new problem in BCL*/
  XPRS.init();                   /* Initialize Xpress-Optimizer */
 
/****VARIABLES****/
  b = new XPRBvar[T];
  i = new XPRBvar[T];
  n = new XPRBvar[T];
  epl = new XPRBvar[T];
  emn = new XPRBvar[T];
  for(t=0;t0) p.newCtr("bal", b[t].eql(b[t-1].add(n[t].mul(-1))) );
   else  p.newCtr("bal", b[t].eql(n[t].mul(-1)) );
  }

  interest = new XPRBctr[T];
  for(t=1;t0.000001)
  {
   ct++;
   basis=p.saveBasis();           /* Save the current basis */

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