help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to rewrite this m.file?


From: Heber Farnsworth
Subject: Re: How to rewrite this m.file?
Date: Mon, 8 Jun 1998 12:15:48 -0400

This .m file is just a front end to a linear programming function called lp 
that 
is included with matlab.  Octave does not yet have one (I think, I'm using an 
old release) although I'm working on one myself (not ready yet).

> I'm stuck with a MATLAB m-file which is used to give
> solutions for a two player zero sum game.
> 
> (http://robotics.stanford.edu/~koller/gala.html)
> 
> 
> Here comes the m file:
> ---- begin sprs.m ----
> % solves the linear programming problem for two-player zero-sum
> % games derived from the Koller-Megiddo-Von Stengel algorithm.
> 
> % the current directory should contain the matrices A, E, F, e, f
> 
> t1 = cputime;
> 
> load A;
> AS = spconvert(A);
> load E;
> ES = spconvert(E);
> load F;
> FS = spconvert(F);
> load e;
> load f;
> 
> %get dimensions
> S = size(ES);
> T = size(FS);
> 
> % extend e and f to cover yp entirely
> j = [zeros(T(2), 1) ; e];
> k = [f ; zeros(S(2), 1)];
> 
> % build constraint matrix
> HS = [FS , zeros(T(1), S(1)) ; AS, -ES'];
> H = full(HS);
> SIZE = size(H)
> 
> % build bounds, with slight 'error' to simulate <=, >=
> LB = [zeros(T(2), 1) ; -inf * ones(S(1), 1)];
> UB = [ones(T(2), 1) ; inf * ones(S(1), 1)];
> 
> % solve lp problem
> % (don't bother with lagrange multipliers for now)
> [yp, lagrange] = lp(j, H, k, LB, UB, [], T(1));
> 
> % get y and p from solution
> x = lagrange(T(1)+1 : T(1)+S(2));
> y = yp(1 : T(2))
> p = yp(T(2)+1 : T(2)+S(1))
> q = lagrange(1 : T(1));
> 
> t2 = cputime;
> TIME = t2 - t1
> 
> % save results
> save x x -ascii;
> save y y -ascii;
> save p p -ascii;
> save q q -ascii;
> save lg lagrange -ascii;
> save time TIME -ascii;
> save size SIZE -ascii;
> ---- end sprs.m ----
> 
> The spconvert() function should be no problem (thanks to John W. Eaton)
> Main problem for me is the lp() function. Since I'm a non mathematician
> I'm standing before a locked door. How could the MATLAB lp() function
> be replaced in OCTAVE?
> 
> Enjoy!
> Hans
> 
> Hans Zoebelein             * You are interested in Linux blind support?
> address@hidden    * Join the blinux mailing list and mail to:
>  Check out Blinux Project: * address@hidden
>  http://www.leb.net/blinux * with subject line: subscribe
> 
> 
> 

_____________________________________________________
Heber K. Farnsworth             phone: (614) 292-3092          
Assistant Professor of Finance    FAX: (614) 292-2418
Fisher College of Business
the Ohio State University
_____________________________________________________



reply via email to

[Prev in Thread] Current Thread [Next in Thread]