This list is closed, nobody may subscribe to it.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(10) |
Aug
(5) |
Sep
(3) |
Oct
(41) |
Nov
(41) |
Dec
(33) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(75) |
Feb
(10) |
Mar
(170) |
Apr
(174) |
May
(66) |
Jun
(11) |
Jul
(10) |
Aug
(44) |
Sep
(73) |
Oct
(28) |
Nov
(139) |
Dec
(52) |
2003 |
Jan
(35) |
Feb
(93) |
Mar
(62) |
Apr
(10) |
May
(55) |
Jun
(70) |
Jul
(37) |
Aug
(16) |
Sep
(56) |
Oct
(31) |
Nov
(57) |
Dec
(83) |
2004 |
Jan
(85) |
Feb
(67) |
Mar
(27) |
Apr
(37) |
May
(75) |
Jun
(85) |
Jul
(160) |
Aug
(68) |
Sep
(104) |
Oct
(25) |
Nov
(39) |
Dec
(23) |
2005 |
Jan
(10) |
Feb
(45) |
Mar
(43) |
Apr
(19) |
May
(108) |
Jun
(31) |
Jul
(41) |
Aug
(23) |
Sep
(65) |
Oct
(58) |
Nov
(44) |
Dec
(54) |
2006 |
Jan
(96) |
Feb
(27) |
Mar
(69) |
Apr
(59) |
May
(67) |
Jun
(35) |
Jul
(13) |
Aug
(461) |
Sep
(160) |
Oct
(399) |
Nov
(32) |
Dec
(72) |
2007 |
Jan
(316) |
Feb
(305) |
Mar
(318) |
Apr
(54) |
May
(194) |
Jun
(173) |
Jul
(282) |
Aug
(91) |
Sep
(227) |
Oct
(365) |
Nov
(168) |
Dec
(18) |
2008 |
Jan
(71) |
Feb
(111) |
Mar
(155) |
Apr
(173) |
May
(70) |
Jun
(67) |
Jul
(55) |
Aug
(83) |
Sep
(32) |
Oct
(68) |
Nov
(80) |
Dec
(29) |
2009 |
Jan
(46) |
Feb
(18) |
Mar
(95) |
Apr
(76) |
May
(140) |
Jun
(98) |
Jul
(84) |
Aug
(123) |
Sep
(94) |
Oct
(131) |
Nov
(142) |
Dec
(125) |
2010 |
Jan
(128) |
Feb
(158) |
Mar
(172) |
Apr
(134) |
May
(94) |
Jun
(84) |
Jul
(32) |
Aug
(127) |
Sep
(167) |
Oct
(109) |
Nov
(69) |
Dec
(78) |
2011 |
Jan
(39) |
Feb
(58) |
Mar
(52) |
Apr
(47) |
May
(56) |
Jun
(76) |
Jul
(55) |
Aug
(54) |
Sep
(165) |
Oct
(255) |
Nov
(328) |
Dec
(263) |
2012 |
Jan
(82) |
Feb
(147) |
Mar
(400) |
Apr
(216) |
May
(209) |
Jun
(160) |
Jul
(86) |
Aug
(141) |
Sep
(156) |
Oct
(6) |
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(2) |
2016 |
Jan
|
Feb
(2) |
Mar
(2) |
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2019 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(4) |
Jun
(8) |
Jul
(2) |
Aug
(5) |
Sep
(9) |
Oct
|
Nov
|
Dec
|
From: <jpi...@us...> - 2012-03-24 15:54:43
|
Revision: 10023 http://octave.svn.sourceforge.net/octave/?rev=10023&view=rev Author: jpicarbajal Date: 2012-03-24 15:54:32 +0000 (Sat, 24 Mar 2012) Log Message: ----------- geometry: Bumping versin. Releasing Modified Paths: -------------- trunk/octave-forge/main/geometry/DESCRIPTION trunk/octave-forge/main/geometry/NEWS Modified: trunk/octave-forge/main/geometry/DESCRIPTION =================================================================== --- trunk/octave-forge/main/geometry/DESCRIPTION 2012-03-24 14:31:07 UTC (rev 10022) +++ trunk/octave-forge/main/geometry/DESCRIPTION 2012-03-24 15:54:32 UTC (rev 10023) @@ -1,6 +1,6 @@ Name: Geometry Version: 1.4.1 -Date: 2012-03-18 +Date: 2012-03-24 Author: David Legland <dav...@gr...>, José Luis García Pallero <jgp...@gm...>, Juan Pablo Carbajal <car...@if...> Maintainer: Juan Pablo Carbajal <car...@if...> Title: Computational Geometry Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-03-24 14:31:07 UTC (rev 10022) +++ trunk/octave-forge/main/geometry/NEWS 2012-03-24 15:54:32 UTC (rev 10023) @@ -1,7 +1,7 @@ Summary of important user-visible changes for releases of the geometry package =============================================================================== -geometry-1.4.1 Release Date: 2012-03-22 Release Manager: Juan Pablo Carbajal +geometry-1.4.1 Release Date: 2012-03-24 Release Manager: Juan Pablo Carbajal =============================================================================== * Renamed functions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mma...@us...> - 2012-03-24 14:31:14
|
Revision: 10022 http://octave.svn.sourceforge.net/octave/?rev=10022&view=rev Author: mmarzolla Date: 2012-03-24 14:31:07 +0000 (Sat, 24 Mar 2012) Log Message: ----------- fixed typos Modified Paths: -------------- trunk/octave-forge/main/queueing/doc/contributing.txi trunk/octave-forge/main/queueing/doc/markovchains.txi trunk/octave-forge/main/queueing/doc/summary.txi Modified: trunk/octave-forge/main/queueing/doc/contributing.txi =================================================================== --- trunk/octave-forge/main/queueing/doc/contributing.txi 2012-03-24 11:11:08 UTC (rev 10021) +++ trunk/octave-forge/main/queueing/doc/contributing.txi 2012-03-24 14:31:07 UTC (rev 10022) @@ -30,32 +30,28 @@ @item If you are contributing a new function, please embed proper documentation within the function itself. The documentation must be in -@code{texinfo} format, so that it will be extracted and formatted into +@code{texinfo} format, so that it can be extracted and formatted into the printable manual. See the existing functions of the @code{queueing} package for the documentation style. -@item The documentation should be as precise as possible. In particular, -always state what the valid ranges of the parameters are. - -@item If you are contributing a new function, ensure that the function +@item Make sure that each new function properly checks the validity of its input parameters. For example, each function accepting vectors should check whether the dimensions match. -@item Always provide bibliographic references for each algorithm you +@item Provide bibliographic references for each new algorithm you contribute. If your implementation differs in some way from the reference you give, please describe how and why your implementation -differs. +differs. Add references to the @file{doc/references.txi} file. -@item Include Octave test and demo blocks with your code. -Test blocks are particularly important, because Queueing Network -algorithms tend to be quite complex to implement correctly, and we -must ensure that the implementations provided with the -@code{queueing} package are (mostly) correct. +@item Include test and demo blocks with your code. +Test blocks are particularly important, since most algorithms tend to +be quite tricky to implement correctly. If appropriate, test blocks +should also verify that the function fails on incorrect input +parameters. @end itemize Send your contribution to Moreno Marzolla -(@email{marzolla@@cs.unibo.it}). Even if you are just a user of -@code{queueing}, and find this package useful, let me know by -dropping me a line. Thanks. +(@email{marzolla@@cs.unibo.it}). If you are just a user of this +package and find it useful, let me know by dropping me a line. Thanks. Modified: trunk/octave-forge/main/queueing/doc/markovchains.txi =================================================================== --- trunk/octave-forge/main/queueing/doc/markovchains.txi 2012-03-24 11:11:08 UTC (rev 10021) +++ trunk/octave-forge/main/queueing/doc/markovchains.txi 2012-03-24 14:31:07 UTC (rev 10022) @@ -249,8 +249,11 @@ @noindent where @math{{\bf \pi}(i) = {\bf \pi}(0){\bf P}^i} is the state occupancy probability after @math{i} transitions. -If @math{\bf P} has absorbing states, that is, states with no out -transitions, we can rearrange the states to rewrite @math{\bf P} as: +If @math{\bf P} is absorbing, i.e., the stochastic process eventually +reaches with probability 1 a state with no outgoing transitions, then +we can compute the expected number of visits until absorption +@math{\bf L}. To do so, we first rearrange the states to rewrite +matrix @math{\bf P} as: @iftex @tex @@ -271,12 +274,11 @@ @noindent where the first @math{t} states are transient and the last @math{r} states are absorbing (@math{t+r = N}). The matrix @math{{\bf N} = ({\bf I} - {\bf Q})^{-1}} is called the -@emph{fundamental matrix}; @math{N(i,j)} represents the expected -number of times that the process is in the @math{j}-th transient state -if it is started in the @math{i}-th transient state. If we reshape -@math{\bf N} to the size of @math{\bf P} (filling missing entries with -zeros), we have that, for absorbing chains @math{{\bf L} = {\bf -\pi}(0){\bf N}}. +@emph{fundamental matrix}; @math{N_{i,j}} is the expected number of +times that the process is in the @math{j}-th transient state if it +started in the @math{i}-th transient state. If we reshape @math{\bf N} +to the size of @math{\bf P} (filling missing entries with zeros), we +have that, for absorbing chains @math{{\bf L} = {\bf \pi}(0){\bf N}}. @DOCSTRING(dtmc_exps) @@ -293,11 +295,11 @@ The @emph{mean time to absorption} is defined as the average number of transitions which are required to reach an absorbing state, starting from a transient state (or given an initial state occupancy -probability vector @math{{\bf \pi}(0)} ). +probability vector @math{{\bf \pi}(0)}). -Let @math{{\bf t}_i} be the expected number of steps before being -absorbed in any absorbing state, starting from state @math{i}. Vector -@math{\bf t} can be easiliy computed from the fundamental matrix +Let @math{{\bf t}_i} be the expected number of transitions before +being absorbed in any absorbing state, starting from state @math{i}. +Vector @math{\bf t} can be computed from the fundamental matrix @math{\bf N} (@pxref{Expected number of visits (DTMC)}) as @iftex @@ -311,10 +313,10 @@ @end example @end ifnottex -We can define a matrix @math{{\bf B} = [ B_{i, j} ]} such that -@math{B_{i, j}} is the probability of being absorbed in state -@math{j}, starting from transient state @math{i}. Again, using -the fundamental matrix @math{\bf N} and @math{\bf R}, we have +Let @math{{\bf B} = [ B_{i, j} ]} be a matrix where @math{B_{i, j}} is +the probability of being absorbed in state @math{j}, starting from +transient state @math{i}. Again, using matrices @math{\bf N} and +@math{\bf R} (@pxref{Expected number of visits (DTMC)}) we can write @iftex @tex @@ -333,9 +335,9 @@ @node First passage times (DTMC) @subsection First Passage Times -The First Passage Time @math{M_{i, j}} is defined as the average -number of transitions needed to visit state @math{j} for the first -time, starting from state @math{i}. Matrix @math{\bf M} satisfies the +The First Passage Time @math{M_{i, j}} is the average number of +transitions needed to visit state @math{j} for the first time, +starting from state @math{i}. Matrix @math{\bf M} satisfies the property that @iftex @@ -359,7 +361,7 @@ used. Let @math{\bf W} be the @math{N \times N} matrix having each row equal to the steady-state probability vector @math{\bf \pi} for @math{\bf P}; let @math{\bf I} be the @math{N \times N} identity -matrix. Define matrix @math{\bf Z} as follows: +matrix. Define @math{\bf Z} as follows: @iftex @tex @@ -393,10 +395,9 @@ @end ifnottex According to the definition above, @math{M_{i,i} = 0}. We arbitrarily -redefine @math{M_{i,i}} to be the @emph{mean recurrence time} -@math{r_i} for state @math{i}, that is the average number of -transitions needed to return to state @math{i} starting from -it. @math{r_i} is defined as: +let @math{M_{i,i}} to be the @emph{mean recurrence time} @math{r_i} +for state @math{i}, that is the average number of transitions needed +to return to state @math{i} starting from it. @math{r_i} is: @iftex @tex @@ -413,9 +414,6 @@ @end example @end ifnottex -@noindent where @math{\pi_i} is the stationary probability of visiting state -@math{i}. - @DOCSTRING(dtmc_fpt) @c Modified: trunk/octave-forge/main/queueing/doc/summary.txi =================================================================== --- trunk/octave-forge/main/queueing/doc/summary.txi 2012-03-24 11:11:08 UTC (rev 10021) +++ trunk/octave-forge/main/queueing/doc/summary.txi 2012-03-24 14:31:07 UTC (rev 10022) @@ -65,15 +65,14 @@ @item @math{M/H_m/1} (Hyperexponential service time distribution) @end itemize -Functions for Markov chain analysis are also provided, for discrete-time -chains (DTMC) or continuous-time chains (CTMC): +Functions for Markov chain analysis are also provided: @itemize @item Birth-death process; @item Transient and steady-state occupancy probabilities; @item Mean times to absorption; -@item Expected sojourn times and time-averaged sojourn times (CTMC only); +@item Expected sojourn times and time-averaged sojourn times; @item Mean first passage times; @end itemize This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-24 11:11:14
|
Revision: 10021 http://octave.svn.sourceforge.net/octave/?rev=10021&view=rev Author: jpicarbajal Date: 2012-03-24 11:11:08 +0000 (Sat, 24 Mar 2012) Log Message: ----------- geometry: suppresing graphical output from tests Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/geom2d/drawLine.m Modified: trunk/octave-forge/main/geometry/inst/geom2d/drawLine.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/drawLine.m 2012-03-24 10:24:19 UTC (rev 10020) +++ trunk/octave-forge/main/geometry/inst/geom2d/drawLine.m 2012-03-24 11:11:08 UTC (rev 10021) @@ -91,7 +91,7 @@ %!test %! addpath (privpath,'-end') %! box = [0 100 0 100]; -%! hf = figure(); +%! hf = figure('visible','off'); %! axis(box); %! line = [30 40 10 0]; %! edge = [0 40 100 40]; @@ -99,12 +99,11 @@ %! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); %! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); %! rmpath (privpath); -%! close all %!test %! addpath (privpath,'-end') %! box = [0 100 0 100]; -%! hf = figure(); +%! hf = figure('visible','off'); %! axis(box); %! line = [30 40 -10 0]; %! edge = [100 40 0 40]; @@ -112,23 +111,21 @@ %! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); %! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); %! rmpath (privpath); -%! close all %!test %! addpath (privpath,'-end') %! box = [0 100 0 100]; -%! hf = figure(); +%! hf = figure('visible','off'); %! axis(box); %! line = [30 140 10 0]; %! hl = drawLine(line); %! assertEqual(-1, hl); %! rmpath (privpath); -%! close all %!test %! addpath (privpath,'-end') %! box = [0 100 0 100]; -%! hf = figure(); +%! hf = figure('visible','off'); %! axis(box); %! line = [30 40 0 10]; %! edge = [30 0 30 100]; @@ -136,12 +133,11 @@ %! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); %! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); %! rmpath (privpath); -%! close all %!test %! addpath (privpath,'-end') %! box = [0 100 0 100]; -%! hf = figure(); +%! hf = figure('visible','off'); %! axis(box); %! line = [30 40 0 -10]; %! edge = [30 100 30 0]; @@ -149,23 +145,21 @@ %! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); %! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); %! rmpath (privpath); -%! close all %!test %! addpath (privpath,'-end') %! box = [0 100 0 100]; -%! hf = figure(); +%! hf = figure('visible','off'); %! axis(box); %! line = [140 30 0 10]; %! hl = drawLine(line); %! assertEqual(-1, hl); %! rmpath (privpath); -%! close all %!test %! addpath (privpath,'-end') %! box = [0 100 0 100]; -%! hf = figure(); +%! hf = figure('visible','off'); %! axis(box); %! line = [80 30 10 10]; %! edge = [50 0 100 50]; @@ -173,12 +167,11 @@ %! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); %! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); %! rmpath (privpath); -%! close all %!test %! addpath (privpath,'-end') %! box = [0 100 0 100]; -%! hf = figure(); +%! hf = figure('visible','off'); %! axis(box); %! line = [20 70 10 10]; %! edge = [0 50 50 100]; @@ -186,12 +179,11 @@ %! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); %! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); %! rmpath (privpath); -%! close all %!test %! addpath (privpath,'-end') %! box = [0 100 0 100]; -%! hf = figure(); +%! hf = figure('visible','off'); %! axis(box); %! line = [140 -30 10 10]; %! hl = drawLine(line); @@ -200,12 +192,11 @@ %! hl = drawLine(line); %! assertEqual(-1, hl); %! rmpath (privpath); -%! close all %!test %! addpath (privpath,'-end') %! box = [0 100 0 100]; -%! hf = figure(); +%! hf = figure('visible','off'); %! axis(box); %! line = [... %! 80 30 10 10; ... @@ -224,4 +215,4 @@ %! assertEqual(-1, hl(3)); %! assertEqual(-1, hl(4)); %! rmpath (privpath); -%! close all + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-24 10:24:26
|
Revision: 10020 http://octave.svn.sourceforge.net/octave/?rev=10020&view=rev Author: jpicarbajal Date: 2012-03-24 10:24:19 +0000 (Sat, 24 Mar 2012) Log Message: ----------- geometry: Fixing typos. deprecating old functions Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m Added Paths: ----------- trunk/octave-forge/main/geometry/inst/io/deprecated/private/_parsePath.py Removed Paths: ------------- trunk/octave-forge/main/geometry/doc/ trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/private/_parsePath.py (from rev 10004, trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/private/_parsePath.py (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/private/_parsePath.py 2012-03-24 10:24:19 UTC (rev 10020) @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import inkex, simplepath +import sys +#import getopt + +def parsePaths (filen=None): + + svg = inkex.Effect () + svg.parse (filen) + + paths = svg.document.xpath ('//svg:path', namespaces=inkex.NSS) + for path in paths: + D = simplepath.parsePath (path.attrib['d']) + cmdlst = []; + parlst = []; + for cmd,params in D: + cmdlst.append(cmd) + parlst.append(params) + + print 'svgpath = struct("cmd","{0}","data",{{{1}}});' \ + .format(''.join(cmdlst),str(parlst).replace('[[','[').replace(']]',']')) + + print 'svgpathid = "{0}"; $'.format(path.attrib['id']) + + + +# ---------------------------- + +if __name__=="__main__": + ''' + try: + optlist,args = getopt.getopt(sys.argv[1:],"thdp") + except getopt.GetoptError: + usage() + sys.exit(2) + + doHelp = 0 + c = Context() + c.doPrint = 1 + for opt in optlist: + if opt[0] == "-d": c.debug = 1 + if opt[0] == "-p": c.plot = 1 + if opt[0] == "-t": c.triangulate = 1 + if opt[0] == "-h": doHelp = 1 + + if not doHelp: + pts = [] + fp = sys.stdin + if len(args) > 0: + fp = open(args[0],'r') + for line in fp: + fld = line.split() + x = float(fld[0]) + y = float(fld[1]) + pts.append(Site(x,y)) + if len(args) > 0: fp.close() + + if doHelp or len(pts) == 0: + usage() + sys.exit(2) + ''' + svg = sys.argv[1] + parsePaths(svg) Deleted: trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py 2012-03-24 09:46:42 UTC (rev 10019) +++ trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py 2012-03-24 10:24:19 UTC (rev 10020) @@ -1,64 +0,0 @@ -#!/usr/bin/env python - -import inkex, simplepath -import sys -#import getopt - -def parsePaths (filen=None): - - svg = inkex.Effect () - svg.parse (filen) - - paths = svg.document.xpath ('//svg:path', namespaces=inkex.NSS) - for path in paths: - D = simplepath.parsePath (path.attrib['d']) - cmdlst = []; - parlst = []; - for cmd,params in D: - cmdlst.append(cmd) - parlst.append(params) - - print 'svgpath = struct("cmd","{0}","data",{{{1}}});' \ - .format(''.join(cmdlst),str(parlst).replace('[[','[').replace(']]',']')) - - print 'svgpathid = "{0}"; $'.format(path.attrib['id']) - - - -# ---------------------------- - -if __name__=="__main__": - ''' - try: - optlist,args = getopt.getopt(sys.argv[1:],"thdp") - except getopt.GetoptError: - usage() - sys.exit(2) - - doHelp = 0 - c = Context() - c.doPrint = 1 - for opt in optlist: - if opt[0] == "-d": c.debug = 1 - if opt[0] == "-p": c.plot = 1 - if opt[0] == "-t": c.triangulate = 1 - if opt[0] == "-h": doHelp = 1 - - if not doHelp: - pts = [] - fp = sys.stdin - if len(args) > 0: - fp = open(args[0],'r') - for line in fp: - fld = line.split() - x = float(fld[0]) - y = float(fld[1]) - pts.append(Site(x,y)) - if len(args) > 0: fp.close() - - if doHelp or len(pts) == 0: - usage() - sys.exit(2) - ''' - svg = sys.argv[1] - parsePaths(svg) Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-03-24 09:46:42 UTC (rev 10019) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-03-24 10:24:19 UTC (rev 10020) @@ -36,7 +36,7 @@ [~,id] = lastwarn ('',''); if strcmp (id ,'geom2d:shapearea:InvalidResult') - lastwarn('Inverting centriod','geom2d:shapecentriod:InvalidResult'); + lastwarn('Inverting centroid','geom2d:shapecentroid:InvalidResult'); cm = -cm; end @@ -65,13 +65,13 @@ %! [0.25 0.75; ... %! 0 0]}; %! CoM = shapecentroid (boomerang) -%! Gcentriod = centroid(shape2polygon(boomerang)) +%! Gcentroid = centroid(shape2polygon(boomerang)) %! %! figure(1); clf; %! shapeplot(boomerang,10,'-o'); %! hold on -%! drawPoint(CoM,'xk;shape centriod;'); -%! drawPoint(Gcentriod,'xr;point centriod;'); +%! drawPoint(CoM,'xk;shape centroid;'); +%! drawPoint(Gcentroid,'xr;point centroid;'); %! hold off %! axis equal @@ -83,12 +83,12 @@ %! [0.00000 1.10798; 0.28965 -0.53032]; ... %! [-0.34163 1.10798; 0.00000 -0.24067]};... %! CoM = shapecentroid (Lshape) -%! Gcentriod = centroid (shape2polygon (Lshape)) +%! Gcentroid = centroid (shape2polygon (Lshape)) %! %! shapeplot(Lshape,10,'-o'); %! hold on -%! drawPoint(CoM,'xk;shape centriod;'); -%! drawPoint(Gcentriod,'xr;point centriod;'); +%! drawPoint(CoM,'xk;shape centroid;'); +%! drawPoint(Gcentroid,'xr;point centroid;'); %! hold off %! axis equal This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mma...@us...> - 2012-03-24 09:46:52
|
Revision: 10019 http://octave.svn.sourceforge.net/octave/?rev=10019&view=rev Author: mmarzolla Date: 2012-03-24 09:46:42 +0000 (Sat, 24 Mar 2012) Log Message: ----------- fixed documentation typos Modified Paths: -------------- trunk/octave-forge/main/queueing/doc/markovchains.txi trunk/octave-forge/main/queueing/doc/queueing.html trunk/octave-forge/main/queueing/doc/queueing.pdf Modified: trunk/octave-forge/main/queueing/doc/markovchains.txi =================================================================== --- trunk/octave-forge/main/queueing/doc/markovchains.txi 2012-03-23 01:59:38 UTC (rev 10018) +++ trunk/octave-forge/main/queueing/doc/markovchains.txi 2012-03-24 09:46:42 UTC (rev 10019) @@ -31,7 +31,7 @@ @section Discrete-Time Markov Chains Let @math{X_0, X_1, @dots{}, X_n, @dots{} } be a sequence of random -variables, each one defined over a discete state space @math{0, 1, 2, +variables defined over a discete state space @math{0, 1, 2, @dots{}}. The sequence @math{X_0, X_1, @dots{}, X_n, @dots{}} is a @emph{stochastic process} with discrete time @math{0, 1, 2, @dots{}}. A @emph{Markov chain} is a stochastic process @math{@{X_n, @@ -47,21 +47,21 @@ @math{P(X_{n+1} = x_{n+1} | X_n = x_n, X_{n-1} = x_{n-1}, ..., X_0 = x_0) = P(X_{n+1} = x_{n+1} | X_n = x_n)} @end ifnottex -@noindent which means that the probability that the system is in +@noindent which basically means that the probability that the system is in a particular state at time @math{n+1} only depends on the state the system was at time @math{n}. The evolution of a Markov chain with finite state space @math{@{1, 2, @dots{}, N@}} can be fully described by a stochastic matrix @math{{\bf -P}(n) = [ P_{i,j}(n) ]} such that @math{P_{i, j}(n) = P( X_{n+1} = j\ |\ -X_n = i )}. If the Markov chain is homogeneous (that is, the +P}(n) = [ P_{i,j}(n) ]} such that @math{P_{i, j}(n) = P( X_{n+1} = j\ +|\ X_n = i )}. If the Markov chain is homogeneous (that is, the transition probability matrix @math{{\bf P}(n)} is time-independent), -we can simply write @math{{\bf P} = [P_{i, j}]}, where @math{P_{i, j} = -P( X_{n+1} = j\ |\ X_n = i )} for all @math{n=0, 1, @dots{}}. +we can write @math{{\bf P} = [P_{i, j}]}, where @math{P_{i, j} = P( +X_{n+1} = j\ |\ X_n = i )} for all @math{n=0, 1, @dots{}}. The transition probability matrix @math{\bf P} must satisfy the following two properties: (1) @math{P_{i, j} @geq{} 0} for all -@math{i, j}, and (2) @math{\sum_{j=1}^N P_{i,j} = 1}. +@math{i, j}, and (2) @math{\sum_{j=1}^N P_{i,j} = 1} for all @math{i} @c @DOCSTRING(dtmc_check_P) @@ -82,15 +82,14 @@ @subsection State occupancy probabilities We denote with @math{{\bf \pi}(n) = \left(\pi_1(n), \pi_2(n), @dots{}, -\pi_N(n) \right)} the @emph{state occupancy probability vector} at step -@math{n}. @math{\pi_i(n)} denotes the probability that the system is -in state @math{i} after @math{n} transitions. +\pi_N(n) \right)} the @emph{state occupancy probability vector} at +step @math{n}. @math{\pi_i(n)} denotes the probability that the system +is in state @math{i} after @math{n} transitions. Given the transition probability matrix @math{\bf P} and the initial state occupancy probability vector @math{{\bf \pi}(0) = -\left(\pi_1(0), \pi_2(0), @dots{}, \pi_N(0)\right)}, the state -occupancy probabilities @math{{\bf \pi}(n)} after @math{n} transitions -can easily be computed as: +\left(\pi_1(0), \pi_2(0), @dots{}, \pi_N(0)\right)}, @math{{\bf +\pi}(n)} can be computed as: @iftex @tex @@ -107,9 +106,9 @@ Under certain conditions, there exists a @emph{stationary state occupancy probability} @math{{\bf \pi} = \lim_{n \rightarrow +\infty} -{\bf \pi}(n)}, which is independent from the initial occupancy -@math{{\bf \pi}(0)}. The stationary vector @math{\bf \pi} can be -computed as the solution of the following linear system: +{\bf \pi}(n)}, which is independent from @math{{\bf \pi}(0)}. The +stationary vector @math{\bf \pi} is the solution of the following +linear system: @iftex @tex @@ -162,10 +161,10 @@ @end example A mouse is placed in one of the rooms and can wander around. At each -step, the mouse moves to one of the neighboring rooms with equal -probability: if it is in room 1, it van move to room 2 and 4 with -probability 1/2. If the mouse is in room 8, it can move to either 7, 5 -or 9 with probability 1/3. +step, the mouse moves from the current room to a neighboring one with +equal probability: if it is in room 1, it can move to room 2 and 4 +with probability 1/2, respectively. If the mouse is in room 8, it can +move to either 7, 5 or 9 with probability 1/3. The transition probability @math{\bf P} from room @math{i} to room @math{j} is the following: @@ -250,8 +249,8 @@ @noindent where @math{{\bf \pi}(i) = {\bf \pi}(0){\bf P}^i} is the state occupancy probability after @math{i} transitions. -If @math{\bf P} is absorbing, we can rearrange the states to rewrite -@math{\bf P} as: +If @math{\bf P} has absorbing states, that is, states with no out +transitions, we can rearrange the states to rewrite @math{\bf P} as: @iftex @tex @@ -270,13 +269,14 @@ @end ifnottex @noindent where the first @math{t} states are transient -and the last @math{r} states are absorbing. The matrix @math{{\bf N} = -({\bf I} - {\bf Q})^{-1}} is called the @emph{fundamental matrix}; -@math{N(i,j)} represents the expected number of times that the process -is in the @math{j}-th transient state if it is started in the -@math{i}-th transient state. If we reshape @math{\bf N} to the size of -@math{\bf P} (filling missing entries with zeros), we have that, for -absorbing chains @math{{\bf L} = {\bf \pi}(0){\bf N}}. +and the last @math{r} states are absorbing (@math{t+r = N}). The +matrix @math{{\bf N} = ({\bf I} - {\bf Q})^{-1}} is called the +@emph{fundamental matrix}; @math{N(i,j)} represents the expected +number of times that the process is in the @math{j}-th transient state +if it is started in the @math{i}-th transient state. If we reshape +@math{\bf N} to the size of @math{\bf P} (filling missing entries with +zeros), we have that, for absorbing chains @math{{\bf L} = {\bf +\pi}(0){\bf N}}. @DOCSTRING(dtmc_exps) @@ -440,12 +440,11 @@ @end ifnottex A continuous-time Markov chain is defined according to an -@emph{infinitesimal generator matrix} @math{{\bf Q} = [Q_{i,j}]} such -that for each @math{i \neq j}, @math{Q_{i, j}} is the transition rate -from state @math{i} to state @math{j}. The elements @math{Q_{i, i}} -qre defined as @math{Q_{i, i} = - \sum_{j \neq i} Q_{i, j}}, such that -matrix @math{\bf Q} satisfies the property that, for all @math{i}, -@math{\sum_{j=1}^N Q_{i, j} = 0}. +@emph{infinitesimal generator matrix} @math{{\bf Q} = [Q_{i,j}]}, +where for each @math{i \neq j}, @math{Q_{i, j}} is the transition rate +from state @math{i} to state @math{j}. The matrix @math{\bf Q} must +satisfy the property that, for all @math{i}, @math{\sum_{j=1}^N Q_{i, +j} = 0}. @DOCSTRING(ctmc_check_Q) @@ -463,12 +462,13 @@ Similarly to the discrete case, we denote with @math{{\bf \pi}(t) = (\pi_1(t), \pi_2(t), @dots{}, \pi_N(t) )} the @emph{state occupancy -probability vector} at time @math{t}. @math{\pi_i(t)} denotes the -probability that the system is in state @math{i} at time @math{t @geq{} 0}. +probability vector} at time @math{t}. @math{\pi_i(t)} is the +probability that the system is in state @math{i} at time @math{t +@geq{} 0}. Given the infinitesimal generator matrix @math{\bf Q} and the initial -state occupancy probability vector @math{{\bf \pi}(0) = (\pi_1(0), -\pi_2(0), @dots{}, \pi_N(0))}, the state occupancy probability vector +state occupancy probabilities @math{{\bf \pi}(0) = (\pi_1(0), +\pi_2(0), @dots{}, \pi_N(0))}, the state occupancy probabilities @math{{\bf \pi}(t)} at time @math{t} can be computed as: @iftex @@ -488,9 +488,8 @@ of @math{{\bf Q} t}. Under certain conditions, there exists a @emph{stationary state occupancy probability} @math{{\bf \pi} = \lim_{t \rightarrow +\infty} {\bf \pi}(t)}, which is independent from -the initial state occupancy @math{{\bf \pi}(0)}. The stationary state -occupancy probability vector @math{\bf \pi} can be computed as the -solution of the following linear system: +@math{{\bf \pi}(0)}. @math{\bf \pi} is the solution of the following +linear system: @iftex @tex Modified: trunk/octave-forge/main/queueing/doc/queueing.html =================================================================== --- trunk/octave-forge/main/queueing/doc/queueing.html 2012-03-23 01:59:38 UTC (rev 10018) +++ trunk/octave-forge/main/queueing/doc/queueing.html 2012-03-24 09:46:42 UTC (rev 10019) @@ -60,8 +60,8 @@ <li><a href="#Birth_002ddeath-process-_0028DTMC_0029">4.1.2 Birth-death process</a> <li><a href="#Expected-number-of-visits-_0028DTMC_0029">4.1.3 Expected Number of Visits</a> <li><a href="#Time_002daveraged-expected-sojourn-times-_0028DTMC_0029">4.1.4 Time-averaged expected sojourn times</a> -<li><a href="#First-passage-times-_0028DTMC_0029">4.1.5 First Passage Times</a> -<li><a href="#Mean-time-to-absorption-_0028DTMC_0029">4.1.6 Mean Time to Absorption</a> +<li><a href="#Mean-time-to-absorption-_0028DTMC_0029">4.1.5 Mean Time to Absorption</a> +<li><a href="#First-passage-times-_0028DTMC_0029">4.1.6 First Passage Times</a> </li></ul> <li><a href="#Continuous_002dTime-Markov-Chains">4.2 Continuous-Time Markov Chains</a> <ul> @@ -573,7 +573,7 @@ routing of jobs within the network is described with a <em>routing probability matrix</em> P. Specifically, a request completing service at center i is enqueued at center j with -probability P_ij. Let us assume the following routing +probability P_i, j. Let us assume the following routing probability matrix: <pre class="example"> [ 0 0.3 0.7 ] @@ -611,7 +611,7 @@ <pre class="example"> V_j = sum_i V_i P_ij </pre> <p>We can compute V_k from the routing probability matrix -P_ij using the <samp><span class="command">qnvisits</span></samp> function: +P_i, j using the <samp><span class="command">qnvisits</span></samp> function: <pre class="example"> <kbd>P = [0 0.3 0.7; 1 0 0; 1 0 0];</kbd> <kbd>V = qnvisits(P)</kbd> @@ -715,7 +715,7 @@ <pre class="example"> V_j = sum_i V_i P_ij </pre> - <p>where P_0j is the probability of an external arrival to + <p>where P_0, j is the probability of an external arrival to center j. This can be computed as: <p>Assuming the same service times as in the previous example, the @@ -794,29 +794,29 @@ <h3 class="section">4.1 Discrete-Time Markov Chains</h3> <p>Let X_0, X_1, <small class="dots">...</small>, X_n, <small class="dots">...</small> be a sequence of random -variables, each one defined over a discete state space 0, 1, 2, +variables defined over a discete state space 0, 1, 2, <small class="dots">...</small>. The sequence X_0, X_1, <small class="dots">...</small>, X_n, <small class="dots">...</small> is a <em>stochastic process</em> with discrete time 0, 1, 2, <small class="dots">...</small>. A <em>Markov chain</em> is a stochastic process {X_n, -n=0, 1, 2, <small class="dots">...</small>} which satisfies the following Marrkov property: +n=0, 1, 2, <small class="dots">...</small>} which satisfies the following Markov property: <p>P(X_n+1 = x_n+1 | X_n = x_n, X_n-1 = x_n-1, ..., X_0 = x_0) = P(X_n+1 = x_n+1 | X_n = x_n) -<p class="noindent">which means that the probability that the system is in +<p class="noindent">which basically means that the probability that the system is in a particular state at time n+1 only depends on the state the system was at time n. <p>The evolution of a Markov chain with finite state space {1, 2, <small class="dots">...</small>, N} can be fully described by a stochastic matrix \bf -P(n) = P_i,j(n) such that P_i, j(n) = P( X_n+1 = j\ |\ -X_n = i ). If the Markov chain is homogeneous (that is, the +P(n) = [ P_i,j(n) ] such that P_i, j(n) = P( X_n+1 = j\ +|\ X_n = i ). If the Markov chain is homogeneous (that is, the transition probability matrix \bf P(n) is time-independent), -we can simply write \bf P = P_i, j, where P_i, j = -P( X_n+1 = j\ |\ X_n = i ) for all n=0, 1, 2, <small class="dots">...</small>. +we can write \bf P = [P_i, j], where P_i, j = P( +X_n+1 = j\ |\ X_n = i ) for all n=0, 1, <small class="dots">...</small>. <p>The transition probability matrix \bf P must satisfy the following two properties: (1) P_i, j ≥ 0 for all -i, j, and (2) \sum_j=1^N P_i,j = 1. +i, j, and (2) \sum_j=1^N P_i,j = 1 for all i <p><a name="doc_002ddtmc_005fcheck_005fP"></a> @@ -836,8 +836,8 @@ <li><a accesskey="2" href="#Birth_002ddeath-process-_0028DTMC_0029">Birth-death process (DTMC)</a> <li><a accesskey="3" href="#Expected-number-of-visits-_0028DTMC_0029">Expected number of visits (DTMC)</a> <li><a accesskey="4" href="#Time_002daveraged-expected-sojourn-times-_0028DTMC_0029">Time-averaged expected sojourn times (DTMC)</a> -<li><a accesskey="5" href="#First-passage-times-_0028DTMC_0029">First passage times (DTMC)</a> -<li><a accesskey="6" href="#Mean-time-to-absorption-_0028DTMC_0029">Mean time to absorption (DTMC)</a> +<li><a accesskey="5" href="#Mean-time-to-absorption-_0028DTMC_0029">Mean time to absorption (DTMC)</a> +<li><a accesskey="6" href="#First-passage-times-_0028DTMC_0029">First passage times (DTMC)</a> </ul> <div class="node"> @@ -851,26 +851,32 @@ <h4 class="subsection">4.1.1 State occupancy probabilities</h4> -<p>We denote with \bf \pi(n) = (\pi_1(n), \pi_2(n), <small class="dots">...</small>, -\pi_N(n) ) the <em>state occupancy probability vector</em> at step -n. \pi_i(n) denotes the probability that the system is -in state i at step n. +<p>We denote with \bf \pi(n) = \left(\pi_1(n), \pi_2(n), <small class="dots">...</small>, +\pi_N(n) \right) the <em>state occupancy probability vector</em> at +step n. \pi_i(n) denotes the probability that the system +is in state i after n transitions. <p>Given the transition probability matrix \bf P and the initial -state occupancy probability vector \bf \pi(0) = (\pi_1(0), -\pi_2(0), <small class="dots">...</small>, \pi_N(0)) at step 0, the state occupancy -probability vector \bf \pi(n) at step n can be -computed as: +state occupancy probability vector \bf \pi(0) = +\left(\pi_1(0), \pi_2(0), <small class="dots">...</small>, \pi_N(0)\right), \bf +\pi(n) can be computed as: <pre class="example"> \pi(n) = \pi(0) P^n </pre> <p>Under certain conditions, there exists a <em>stationary state occupancy probability</em> \bf \pi = \lim_n \rightarrow +\infty -\bf \pi(n), which is independent from the initial state occupancy -\bf \pi(0). The stationary state occupancy probability vector -\bf \pi satisfies \bf \pi = \bf \pi \bf P -and \sum_i=1^N \pi_i = 1 +\bf \pi(n), which is independent from \bf \pi(0). The +stationary vector \bf \pi is the solution of the following +linear system: +<pre class="example"> / + | \pi P = \pi + | \pi 1^T = 1 + \ +</pre> + <p class="noindent">where \bf 1 is the row vector of ones, and ( \cdot )^T +the transpose operator. + <p><a name="doc_002ddtmc"></a> <div class="defun"> @@ -891,10 +897,11 @@ <dl> <dt><var>P</var><dd><var>P</var><code>(i,j)</code> is the transition probability from state i to state j. <var>P</var> must be an irreducible stochastic matrix, -which means that the sum of each row must be 1 (\sum_j=1^N P_i j = 1), and the rank of +which means that the sum of each row must be 1 (\sum_j=1^N P_i, j = 1), and the rank of <var>P</var> must be equal to its dimension. - <br><dt><var>n</var><dd>Step at which to compute the transient probability + <br><dt><var>n</var><dd>Number of transitions after which compute the state occupancy probabilities +(n=0, 1, <small class="enddots">...</small>) <br><dt><var>p0</var><dd><var>p0</var><code>(i)</code> is the probability that at step 0 the system is in state i. @@ -908,7 +915,7 @@ <var>p</var><code>(i)</code> is the steady-state probability that the system is in state i. <var>p</var> satisfies the equations p = p\bf P and \sum_i=1^N p_i = 1. If this function is invoked with three arguments, <var>p</var><code>(i)</code> is the marginal probability -that the system is in state i at step <var>n</var>, +that the system is in state i after <var>n</var> transitions, given the initial probabilities <var>p0</var><code>(i)</code> that the initial state is i. @@ -918,21 +925,62 @@ <p class="noindent"><strong>EXAMPLE</strong> -<pre class="example"><pre class="verbatim"> a = 0.2; - b = 0.15; - P = [ 1-a a; b 1-b]; - T = 0:14; - pp = zeros(2,length(T)); - for i=1:length(T) - pp(:,i) = dtmc(P,T(i),[1 0]); - endfor - ss = dtmc(P); # compute steady state probabilities - plot( T, pp(1,:), "b+;p_0(t);", "linewidth", 2, \ - T, ss(1)*ones(size(T)), "b;Steady State;", \ - T, pp(2,:), "r+;p_1(t);", "linewidth", 2, \ - T, ss(2)*ones(size(T)), "r;Steady State;" ); - xlabel("Time Step");</pre> + <p>This example is from [GrSn97]. Let us consider a maze with nine rooms, +as shown in the following figure + +<pre class="example"> +-----+-----+-----+ + | | | | + | 1 2 3 | + | | | | + +- -+- -+- -+ + | | | | + | 4 5 6 | + | | | | + +- -+- -+- -+ + | | | | + | 7 8 9 | + | | | | + +-----+-----+-----+ </pre> + <p>A mouse is placed in one of the rooms and can wander around. At each +step, the mouse moves from the current room to a neighboring one with +equal probability: if it is in room 1, it can move to room 2 and 4 +with probability 1/2, respectively. If the mouse is in room 8, it can +move to either 7, 5 or 9 with probability 1/3. + + <p>The transition probability \bf P from room i to room +j is the following: + +<pre class="example"> / 0 1/2 0 1/2 0 0 0 0 0 \ + | 1/3 0 1/3 0 1/3 0 0 0 0 | + | 0 1/2 0 0 0 1/2 0 0 0 | + | 1/3 0 0 0 1/3 0 1/3 0 0 | + P = | 0 1/4 0 1/4 0 1/4 0 1/4 0 | + | 0 0 1/3 0 1/3 0 0 0 1/3 | + | 0 0 0 1/2 0 0 0 1/2 0 | + | 0 0 0 0 1/3 0 1/3 0 1/3 | + \ 0 0 0 0 0 1/2 0 1/2 0 / +</pre> + <p>The stationary state occupancy probability vector can be computed +using the following code: + +<pre class="example"> <!-- @group --> +<pre class="verbatim"> P = zeros(9,9); + P(1,[2 4] ) = 1/2; + P(2,[1 5 3] ) = 1/3; + P(3,[2 6] ) = 1/2; + P(4,[1 5 7] ) = 1/3; + P(5,[2 4 6 8]) = 1/4; + P(6,[3 5 9] ) = 1/3; + P(7,[4 8] ) = 1/2; + P(8,[7 5 9] ) = 1/3; + P(9,[6 8] ) = 1/2; + p = dtmc(P); + disp(p)</pre><!-- @end group --> + ⇒ 0.083333 0.125000 0.083333 0.125000 + 0.166667 0.125000 0.083333 0.125000 + 0.083333 +</pre> <div class="node"> <a name="Birth-death-process-(DTMC)"></a> <a name="Birth_002ddeath-process-_0028DTMC_0029"></a> @@ -948,30 +996,29 @@ <p><a name="doc_002ddtmc_005fbd"></a> <div class="defun"> -— Function File: <var>P</var> = <b>dtmc_bd</b> (<var>birth, death</var>)<var><a name="index-dtmc_005fbd-11"></a></var><br> +— Function File: <var>P</var> = <b>dtmc_bd</b> (<var>b, d</var>)<var><a name="index-dtmc_005fbd-11"></a></var><br> <blockquote> <p><a name="index-Markov-chain_002c-discrete-time-12"></a><a name="index-Birth_002ddeath-process-13"></a> -Returns the N \times N transition probability matrix P -for a birth-death process with given rates. +Returns the transition probability matrix P for a discrete +birth-death process over state space 1, 2, <small class="dots">...</small>, N. +<var>b</var><code>(i)</code> is the transition probability from state +i to i+1, and <var>d</var><code>(i)</code> is the transition +probability from state i+1 to state i, i=1, 2, +<small class="dots">...</small>, N-1. - <p><strong>INPUTS</strong> + <p>Matrix \bf P is therefore defined as: - <dl> -<dt><var>birth</var><dd>Vector with N-1 elements, where <var>birth</var><code>(i)</code> is the -transition probability from state i to state i+1. - - <br><dt><var>death</var><dd>Vector with N-1 elements, where <var>death</var><code>(i)</code> is the -transition probability from state i+1 to state i. - - </dl> - - <p><strong>OUTPUTS</strong> - - <dl> -<dt><var>P</var><dd>Transition probability matrix for the birth-death process. - - </dl> - + <pre class="example"> / \ + | 1-b(1) b(1) | + | d(1) (1-d(1)-b(2)) b(2) | + | d(2) (1-d(2)-b(3)) b(3) | + | | + | ... ... ... | + | | + | d(N-2) (1-d(N-2)-b(N-1)) b(N-1) | + | d(N-1) 1-d(N-1) | + \ / +</pre> </blockquote></div> <div class="node"> @@ -988,9 +1035,9 @@ <p>Given a N state discrete-time Markov chain with transition matrix \bf P and an integer n ≥ 0, we let -L-I(n) be the the expected number of visits to state i +L_i(n) be the the expected number of visits to state i during the first n transitions. The vector \bf L(n) = -(L_1(n), L_2(n), <small class="dots">...</small>, L_N(n)) is defined as: +( L_1(n), L_2(n), <small class="dots">...</small>, L_N(n) ) is defined as <pre class="example"> n n ___ ___ @@ -999,25 +1046,24 @@ /___ /___ i=0 i=0 </pre> - <p class="noindent">where \bf \pi(i) = \bf \pi(0)\bf P^i is the state occupancy probability -after i transitions. + <p class="noindent">where \bf \pi(i) = \bf \pi(0)\bf P^i is the state +occupancy probability after i transitions. - <p>If \bf P is absorbing, we can rearrange the states to rewrite -\bf P as: + <p>If \bf P has absorbing states, that is, states with no out +transitions, we can rearrange the states to rewrite \bf P as: <pre class="example"> / Q | R \ P = |---+---| \ 0 | I / </pre> - <p class="noindent">where we suppose that the first t states are transient -and the last r states are absorbing. - - <p>The matrix \bf N = (\bf I - \bf Q)^-1 is called the + <p class="noindent">where the first t states are transient +and the last r states are absorbing (t+r = N). The +matrix \bf N = (\bf I - \bf Q)^-1 is called the <em>fundamental matrix</em>; N(i,j) represents the expected number of times that the process is in the j-th transient state if it is started in the i-th transient state. If we reshape \bf N to the size of \bf P (filling missing entries with -zeros), we have that, for abrosbing chains \bf L = \bf +zeros), we have that, for absorbing chains \bf L = \bf \pi(0)\bf N. <p><a name="doc_002ddtmc_005fexps"></a> @@ -1036,11 +1082,11 @@ <dt><var>P</var><dd>N \times N transition probability matrix. <br><dt><var>n</var><dd>Number of steps during which the expected number of visits are -computed (<var>n</var> ≥ 0). If <var>n</var><code>=0</code>, simply -returns <var>p0</var>. If <var>n</var><code> > 0</code>, returns the expected number -of visits after exactly <var>n</var> transitions. +computed (<var>n</var> ≥ 0). If <var>n</var><code>=0</code>, returns +<var>p0</var>. If <var>n</var><code> > 0</code>, returns the expected number of +visits after exactly <var>n</var> transitions. - <br><dt><var>p0</var><dd>Initial state occupancy probability + <br><dt><var>p0</var><dd>Initial state occupancy probability. </dl> @@ -1050,7 +1096,8 @@ <dt><var>L</var><dd>When called with two arguments, <var>L</var><code>(i)</code> is the expected number of visits to transient state i before absorption. When called with three arguments, <var>L</var><code>(i)</code> is the expected number -of visits to state i during the first <var>n</var> transitions. +of visits to state i during the first <var>n</var> transitions, +given initial occupancy probability <var>p0</var>. </dl> @@ -1065,7 +1112,7 @@ <a name="Time-averaged-expected-sojourn-times-(DTMC)"></a> <a name="Time_002daveraged-expected-sojourn-times-_0028DTMC_0029"></a> <p><hr> -Next: <a rel="next" accesskey="n" href="#First-passage-times-_0028DTMC_0029">First passage times (DTMC)</a>, +Next: <a rel="next" accesskey="n" href="#Mean-time-to-absorption-_0028DTMC_0029">Mean time to absorption (DTMC)</a>, Previous: <a rel="previous" accesskey="p" href="#Expected-number-of-visits-_0028DTMC_0029">Expected number of visits (DTMC)</a>, Up: <a rel="up" accesskey="u" href="#Discrete_002dTime-Markov-Chains">Discrete-Time Markov Chains</a> @@ -1091,7 +1138,7 @@ <dt><var>Q</var><dd>Infinitesimal generator matrix. <var>Q</var><code>(i,j)</code> is the transition rate from state i to state j, 1 ≤ i \neq j ≤ N. The -matrix <var>Q</var> must also satisfy the condition \sum_j=1^N Q_ij = 0 +matrix <var>Q</var> must also satisfy the condition \sum_j=1^N Q_i, j = 0 <br><dt><var>t</var><dd>Time. If omitted, the results are computed until absorption. @@ -1115,84 +1162,43 @@ </blockquote></div> <div class="node"> -<a name="First-passage-times-(DTMC)"></a> -<a name="First-passage-times-_0028DTMC_0029"></a> +<a name="Mean-time-to-absorption-(DTMC)"></a> +<a name="Mean-time-to-absorption-_0028DTMC_0029"></a> <p><hr> -Next: <a rel="next" accesskey="n" href="#Mean-time-to-absorption-_0028DTMC_0029">Mean time to absorption (DTMC)</a>, +Next: <a rel="next" accesskey="n" href="#First-passage-times-_0028DTMC_0029">First passage times (DTMC)</a>, Previous: <a rel="previous" accesskey="p" href="#Time_002daveraged-expected-sojourn-times-_0028DTMC_0029">Time-averaged expected sojourn times (DTMC)</a>, Up: <a rel="up" accesskey="u" href="#Discrete_002dTime-Markov-Chains">Discrete-Time Markov Chains</a> </div> -<h4 class="subsection">4.1.5 First Passage Times</h4> +<h4 class="subsection">4.1.5 Mean Time to Absorption</h4> -<p>The First Passage Time M_i j is defined as the average -number of transitions needed to visit state j for the first -time, starting from state i. Matrix \bf M satisfies the -property that +<p>The <em>mean time to absorption</em> is defined as the average number of +transitions which are required to reach an absorbing state, starting +from a transient state (or given an initial state occupancy +probability vector \bf \pi(0) ). -<pre class="example"> ___ - \ - M_ij = 1 + > P_ij * M_kj - /___ - k!=j + <p>Let \bf t_i be the expected number of steps before being +absorbed in any absorbing state, starting from state i. Vector +\bf t can be easiliy computed from the fundamental matrix +\bf N (see <a href="#Expected-number-of-visits-_0028DTMC_0029">Expected number of visits (DTMC)</a>) as + +<pre class="example"> t = 1 N </pre> - <p><a name="doc_002ddtmc_005ffpt"></a> + <p>We can define a matrix \bf B = [ B_i, j ] such that +B_i, j is the probability of being absorbed in state +j, starting from transient state i. Again, using +the fundamental matrix \bf N and \bf R, we have -<div class="defun"> -— Function File: <var>M</var> = <b>dtmc_fpt</b> (<var>P</var>)<var><a name="index-dtmc_005ffpt-20"></a></var><br> -<blockquote> - <p><a name="index-First-passage-times-21"></a><a name="index-Mean-recurrence-times-22"></a> -Compute mean first passage times and mean recurrence times -for an irreducible discrete-time Markov chain. +<pre class="example"> B = N R +</pre> + <p><a name="doc_002ddtmc_005fmtta"></a> - <p><strong>INPUTS</strong> - - <dl> -<dt><var>P</var><dd><var>P</var><code>(i,j)</code> is the transition probability from state i -to state j. <var>P</var> must be an irreducible stochastic matrix, -which means that the sum of each row must be 1 (\sum_j=1^N -P_i j = 1), and the rank of <var>P</var> must be equal to its -dimension. - - </dl> - - <p><strong>OUTPUTS</strong> - - <dl> -<dt><var>M</var><dd>For all i \neq j, <var>M</var><code>(i,j)</code> is the average number of -transitions before state <var>j</var> is reached for the first time, -starting from state <var>i</var>. <var>M</var><code>(i,i)</code> is the <em>mean -recurrence time</em> of state i, and represents the average time -needed to return to state <var>i</var>. - - </dl> - - <pre class="sp"> - - </pre> - <strong>See also:</strong> ctmc_fpt. - - </blockquote></div> - -<div class="node"> -<a name="Mean-time-to-absorption-(DTMC)"></a> -<a name="Mean-time-to-absorption-_0028DTMC_0029"></a> -<p><hr> -Previous: <a rel="previous" accesskey="p" href="#First-passage-times-_0028DTMC_0029">First passage times (DTMC)</a>, -Up: <a rel="up" accesskey="u" href="#Discrete_002dTime-Markov-Chains">Discrete-Time Markov Chains</a> - -</div> - -<h4 class="subsection">4.1.6 Mean Time to Absorption</h4> - -<p><a name="doc_002ddtmc_005fmtta"></a> - <div class="defun"> -— Function File: [<var>t</var> <var>N</var> <var>B</var>] = <b>dtmc_mtta</b> (<var>P</var>)<var><a name="index-dtmc_005fmtta-23"></a></var><br> -— Function File: [<var>t</var> <var>N</var> <var>B</var>] = <b>dtmc_mtta</b> (<var>P, p0</var>)<var><a name="index-dtmc_005fmtta-24"></a></var><br> +— Function File: [<var>t</var> <var>N</var> <var>B</var>] = <b>dtmc_mtta</b> (<var>P</var>)<var><a name="index-dtmc_005fmtta-20"></a></var><br> +— Function File: [<var>t</var> <var>N</var> <var>B</var>] = <b>dtmc_mtta</b> (<var>P, p0</var>)<var><a name="index-dtmc_005fmtta-21"></a></var><br> <blockquote> - <p><a name="index-Mean-time-to-absorption-25"></a><a name="index-Absorption-probabilities-26"></a><a name="index-Fundamental-matrix-27"></a> + <p><a name="index-Mean-time-to-absorption-22"></a><a name="index-Absorption-probabilities-23"></a><a name="index-Fundamental-matrix-24"></a> Compute the expected number of steps before absorption for a DTMC with N \times N transition probability matrix <var>P</var>; compute also the fundamental matrix <var>N</var> for <var>P</var>. @@ -1244,6 +1250,94 @@ </blockquote></div> <div class="node"> +<a name="First-passage-times-(DTMC)"></a> +<a name="First-passage-times-_0028DTMC_0029"></a> +<p><hr> +Previous: <a rel="previous" accesskey="p" href="#Mean-time-to-absorption-_0028DTMC_0029">Mean time to absorption (DTMC)</a>, +Up: <a rel="up" accesskey="u" href="#Discrete_002dTime-Markov-Chains">Discrete-Time Markov Chains</a> + +</div> + +<h4 class="subsection">4.1.6 First Passage Times</h4> + +<p>The First Passage Time M_i, j is defined as the average +number of transitions needed to visit state j for the first +time, starting from state i. Matrix \bf M satisfies the +property that + +<pre class="example"> ___ + \ + M_ij = 1 + > P_ij * M_kj + /___ + k!=j +</pre> + <p>To compute \bf M = [ M_i, j] a different formulation is +used. Let \bf W be the N \times N matrix having each +row equal to the steady-state probability vector \bf \pi for +\bf P; let \bf I be the N \times N identity +matrix. Define matrix \bf Z as follows: + +<pre class="example"> -1 + Z = (I - P + W) +</pre> + <p class="noindent">Then, we have that + +<pre class="example"> Z_jj - Z_ij + M_ij = ----------- + \pi_j +</pre> + <p>According to the definition above, M_i,i = 0. We arbitrarily +redefine M_i,i to be the <em>mean recurrence time</em> +r_i for state i, that is the average number of +transitions needed to return to state i starting from +it. r_i is defined as: + +<pre class="example"> 1 + r_i = ----- + \pi_i +</pre> + <p class="noindent">where \pi_i is the stationary probability of visiting state +i. + + <p><a name="doc_002ddtmc_005ffpt"></a> + +<div class="defun"> +— Function File: <var>M</var> = <b>dtmc_fpt</b> (<var>P</var>)<var><a name="index-dtmc_005ffpt-25"></a></var><br> +<blockquote> + <p><a name="index-First-passage-times-26"></a><a name="index-Mean-recurrence-times-27"></a> +Compute mean first passage times and mean recurrence times +for an irreducible discrete-time Markov chain. + + <p><strong>INPUTS</strong> + + <dl> +<dt><var>P</var><dd><var>P</var><code>(i,j)</code> is the transition probability from state i +to state j. <var>P</var> must be an irreducible stochastic matrix, +which means that the sum of each row must be 1 (\sum_j=1^N +P_i j = 1), and the rank of <var>P</var> must be equal to its +dimension. + + </dl> + + <p><strong>OUTPUTS</strong> + + <dl> +<dt><var>M</var><dd>For all i \neq j, <var>M</var><code>(i,j)</code> is the average number of +transitions before state <var>j</var> is reached for the first time, +starting from state <var>i</var>. <var>M</var><code>(i,i)</code> is the <em>mean +recurrence time</em> of state i, and represents the average time +needed to return to state <var>i</var>. + + </dl> + + <pre class="sp"> + + </pre> + <strong>See also:</strong> ctmc_fpt. + + </blockquote></div> + +<div class="node"> <a name="Continuous-Time-Markov-Chains"></a> <a name="Continuous_002dTime-Markov-Chains"></a> <p><hr> @@ -1256,17 +1350,17 @@ <p>A stochastic process {X(t), t ≥ 0} is a continuous-time Markov chain if, for all integers n, and for any sequence -t_0, t_1 , \ldots , t_n, t_n+1 such that t_0 < t_1 < +t_0, t_1 , \ldots, t_n, t_n+1 such that t_0 < t_1 < \ldots < t_n < t_n+1, we have <p>P(X_n+1 = x_n+1 | X_n = x_n, X_n-1 = x_n-1, ..., X_0 = x_0) = P(X_n+1 = x_n+1 | X_n = x_n) <p>A continuous-time Markov chain is defined according to an -<em>infinitesimal generator matrix</em> \bf Q = [Q_i,j] such -that for each i \neq j, Q_i, j is the transition rate -from state i to state j. The elements Q_i, i -must be defined in such a way that the infinitesimal generator matrix -\bf Q satisfies the property \sum_j=1^N Q_i,j = 0. +<em>infinitesimal generator matrix</em> \bf Q = [Q_i,j], +where for each i \neq j, Q_i, j is the transition rate +from state i to state j. The matrix \bf Q must +satisfy the property that, for all i, \sum_j=1^N Q_i, +j = 0. <p><a name="doc_002dctmc_005fcheck_005fQ"></a> @@ -1303,12 +1397,13 @@ <p>Similarly to the discrete case, we denote with \bf \pi(t) = (\pi_1(t), \pi_2(t), <small class="dots">...</small>, \pi_N(t) ) the <em>state occupancy -probability vector</em> at time t. \pi_i(t) denotes the -probability that the system is in state i at time t ≥ 0. +probability vector</em> at time t. \pi_i(t) is the +probability that the system is in state i at time t +≥ 0. <p>Given the infinitesimal generator matrix \bf Q and the initial -state occupancy probability vector \bf \pi(0) = (\pi_1(0), -\pi_2(0), <small class="dots">...</small>, \pi_N(0)), the state occupancy probability vector +state occupancy probabilities \bf \pi(0) = (\pi_1(0), +\pi_2(0), <small class="dots">...</small>, \pi_N(0)), the state occupancy probabilities \bf \pi(t) at time t can be computed as: <pre class="example"> \pi(t) = \pi(0) exp(Qt) @@ -1317,10 +1412,14 @@ of \bf Q t. Under certain conditions, there exists a <em>stationary state occupancy probability</em> \bf \pi = \lim_t \rightarrow +\infty \bf \pi(t), which is independent from -the initial state occupancy \bf \pi(0). The stationary state -occupancy probability vector \bf \pi satisfies -\bf \pi \bf Q = \bf 0 and \sum_i=1^N \pi_i = 1. +\bf \pi(0). \bf \pi is the solution of the following +linear system: +<pre class="example"> / + | \pi Q = 0 + | \pi 1^T = 1 + \ +</pre> <p><a name="doc_002dctmc"></a> <div class="defun"> @@ -1342,12 +1441,12 @@ <dt><var>Q</var><dd>Infinitesimal generator matrix. <var>Q</var> is a N \times N square matrix where <var>Q</var><code>(i,j)</code> is the transition rate from state i to state j, for 1 ≤ i \neq j ≤ N. -Transition rates must be nonnegative, and \sum_j=1^N Q_i j = 0 +Transition rates must be nonnegative, and \sum_j=1^N Q_i, j = 0 <br><dt><var>t</var><dd>Time at which to compute the transient probability <br><dt><var>p0</var><dd><var>p0</var><code>(i)</code> is the probability that the system -is in state i at time 0 . +is in state i at time 0. </dl> @@ -1390,30 +1489,28 @@ <p><a name="doc_002dctmc_005fbd"></a> <div class="defun"> -— Function File: <var>Q</var> = <b>ctmc_bd</b> (<var>birth, death</var>)<var><a name="index-ctmc_005fbd-36"></a></var><br> +— Function File: <var>Q</var> = <b>ctmc_bd</b> (<var>b, d</var>)<var><a name="index-ctmc_005fbd-36"></a></var><br> <blockquote> <p><a name="index-Markov-chain_002c-continuous-time-37"></a><a name="index-Birth_002ddeath-process-38"></a> -Returns the N \times N infinitesimal generator matrix Q -for a birth-death process with given rates. +Returns the infinitesimal generator matrix Q for a continuous +birth-death process over state space 1, 2, <small class="dots">...</small>, N. +<var>b</var><code>(i)</code> is the transition rate from state i to +i+1, and <var>d</var><code>(i)</code> is the transition rate from state +i+1 to state i, i=1, 2, <small class="dots">...</small>, N-1. - <p><strong>INPUTS</strong> + <p>Matrix \bf Q is therefore defined as: - <dl> -<dt><var>birth</var><dd>Vector with N-1 elements, where <var>birth</var><code>(i)</code> is the -transition rate from state i to state i+1. - - <br><dt><var>death</var><dd>Vector with N-1 elements, where <var>death</var><code>(i)</code> is the -transition rate from state i+1 to state i. - - </dl> - - <p><strong>OUTPUTS</strong> - - <dl> -<dt><var>Q</var><dd>Infinitesimal generator matrix for the birth-death process. - - </dl> - + <pre class="example"> / \ + | -b(1) b(1) | + | d(1) -(d(1)+b(2)) b(2) | + | d(2) -(d(2)+b(3)) b(3) | + | | + | ... ... ... | + | | + | d(N-2) -(d(N-2)+b(N-1)) b(N-1) | + | d(N-1) -d(N-1) | + \ / +</pre> </blockquote></div> <div class="node"> @@ -1430,11 +1527,11 @@ <p>Given a N state continuous-time Markov Chain with infinitesimal generator matrix \bf Q, we define the vector \bf L(t) = -(L_1(t), L_2(t), \ldots L_N(t)) such that L_i(t) is the +(L_1(t), L_2(t), \ldots, L_N(t)) such that L_i(t) is the expected sojourn time in state i during the interval [0,t), assuming that the initial occupancy probability at time -0 was \bf \pi(0). \bf L(t) is the solution of -the following differential equation: +0 was \bf \pi(0). \bf L(t) can be expressed as the +solution of the following differential equation: <pre class="example"> dL --(t) = L(t) Q + pi(0), L(0) = 0 @@ -1444,11 +1541,12 @@ form as: <pre class="example"> / t - L(t) = | pi(u) du - / u=0 + L(t) = | pi(u) du + / 0 </pre> <p class="noindent">where \bf \pi(t) = \bf \pi(0) \exp(\bf Qt) is -the state occupancy probability at time t. +the state occupancy probability at time t; \exp(\bf Qt) +is the matrix exponential of \bf Qt. <p><a name="doc_002dctmc_005fexps"></a> @@ -1471,7 +1569,7 @@ ≤ i \neq j ≤ N. The matrix <var>Q</var> must also satisfy the condition \sum_j=1^N Q_ij = 0. - <br><dt><var>t</var><dd>Time + <br><dt><var>t</var><dd>If given, compute the expected sojourn times in [0,t] <br><dt><var>p</var><dd>Initial occupancy probability vector; <var>p</var><code>(i)</code> is the probability the system is in state i at time 0, i = 1, @@ -1485,9 +1583,9 @@ <dt><var>L</var><dd>If this function is called with three arguments, <var>L</var><code>(i)</code> is the expected time spent in state i during the interval [0,t]. If this function is called with two arguments -<var>L</var><code>(i)</code> is either the expected time spent in state i until -absorption (if i is a transient state), or zero -(if <var>i</var> is an absorbing state). +<var>L</var><code>(i)</code> is either the expected time spent in state i +until absorption (if i is a transient state), or zero (if +<var>i</var> is an absorbing state). </dl> @@ -1503,10 +1601,9 @@ <pre class="example"><pre class="verbatim"> lambda = 0.5; N = 4; - birth = lambda*linspace(1,N-1,N-1); - death = zeros(1,N-1); - Q = diag(birth,1)+diag(death,-1); - Q -= diag(sum(Q,2)); + b = lambda*[1:N-1]; + d = zeros(size(b)); + Q = ctmc_bd(b,d); t = linspace(0,10,100); p0 = zeros(1,N); p0(1)=1; L = zeros(length(t),N); @@ -2480,11 +2577,12 @@ service, and the instant at which service finishes and the request moves to another queue (or exits the system). - <br><dt>P_ij<dd>Routing probability matrix. \bf P = P_ij is a K \times -K matrix such that P_ij is the probability that a request -completing service at server i will move directly to server -j, The probability that a request leaves the system after service -at service center i is 1-\sum_j=1^K P_ij. + <br><dt>P_i, j<dd>Routing probability matrix. \bf P = P_i, j is a K +\times K matrix such that P_i, j is the probability that a +request completing service at server i will move directly to +server j, The probability that a request leaves the system +after service at service center i is 1-\sum_j=1^K P_i, +j. <br><dt>V_i<dd>Average number of visits. V_i is the average number of visits to the service center i. This quantity will be described shortly. @@ -2529,56 +2627,71 @@ external arrival rate of requests to the system. The average number of visits satisfy the following equation: -<pre class="example"> V == P0 + V*P; +<pre class="example"> K + ___ + \ + V_j = P_(0, j) + > V_i P_(i, j) + /___ + i=1 </pre> - <p class="noindent">where P_0 j is the probability that an external + <p class="noindent">where P_0, j is the probability that an external arrival goes to service center j. If \lambda_j is the external arrival rate to service center j, and \lambda = \sum_j \lambda_j is the overall external arrival rate, then -P_0 j = \lambda_j / \lambda. +P_0, j = \lambda_j / \lambda. <p>For closed models, the visit ratios satisfy the following equation: -<pre class="example"> V(1) == 1 && V == V*P; +<pre class="example"> + V_1 = 1 + + K + ___ + \ + V_j = > V_i P_(i, j) + /___ + i=1 + + V(1) == 1 && V == V*P; </pre> <h4 class="subsection">6.1.2 Multiple class models</h4> <p>In multiple class QN models, we assume that there exist C different classes of requests. Each request from class c spends -on average time S_ck in service at service center k. For -open models, we denote with \bf \lambda = \lambda_ck the -arrival rates, where \lambda_ck is the external arrival rate of -class c customers at service center k. For closed models, -we denote with \bf N = (N_1, N_2, \ldots N_C) the population -vector, where N_c is the number of class c requests in the -system. +on average time S_c, k in service at service center +k. For open models, we denote with \bf \lambda = +\lambda_ck the arrival rates, where \lambda_c, k is the +external arrival rate of class c customers at service center +k. For closed models, we denote with \bf N = (N_1, N_2, +\ldots, N_C) the population vector, where N_c is the number of +class c requests in the system. <p>The transition probability matrix for these kind of networks will be a -C \times K \times C \times K matrix \bf P = -P_risj such that P_risj is the probability that a -class r request which completes service at center i will -join server j as a class s request. +C \times K \times C \times K matrix \bf P = P_r, i, s, j +such that P_r, i, s, j is the probability that a class +r request which completes service at center i will join +server j as a class s request. - <p>Model input and outputs can be adjusted by adding additional -indexes for the customer classes. + <p>Model input and outputs can be adjusted by adding additional indexes +for the customer classes. <p class="noindent"><strong>Model Inputs</strong> <dl> -<dt>\lambda_ci<dd>External arrival rate of class-c requests to service center i +<dt>\lambda_c, i<dd>External arrival rate of class-c requests to service center i - <br><dt>\lambda<dd>Overall external arrival rate to the whole system: \lambda = \sum_c \sum_i \lambda_ci + <br><dt>\lambda<dd>Overall external arrival rate to the whole system: \lambda = \sum_c \sum_i \lambda_c, i - <br><dt>S_ci<dd>Average service time. S_ci is the average service time on service -center i for class c requests. + <br><dt>S_c, i<dd>Average service time. S_c, i is the average service time on +service center i for class c requests. - <br><dt>P_risj<dd>Routing probability matrix. \bf P = P_risj is a C -\times K \times C \times K matrix such that P_risj is the -probability that a class r request which completes service at -server i will move to server j as a class s + <br><dt>P_r, i, s, j<dd>Routing probability matrix. \bf P = P_r, i, s, j is a C +\times K \times C \times K matrix such that P_r, i, s, j is +the probability that a class r request which completes service +at server i will move to server j as a class s request. - <br><dt>V_ci<dd>Average number of visits. V_ci is the average number of visits + <br><dt>V_c, i<dd>Average number of visits. V_c, i is the average number of visits of class c requests to the service center i. </dl> @@ -2586,20 +2699,20 @@ <p class="noindent"><strong>Model Outputs</strong> <dl> -<dt>U_ci<dd>Utilization of service center i by class c requests. The +<dt>U_c, i<dd>Utilization of service center i by class c requests. The utilization is defined as the fraction of time in which the resource is busy (i.e., the server is processing requests). - <br><dt>R_ci<dd>Average response time experienced by class c requests on service + <br><dt>R_c, i<dd>Average response time experienced by class c requests on service center i. The average response time is defined as the average time between the arrival of a customer in the queue, and the completion of service. - <br><dt>Q_ci<dd>Average number of class c requests on service center + <br><dt>Q_c, i<dd>Average number of class c requests on service center i. This includes both the requests in the queue, and the request being served. - <br><dt>X_ci<dd>Throughput of service center i for class c requests. The + <br><dt>X_c, i<dd>Throughput of service center i for class c requests. The throughput is defined as the rate of completion of class c requests. @@ -2622,7 +2735,7 @@ </dl> - <p>We can define the visit ratios V_sj for class s + <p>We can define the visit ratios V_s, j for class s customers at service center j as follows: <p>V_sj = sum_r sum_i V_ri P_risj, for all s,j @@ -2631,12 +2744,12 @@ <p>V_sj = P_0sj + sum_r sum_i V_ri P_risj, for all s,j -<p class="noindent">where P_0sj is the probability that an external +<p class="noindent">where P_0, s, j is the probability that an external arrival goes to service center j as a class-s request. -If \lambda_sj is the external arrival rate of class s -requests to service center j, and \lambda = \sum_s \sum_j -\lambda_sj is the overall external arrival rate to the whole system, -then P_0sj = \lambda_sj / \lambda. +If \lambda_s, j is the external arrival rate of class +s requests to service center j, and \lambda = +\sum_s \sum_j \lambda_s, j is the overall external arrival rate to +the whole system, then P_0, s, j = \lambda_s, j / \lambda. <div class="node"> <a name="Generic-Algorithms"></a> @@ -2826,11 +2939,11 @@ requests in 0.2. Note that service times are class-independent; <li>Node 2 is a -/G/1–PS node, with service times -S_12 = 0.4 for class 1, and S_22 = 0.6 for class 2 +S_1, 2 = 0.4 for class 1, and S_2, 2 = 0.6 for class 2 requests; <li>Node 3 is a -/G/\infty node (delay center), with service -times S_13=1 and S_23=2 for class 1 and 2 +times S_1, 3=1 and S_2, 3=2 for class 1 and 2 respectively. </ul> @@ -2910,8 +3023,8 @@ </ul> <p>We define the <em>joint probability vector</em> \pi(k_1, k_2, -\ldots k_N) as the steady-state probability that there are k_i -requests at service center i, for all i=1,2, \ldots N. +\ldots, k_N) as the steady-state probability that there are k_i +requests at service center i, for all i=1, 2, \ldots, N. Jackson networks have the property that the joint probability is the product of the marginal probabilities \pi_i: @@ -3020,12 +3133,12 @@ <pre class="example"> k = [k1, k2, ... kn]; <span class="roman">population vector</span> p = 1/G(N+1) \prod F(i,k); </pre> - <p>Here \pi(k_1, k_2, \ldots k_K) is the joint probability of -having k_i requests at node i, for all i=1,2, -\ldots K. + <p>Here \pi(k_1, k_2, \ldots, k_K) is the joint probability of +having k_i requests at node i, for all i=1, 2, +\ldots, K. <p>The <em>convolution algorithms</em> computes the normalization constants -G = (G(0), G(1), \ldots G(N)) for single-class, closed networks +\bf G = \left(G(0), G(1), \ldots, G(N)\right) for single-class, closed networks with N requests. The normalization constants are returned as vector <var>G</var><code>=[</code><var>G</var><code>(1), </code><var>G</var><code>(2), ... </code><var>G</var><code>(N+1)]</code> where <var>G</var><code>(i+1)</code> is the value of G(i) (remember that Octave @@ -3104,7 +3217,7 @@ <p>The normalization constant G can be used to compute the steady-state probabilities for a closed single class product-form Queueing Network with K nodes. Let <var>k</var><code>=[k_1, -k_2, ... k_K]</code> be a valid population vector. Then, the +k_2, ..., k_K]</code> be a valid population vector. Then, the steady-state probability <var>p</var><code>(i)</code> to have <var>k</var><code>(i)</code> requests at service center i can be computed as: @@ -3876,7 +3989,7 @@ <p class="noindent"><strong>NOTE</strong> <p>Given a network with K service centers, C job classes and -population vector \bf N=(N_1, N_2, \ldots N_C), the MVA +population vector \bf N=(N_1, N_2, \ldots, N_C), the MVA algorithm requires space O(C \prod_i (N_i + 1)). The time complexity is O(CK\prod_i (N_i + 1)). This implementation is slightly more space-efficient (see details in the code). While the space @@ -4234,14 +4347,14 @@ <li>Average service times are load-independent. - <li>P_ij is the probability that requests completing + <li>P_i, j is the probability that requests completing execution at center i are transferred to center j, i \neq j. For open networks, a request may leave the system -from any node i with probability 1-\sum_j P_ij. +from any node i with probability 1-\sum_j P_i, j. <li>Blocking type is Repetitive-Service (RS). Service center j is <em>saturated</em> if the number of requests is equal -to its capacity <code>C_j</code>. Under the RS blocking discipline, +to its capacity C_j. Under the RS blocking discipline, a request completing service at center i which is being transferred to a saturated server j is put back at the end of the queue of i and will receive service again. Center i @@ -4701,18 +4814,18 @@ <pre class="example"> V == P0 + V*P; </pre> - <p class="noindent">where P_0 j is the probability that an external + <p class="noindent">where P_0, j is the probability that an external arrival goes to service center j. If \lambda_j is the external arrival rate to service center j, and \lambda = \sum_j \lambda_j is the overall external arrival rate, then -P_0 j = \lambda_j / \lambda. +P_0, j = \lambda_j / \lambda. <p>For closed networks, the visit ratios satisfy the following equation: <pre class="example"> V(1) == 1 && V == V*P; </pre> <p>The definitions above can be extended to multiple class networks as -follows. We define the visit ratios V_sj for class s +follows. We define the visit ratios V_s, j for class s customers at service center j as follows: <p>V_sj = sum_r sum_i V_ri P_risj, for all s,j @@ -4722,12 +4835,12 @@ <p>V_sj = P_0sj + sum_r sum_i V_ri P_risj, for all s,j -<p class="noindent">where P_0sj is the probability that an external +<p class="noindent">where P_0, s, j is the probability that an external arrival goes to service center j as a class-s request. -If \lambda_sj is the external arrival rate of class s +If \lambda_s, j is the external arrival rate of class s requests to service center j, and \lambda = \sum_s \sum_j -\lambda_sj is the overall external arrival rate to the whole system, -then P_0sj = \lambda_sj / \lambda. +\lambda_s, j is the overall external arrival rate to the whole system, +then P_0, s, j = \lambda_s, j / \lambda. <p><a name="doc_002dqnvisits"></a> @@ -4853,7 +4966,7 @@ <a href="http://www.cs.purdue.edu/research/technical_reports/1980/TR 80-355.pdf">http://www.cs.purdue.edu/research/technical_reports/1980/TR 80-355.pdf</a> <p>Note that the slightly different problem of generating all tuples -k_1, k_2, \ldots k_N such that \sum_i k_i = k and +k_1, k_2, \ldots, k_N such that \sum_i k_i = k and k_i are nonnegative integers, for some fixed integer k ≥ 0 has been described in S. Santini, <cite>Computing the Indices for a Complex Summation</cite>, unpublished report, available at @@ -4934,13 +5047,15 @@ <dl> <dt>[Aky88]<dd>Ian F. Akyildiz, <cite>Mean Value Analysis for Blocking Queueing Networks</cite>, IEEE Transactions on Software Engineering, vol. 14, n. 2, -april 1988, pp. 418–428. <a href="http://dx.doi.org/10.1109/32.4663">http://dx.doi.org/10.1109/32.4663</a> +april 1988, pp. 418–428. DOI <a href="http://dx.doi.org/10.1109/32.4663">10.1109/32.4663</a> <br><dt>[Bar79]<dd>Y. Bard, <cite>Some Extensions to Multiclass Queueing Network Analysis</cite>, proc. 4th Int. Symp. on Modelling and Performance Evaluation of Computer Systems, feb. 1979, pp. 51–62. - <br><dt>[RGMT98]<dd>G. Bolch, S. Greiner, H. de Meer and + <br><dt>[BCMP75]<dd>Forest Baskett, K. Mani Chandy, Richard R. Muntz, and Fernando G. Palacios. 1975. <cite>Open, Closed, and Mixed Networks of Queues with Different Classes of Customers</cite>. J. ACM 22, 2 (April 1975), 248—260, DOI <a href="http://doi.acm.org/10.1145/321879.321887">10.1145/321879.321887</a> + + <br><dt>[BGMT98]<dd>G. Bolch, S. Greiner, H. de Meer and K. Trivedi, <cite>Queueing Networks and Markov Chains: Modeling and Performance Evaluation with Computer Science Applications</cite>, Wiley, 1998. @@ -4948,17 +5063,21 @@ <br><dt>[Buz73]<dd>Jeffrey P. Buzen, <cite>Computational Algorithms for Closed Queueing Networks with Exponential Servers</cite>, Communications of the ACM, volume 16, number 9, september 1973, -pp. 527–531. <a href="http://doi.acm.org/10.1145/362342.362345">http://doi.acm.org/10.1145/362342.362345</a> +pp. 527–531. DOI <a href="http://doi.acm.org/10.1145/362342.362345">10.1145/362342.362345</a> <br><dt>[CMS08]<dd>G. Casale, R. R. Muntz, G. Serazzi, <cite>Geometric Bounds: a Non-Iterative Analysis Technique for Closed Queueing Networks</cite>, IEEE Transactions on Computers, 57(6):780-794, -June 2008. <a href="http://doi.ieeecomputersociety.org/10.1109/TC.2008.37">http://doi.ieeecomputersociety.org/10.1109/TC.2008.37</a> +June 2008. DOI <a href="http://doi.ieeecomputersociety.org/10.1109/TC.2008.37">10.1109/TC.2008.37</a> - <br><dt>[GrSn97]<dd>Charles M. Grinstead, J. Laurie Snell, (July 1997). Introduction to -Probability. American Mathematical Society. ISBN 978-0821807491 + <br><dt>[GrSn97]<dd>Charles M. Grinstead, J. Laurie Snell, (July 1997). <cite>Introduction +to Probability</cite>. American Mathematical Society. ISBN 978-0821807491; +this excellent textbook is <a href="http://www.dartmouth.edu/~chance/teaching_aids/books_articles/probability_book/amsbook.mac.pdf">available in PDF format</a> +and can be used under the terms of the <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License (FDL)</a> - <br><dt>[Jai91]<dd>R. Jain , <cite>The Art of Computer Systems Performance Analysis</cite>, + <br><dt>[Jac04]<dd>James R. Jackson, <cite>Jobshop-Like Queueing Systems</cite>, Vol. 50, No. 12, Ten Most Influential Titles of "Management Science's" First Fifty Years (Dec., 2004), pp. 1796-1802, <a href="http://www.jstor.org/stable/30046149">available online</a> + + <br><dt>[Jai91]<dd>R. Jain, <cite>The Art of Computer Systems Performance Analysis</cite>, Wiley, 1991, p. 577. <br><dt>[HsLa87]<dd>C. H. Hsieh and S. Lam, @@ -4968,35 +5087,40 @@ <br><dt>[LZGS84]<dd>Edward D. Lazowska, John Zahorjan, G. Scott Graham, and Kenneth C. Sevcik, <cite>Quantitative System Performance: Computer System Analysis Using Queueing Network Models</cite>, Prentice Hall, -1984. <a href="http://www.cs.washington.edu/homes/lazowska/qsp/">http://www.cs.washington.edu/homes/lazowska/qsp/</a>. +1984. <a href="http://www.cs.washington.edu/homes/lazowska/qsp/">available online</a>. <br><dt>[ReKo76]<dd>M. Reiser, H. Kobayashi, <cite>On The Convolution Algorithm for Separable Queueing Networks</cite>, In Proceedings of the 1976 ACM SIGMETRICS Conference on Computer Performance Modeling Measurement and Evaluation (Cambridge, Massachusetts, United States, March 29–31, 1976). SIGMETRICS '76. ACM, New York, NY, -pp. 109–117. <a href="http://doi.acm.org/10.1145/800200.806187">http://doi.acm.org/10.1145/800200.806187</a> +pp. 109–117. DOI <a href="http://doi.acm.org/10.1145/800200.806187">10.1145/800200.806187</a> <br><dt>[ReLa80]<dd>M. Reiser and S. S. Lavenberg, <cite>Mean-Value Analysis of Closed Multichain Queuing Networks</cite>, Journal of the ACM, vol. 27, n. 2, April -1980, pp. 313–322. <a href="http://doi.acm.org/10.1145/322186.322195">http://doi.acm.org/10.1145/322186.322195</a> +1980, pp. 313–322. DOI <a href="http://doi.acm.org/10.1145/322186.322195">10.1145/322186.322195</a> + <br><dt>[Sch79]<dd>P. Schweitzer, <cite>Approximate Analysis of Multiclass Closed Networks of +Queues</cite>, Proc. Int. Conf. on Stochastic Control and Optimization, jun +1979, pp. 25—29 + <br><dt>[Sch81]<dd>Herb Schwetman, <cite>Some Computational -Aspects of Queueing Network Models</cite>, Technical Report CSD-TR-354, +Aspects of Queueing Network Models</cite>, <a href="http://www.cs.purdue.edu/research/technical_reports/1980/TR%2080-354.pdf">Technical Report CSD-TR-354</a>, Department of Computer Sciences, Purdue University, feb, 1981 -(revised). -<a href="http://www.cs.purdue.edu/research/technical_reports/1980/TR%20... [truncated message content] |
From: <sla...@us...> - 2012-03-23 01:59:44
|
Revision: 10018 http://octave.svn.sourceforge.net/octave/?rev=10018&view=rev Author: slackydeb Date: 2012-03-23 01:59:38 +0000 (Fri, 23 Mar 2012) Log Message: ----------- ga: add unit test in ga Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:26 UTC (rev 10017) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:38 UTC (rev 10018) @@ -265,13 +265,17 @@ %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); ## error with conflicting optimization parameters -# TODO: Elite count cannot be greater than the population size %!shared f, nvars %! f = @rastriginsfcn; %! nvars = 2; %!function [C, Ceq] = nonlcon (x) %! C = []; %! Ceq = []; +%!error # Elite count cannot be greater than the population size +%! ps = 3; +%! bad_options = gaoptimset ("PopulationSize", ps, +%! "EliteCount", ps + 1); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); %!error # The number of individuals in the initial population cannot be greater of the population size %! ps = 3; %! bad_options = gaoptimset ("PopulationSize", ps, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-23 01:59:32
|
Revision: 10017 http://octave.svn.sourceforge.net/octave/?rev=10017&view=rev Author: slackydeb Date: 2012-03-23 01:59:26 +0000 (Fri, 23 Mar 2012) Log Message: ----------- ga: improve unit tests Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:13 UTC (rev 10016) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:26 UTC (rev 10017) @@ -170,14 +170,14 @@ ## flawless execution with any supported optimization parameter ## different from the default value -%!shared f, nvars +%!shared f, nvars, default_options %! f = @rastriginsfcn; %! nvars = 2; +%! default_options = gaoptimset (); %!function [C, Ceq] = nonlcon (x) %! C = []; %! Ceq = []; %!test -%! default_options = gaoptimset (); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, default_options); %!test # TODO: use non-default value %! options = gaoptimset ("CreationFcn", @gacreationuniform); @@ -189,7 +189,8 @@ %! options = gaoptimset ("CrossoverFraction", rand); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test -%! options = gaoptimset ("EliteCount", 5); +%! ps = getfield (default_options, "PopulationSize"); +%! options = gaoptimset ("EliteCount", randi ([0, ps])); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test %! options = gaoptimset ("FitnessLimit", 1e-7); @@ -198,15 +199,50 @@ %! options = gaoptimset ("FitnessScalingFcn", @fitscalingrank); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test -%! options = gaoptimset ("Generations", 200); +%! g = getfield (default_options, "Generations"); +%! options = gaoptimset ("Generations", g + 1); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test -%! options = gaoptimset ("InitialPopulation", rand (4, nvars)); -%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%! ps = getfield (default_options, "PopulationSize"); +%! ## Initial population can be partial +%! options_w_full_ip = \ +%! gaoptimset ("InitialPopulation", rand (ps, nvars)); +%! partial_ip = randi ([0, ps - 1]); +%! options_w_partial_ip = \ +%! gaoptimset ("InitialPopulation", rand (partial_ip, nvars)); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options_w_full_ip); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options_w_partial_ip); +%!test +%! ps = getfield (default_options, "PopulationSize"); +%! ## Initial scores needs initial population +%! +%! options_w_full_ip_full_is = \ +%! gaoptimset ("InitialPopulation", rand (ps, nvars), +%! "InitialScores", rand (ps, 1 )); +%! partial_ip = randi ([2, ps - 1]); +%! options_w_partial_ip_full_is = \ +%! gaoptimset ("InitialPopulation", rand (partial_ip, nvars), +%! "InitialScores", rand (partial_ip, 1 )); +%! +%! ## Initial scores can be partial +%! partial_is_when_full_ip = randi ([1, ps - 1]); +%! partial_is_when_partial_ip = randi ([1, partial_ip - 1]); +%! options_w_full_ip_partial_is = \ +%! gaoptimset ("InitialPopulation", rand (ps, nvars), +%! "InitialScores", rand (partial_is_when_full_ip, 1 )); +%! options_w_partial_ip_partial_is = \ +%! gaoptimset ("InitialPopulation", rand (partial_ip, nvars), +%! "InitialScores", rand (partial_is_when_partial_ip, 1 )); +%! +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, +%! options_w_full_ip_full_is); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, +%! options_w_partial_ip_full_is); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, +%! options_w_full_ip_partial_is); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, +%! options_w_partial_ip_partial_is); %!test # TODO: use non-default value -%! options = gaoptimset ("InitialScores", []); -%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); -%!test # TODO: use non-default value %! options = gaoptimset ("MutationFcn", {@mutationgaussian, 1, 1}); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test @@ -262,10 +298,3 @@ %!test assert (ga (@(x) x ** 2, 1), 0, 1e-3); %!test assert (ga (@(x) (x ** 2) - (cos (2 * pi * x)) + 1, 1), 0, 1e-3); - - -## InitialPopulation and InitialScores options - -%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0]))); - -%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0; 0]))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-23 01:59:19
|
Revision: 10016 http://octave.svn.sourceforge.net/octave/?rev=10016&view=rev Author: slackydeb Date: 2012-03-23 01:59:13 +0000 (Fri, 23 Mar 2012) Log Message: ----------- ga: add TODO comment in ga Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:00 UTC (rev 10015) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:13 UTC (rev 10016) @@ -229,6 +229,7 @@ %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); ## error with conflicting optimization parameters +# TODO: Elite count cannot be greater than the population size %!shared f, nvars %! f = @rastriginsfcn; %! nvars = 2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-23 01:59:06
|
Revision: 10015 http://octave.svn.sourceforge.net/octave/?rev=10015&view=rev Author: slackydeb Date: 2012-03-23 01:59:00 +0000 (Fri, 23 Mar 2012) Log Message: ----------- ga: use random value in unit test Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:48 UTC (rev 10014) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:00 UTC (rev 10015) @@ -186,7 +186,7 @@ %! options = gaoptimset ("CrossoverFcn", @crossoverscattered); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test -%! options = gaoptimset ("CrossoverFraction", 0.6); +%! options = gaoptimset ("CrossoverFraction", rand); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test %! options = gaoptimset ("EliteCount", 5); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-23 01:58:54
|
Revision: 10014 http://octave.svn.sourceforge.net/octave/?rev=10014&view=rev Author: slackydeb Date: 2012-03-23 01:58:48 +0000 (Fri, 23 Mar 2012) Log Message: ----------- ga: add TODO comment in ga Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:36 UTC (rev 10013) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:48 UTC (rev 10014) @@ -255,6 +255,7 @@ %!test x = ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ())); +# TODO: convert to simple xtests ## nvars == 1 and min == zeros (1, nvars) %!test assert (ga (@(x) x ** 2, 1), 0, 1e-3); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-23 01:58:42
|
Revision: 10013 http://octave.svn.sourceforge.net/octave/?rev=10013&view=rev Author: slackydeb Date: 2012-03-23 01:58:36 +0000 (Fri, 23 Mar 2012) Log Message: ----------- ga: simplify unit tests in ga removing unuseful option Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:24 UTC (rev 10012) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:36 UTC (rev 10013) @@ -264,6 +264,6 @@ ## InitialPopulation and InitialScores options -%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0]))); +%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0]))); -%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0; 0]))); +%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0; 0]))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-23 01:58:30
|
Revision: 10012 http://octave.svn.sourceforge.net/octave/?rev=10012&view=rev Author: slackydeb Date: 2012-03-23 01:58:24 +0000 (Fri, 23 Mar 2012) Log Message: ----------- ga: structure unit tests in ga about conflicting options Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:11 UTC (rev 10011) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:24 UTC (rev 10012) @@ -228,6 +228,27 @@ %! options = gaoptimset ("Vectorized", "on"); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +## error with conflicting optimization parameters +%!shared f, nvars +%! f = @rastriginsfcn; +%! nvars = 2; +%!function [C, Ceq] = nonlcon (x) +%! C = []; +%! Ceq = []; +%!error # The number of individuals in the initial population cannot be greater of the population size +%! ps = 3; +%! bad_options = gaoptimset ("PopulationSize", ps, +%! "InitialPopulation", zeros (ps + 1, nvars)); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!error # Initial scores cannot be specified without specifying the initial population too +%! bad_options = gaoptimset ("InitialScores", zeros (3, 1)); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!error # The number of initial scores specified cannot be greater of the number of individuals in the initial population +%! ip = 3; +%! bad_options = gaoptimset ("InitialPopulation", zeros (ip, nvars), +%! "InitialScores", zeros (ip + 1, 1)); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +# TODO # TODO: structure/add tests below @@ -243,12 +264,6 @@ ## InitialPopulation and InitialScores options -%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "PopulationSize", 3))); - -%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialScores", [0; 0; 0]))); - -%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0], "InitialScores", [0; 0; 0]))); - %!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0]))); %!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0; 0]))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-23 01:58:17
|
Revision: 10011 http://octave.svn.sourceforge.net/octave/?rev=10011&view=rev Author: slackydeb Date: 2012-03-23 01:58:11 +0000 (Fri, 23 Mar 2012) Log Message: ----------- ga: enable unit tests even if only with standard values Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:57:58 UTC (rev 10010) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:11 UTC (rev 10011) @@ -177,14 +177,14 @@ %! C = []; %! Ceq = []; %!test -%! options = gaoptimset (); +%! default_options = gaoptimset (); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, default_options); +%!test # TODO: use non-default value +%! options = gaoptimset ("CreationFcn", @gacreationuniform); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); -%!#test -%!# options = gaoptimset ("CreationFcn", TODO); -%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); -%!#test -%!# options = gaoptimset ("CrossoverFcn", TODO); -%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # TODO: use non-default value +%! options = gaoptimset ("CrossoverFcn", @crossoverscattered); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test %! options = gaoptimset ("CrossoverFraction", 0.6); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); @@ -194,34 +194,34 @@ %!test %! options = gaoptimset ("FitnessLimit", 1e-7); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); -%!#test -%!# options = gaoptimset ("FitnessScalingFcn", TODO); -%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # TODO: use non-default value +%! options = gaoptimset ("FitnessScalingFcn", @fitscalingrank); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test %! options = gaoptimset ("Generations", 200); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test %! options = gaoptimset ("InitialPopulation", rand (4, nvars)); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); -%!#test -%!# options = gaoptimset ("InitialScores", TODO); -%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); -%!#test -%!# options = gaoptimset ("MutationFcn", TODO); -%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # TODO: use non-default value +%! options = gaoptimset ("InitialScores", []); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # TODO: use non-default value +%! options = gaoptimset ("MutationFcn", {@mutationgaussian, 1, 1}); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test %! options = gaoptimset ("PopInitRange", [-2; 2]); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test %! options = gaoptimset ("PopulationSize", 200); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); -%!#test -%!# options = gaoptimset ("SelectionFcn", TODO); -%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); -%!#test -%!# options = gaoptimset ("TimeLimit", TODO); -%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); -%!#xtest +%!test # TODO: use non-default value +%! options = gaoptimset ("SelectionFcn", @selectionstochunif); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # TODO: use non-default value +%! options = gaoptimset ("TimeLimit", Inf); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!#xtest # TODO %!# options = gaoptimset ("UseParallel", "always"); %!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-23 01:58:04
|
Revision: 10010 http://octave.svn.sourceforge.net/octave/?rev=10010&view=rev Author: slackydeb Date: 2012-03-23 01:57:58 +0000 (Fri, 23 Mar 2012) Log Message: ----------- ga: organize unit tests related to options in ga Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:57:46 UTC (rev 10009) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:57:58 UTC (rev 10010) @@ -168,13 +168,72 @@ %! nvars = 3; %! x = ga (@(x) (x(:, 1) ** 2) + (x(:, 2) ** 2) + (x(:, 3) ** 2), nvars); +## flawless execution with any supported optimization parameter +## different from the default value +%!shared f, nvars +%! f = @rastriginsfcn; +%! nvars = 2; +%!function [C, Ceq] = nonlcon (x) +%! C = []; +%! Ceq = []; +%!test +%! options = gaoptimset (); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!#test +%!# options = gaoptimset ("CreationFcn", TODO); +%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!#test +%!# options = gaoptimset ("CrossoverFcn", TODO); +%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("CrossoverFraction", 0.6); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("EliteCount", 5); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("FitnessLimit", 1e-7); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!#test +%!# options = gaoptimset ("FitnessScalingFcn", TODO); +%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("Generations", 200); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("InitialPopulation", rand (4, nvars)); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!#test +%!# options = gaoptimset ("InitialScores", TODO); +%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!#test +%!# options = gaoptimset ("MutationFcn", TODO); +%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("PopInitRange", [-2; 2]); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("PopulationSize", 200); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!#test +%!# options = gaoptimset ("SelectionFcn", TODO); +%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!#test +%!# options = gaoptimset ("TimeLimit", TODO); +%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!#xtest +%!# options = gaoptimset ("UseParallel", "always"); +%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("Vectorized", "on"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); + + # TODO: structure/add tests below -%!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 200))); +%!test x = ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ())); -%!test x = ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ("EliteCount", 5, "FitnessLimit", 1e-7, "PopInitRange", [-2; 2], "PopulationSize", 200))); - ## nvars == 1 and min == zeros (1, nvars) %!test assert (ga (@(x) x ** 2, 1), 0, 1e-3); @@ -193,10 +252,3 @@ %!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0]))); %!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0; 0]))); - - -## Vectorized and UseParallel options - -%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "Vectorized", "on"))); - -%!#xtest ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "UseParallel", "always"))); TODO This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-23 01:57:52
|
Revision: 10009 http://octave.svn.sourceforge.net/octave/?rev=10009&view=rev Author: slackydeb Date: 2012-03-23 01:57:46 +0000 (Fri, 23 Mar 2012) Log Message: ----------- ga: improve comment in ga Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:57:33 UTC (rev 10008) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:57:46 UTC (rev 10009) @@ -157,7 +157,7 @@ %! "options", gaoptimset ()); %! x = ga (problem); -## number of nvars +## flawless execution with any nvars %!test %! nvars = 1; %! x = ga (@(x) x(1, 1) ** 2, nvars); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-23 01:57:39
|
Revision: 10008 http://octave.svn.sourceforge.net/octave/?rev=10008&view=rev Author: slackydeb Date: 2012-03-23 01:57:33 +0000 (Fri, 23 Mar 2012) Log Message: ----------- ga: test number of nvars in ga Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-22 22:38:34 UTC (rev 10007) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:57:33 UTC (rev 10008) @@ -157,6 +157,17 @@ %! "options", gaoptimset ()); %! x = ga (problem); +## number of nvars +%!test +%! nvars = 1; +%! x = ga (@(x) x(1, 1) ** 2, nvars); +%!test +%! nvars = 2; +%! x = ga (@(x) (x(:, 1) ** 2) + (x(:, 2) ** 2), nvars); +%!test +%! nvars = 3; +%! x = ga (@(x) (x(:, 1) ** 2) + (x(:, 2) ** 2) + (x(:, 3) ** 2), nvars); + # TODO: structure/add tests below %!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 200))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-22 22:38:41
|
Revision: 10007 http://octave.svn.sourceforge.net/octave/?rev=10007&view=rev Author: jpicarbajal Date: 2012-03-22 22:38:34 +0000 (Thu, 22 Mar 2012) Log Message: ----------- geometry: adding path to prvate folder in tests Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/geom2d/bisector.m trunk/octave-forge/main/geometry/inst/geom2d/createCircle.m trunk/octave-forge/main/geometry/inst/geom2d/drawLine.m trunk/octave-forge/main/geometry/inst/geom2d/medianLine.m Modified: trunk/octave-forge/main/geometry/inst/geom2d/bisector.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/bisector.m 2012-03-22 22:05:06 UTC (rev 10006) +++ trunk/octave-forge/main/geometry/inst/geom2d/bisector.m 2012-03-22 22:38:34 UTC (rev 10007) @@ -10,8 +10,8 @@ %% %% 1. Redistributions of source code must retain the above copyright notice, this %% list of conditions and the following disclaimer. -%% -%% 2. Redistributions in binary form must reproduce the above copyright notice, +%% +%% 2. Redistributions in binary form must reproduce the above copyright notice, %% this list of conditions and the following disclaimer in the documentation %% and/or other materials provided with the distribution. %% @@ -19,9 +19,9 @@ %% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE %% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE %% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -%% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +%% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR %% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -%% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +%% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS %% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN %% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) %% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE @@ -43,7 +43,7 @@ %% The result has the form [x0 y0 dx dy], with [x0 y0] being the origin %% point ans [dx dy] being the direction vector, normalized to have unit %% norm. -%% +%% %% @seealso{lines2d, rays2d} %% @end deftypefn @@ -53,9 +53,9 @@ % two lines line1 = varargin{1}; line2 = varargin{2}; - - point = intersectLines(line1, line2); - + + point = intersectLines(line1, line2); + elseif length(varargin)==3 % three points p1 = varargin{1}; @@ -65,7 +65,7 @@ line1 = createLine(p2, p1); line2 = createLine(p2, p3); point = p2; - + elseif length(varargin)==1 % three points, given in one array var = varargin{1}; @@ -90,7 +90,11 @@ endfunction +%!shared privpath +%! privpath = [fileparts(which('geom2d_Contents')) filesep() 'private']; + %!test +%! addpath (privpath,'-end') %! p0 = [0 0]; %! p1 = [10 0]; %! p2 = [0 10]; @@ -99,19 +103,24 @@ %! ray = bisector(line1, line2); %! assertElementsAlmostEqual([0 0], ray(1,1:2)); %! assertAlmostEqual(pi/4, lineAngle(ray)); +%! rmpath (privpath); %!test +%! addpath (privpath,'-end') %! p0 = [0 0]; %! p1 = [10 0]; %! p2 = [0 10]; %! ray = bisector(p1, p0, p2); %! assertElementsAlmostEqual([0 0], ray(1,1:2)); %! assertAlmostEqual(pi/4, lineAngle(ray)); +%! rmpath (privpath); %!test +%! addpath (privpath,'-end') %! p0 = [0 0]; %! p1 = [10 0]; %! p2 = [0 10]; %! ray = bisector([p1; p0; p2]); %! assertElementsAlmostEqual([0 0], ray(1,1:2)); %! assertAlmostEqual(pi/4, lineAngle(ray)); +%! rmpath (privpath); Modified: trunk/octave-forge/main/geometry/inst/geom2d/createCircle.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/createCircle.m 2012-03-22 22:05:06 UTC (rev 10006) +++ trunk/octave-forge/main/geometry/inst/geom2d/createCircle.m 2012-03-22 22:38:34 UTC (rev 10007) @@ -10,8 +10,8 @@ %% %% 1. Redistributions of source code must retain the above copyright notice, this %% list of conditions and the following disclaimer. -%% -%% 2. Redistributions in binary form must reproduce the above copyright notice, +%% +%% 2. Redistributions in binary form must reproduce the above copyright notice, %% this list of conditions and the following disclaimer in the documentation %% and/or other materials provided with the distribution. %% @@ -19,9 +19,9 @@ %% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE %% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE %% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -%% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +%% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR %% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -%% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +%% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS %% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN %% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) %% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE @@ -36,7 +36,7 @@ %% @deftypefnx {Function File} {@var{circle} = } createCircle (@var{p1}, @var{p2}) %% Create a circle from 2 or 3 points. %% -%% Creates the circle passing through the 3 given points. +%% Creates the circle passing through the 3 given points. %% C is a 1x3 array of the form: [XC YX R]. %% %% When two points are given, creates the circle whith center @var{p1} and passing @@ -46,7 +46,7 @@ %% result has as many lines as the point arrays. %% %% Example -%% +%% %% @example %% % Draw a circle passing through 3 points. %% p1 = [10 15]; @@ -70,7 +70,7 @@ x0 = p1(:,1); y0 = p1(:,2); r = hypot((p2(:,1)-x0), (p2(:,2)-y0)); - + elseif nargin == 3 % inputs are three points on the circle p1 = varargin{1}; @@ -81,19 +81,23 @@ line1 = medianLine(p1, p2); line2 = medianLine(p1, p3); point = intersectLines(line1, line2); - x0 = point(:, 1); + x0 = point(:, 1); y0 = point(:, 2); - + % circle radius r = hypot((p1(:,1)-x0), (p1(:,2)-y0)); end - - % create array for returning result + + % create array for returning result circle = [x0 y0 r]; endfunction +%!shared privpath +%! privpath = [fileparts(which('geom2d_Contents')) filesep() 'private']; + %!test +%! addpath (privpath,'-end') %! p1 = [10 15]; %! p2 = [15 20]; %! p3 = [10 25]; @@ -104,8 +108,10 @@ %! assertEqual(exp, circle); %! circle = createCircle(p2, p3, p1); %! assertEqual(exp, circle); +%! rmpath (privpath); %!test +%! addpath (privpath,'-end') %! p1 = [10 15]; %! p2 = [15 20]; %! p3 = [10 25]; @@ -120,4 +126,4 @@ %! assertEqual(exp, circle); %! circle = createCircle(p2, p3, p1); %! assertEqual(exp, circle); - +%! rmpath (privpath); Modified: trunk/octave-forge/main/geometry/inst/geom2d/drawLine.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/drawLine.m 2012-03-22 22:05:06 UTC (rev 10006) +++ trunk/octave-forge/main/geometry/inst/geom2d/drawLine.m 2012-03-22 22:38:34 UTC (rev 10007) @@ -10,8 +10,8 @@ %% %% 1. Redistributions of source code must retain the above copyright notice, this %% list of conditions and the following disclaimer. -%% -%% 2. Redistributions in binary form must reproduce the above copyright notice, +%% +%% 2. Redistributions in binary form must reproduce the above copyright notice, %% this list of conditions and the following disclaimer in the documentation %% and/or other materials provided with the distribution. %% @@ -19,9 +19,9 @@ %% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE %% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE %% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -%% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +%% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR %% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -%% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +%% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS %% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN %% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) %% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE @@ -35,7 +35,7 @@ %% @deftypefn {Function File} {@var{h} =} drawLine (@var{line}) %% @deftypefnx {Function File} {@var{h} =} drawLine (@var{line}, @var{param},@var{value}) %% Draw the line on the current axis. -%% +%% %% Draws the line LINE on the current axis, by using current axis to clip %% the line. Extra @var{param},@var{value} pairs are passed to the @code{line} function. %% Returns a handle to the created line object. If clipped line is not @@ -85,110 +85,143 @@ %! drawLine([30 40 10 20]); %! drawLine([30 40 20 -10], 'color', 'm', 'linewidth', 2); -%%!test -%%! box = [0 100 0 100]; -%%! hf = figure(); -%%! axis(box); -%%! line = [30 40 10 0]; -%%! edge = [0 40 100 40]; -%%! hl = drawLine(line); -%%! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); -%%! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); +%!shared privpath +%! privpath = [fileparts(which('geom2d_Contents')) filesep() 'private']; -%%!test -%%! box = [0 100 0 100]; -%%! hf = figure(); -%%! axis(box); -%%! line = [30 40 -10 0]; -%%! edge = [100 40 0 40]; -%%! hl = drawLine(line); -%%! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); -%%! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); +%!test +%! addpath (privpath,'-end') +%! box = [0 100 0 100]; +%! hf = figure(); +%! axis(box); +%! line = [30 40 10 0]; +%! edge = [0 40 100 40]; +%! hl = drawLine(line); +%! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); +%! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); +%! rmpath (privpath); +%! close all -%%!test -%%! box = [0 100 0 100]; -%%! hf = figure(); -%%! axis(box); -%%! line = [30 140 10 0]; -%%! hl = drawLine(line); -%%! assertEqual(-1, hl); +%!test +%! addpath (privpath,'-end') +%! box = [0 100 0 100]; +%! hf = figure(); +%! axis(box); +%! line = [30 40 -10 0]; +%! edge = [100 40 0 40]; +%! hl = drawLine(line); +%! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); +%! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); +%! rmpath (privpath); +%! close all -%%!test -%%! box = [0 100 0 100]; -%%! hf = figure(); -%%! axis(box); -%%! line = [30 40 0 10]; -%%! edge = [30 0 30 100]; -%%! hl = drawLine(line); -%%! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); -%%! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); +%!test +%! addpath (privpath,'-end') +%! box = [0 100 0 100]; +%! hf = figure(); +%! axis(box); +%! line = [30 140 10 0]; +%! hl = drawLine(line); +%! assertEqual(-1, hl); +%! rmpath (privpath); +%! close all -%%!test -%%! box = [0 100 0 100]; -%%! hf = figure(); -%%! axis(box); -%%! line = [30 40 0 -10]; -%%! edge = [30 100 30 0]; -%%! hl = drawLine(line); -%%! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); -%%! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); +%!test +%! addpath (privpath,'-end') +%! box = [0 100 0 100]; +%! hf = figure(); +%! axis(box); +%! line = [30 40 0 10]; +%! edge = [30 0 30 100]; +%! hl = drawLine(line); +%! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); +%! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); +%! rmpath (privpath); +%! close all -%%!test -%%! box = [0 100 0 100]; -%%! hf = figure(); -%%! axis(box); -%%! line = [140 30 0 10]; -%%! hl = drawLine(line); -%%! assertEqual(-1, hl); +%!test +%! addpath (privpath,'-end') +%! box = [0 100 0 100]; +%! hf = figure(); +%! axis(box); +%! line = [30 40 0 -10]; +%! edge = [30 100 30 0]; +%! hl = drawLine(line); +%! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); +%! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); +%! rmpath (privpath); +%! close all -%%!test -%%! box = [0 100 0 100]; -%%! hf = figure(); -%%! axis(box); -%%! line = [80 30 10 10]; -%%! edge = [50 0 100 50]; -%%! hl = drawLine(line); -%%! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); -%%! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); +%!test +%! addpath (privpath,'-end') +%! box = [0 100 0 100]; +%! hf = figure(); +%! axis(box); +%! line = [140 30 0 10]; +%! hl = drawLine(line); +%! assertEqual(-1, hl); +%! rmpath (privpath); +%! close all -%%!test -%%! box = [0 100 0 100]; -%%! hf = figure(); -%%! axis(box); -%%! line = [20 70 10 10]; -%%! edge = [0 50 50 100]; -%%! hl = drawLine(line); -%%! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); -%%! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); +%!test +%! addpath (privpath,'-end') +%! box = [0 100 0 100]; +%! hf = figure(); +%! axis(box); +%! line = [80 30 10 10]; +%! edge = [50 0 100 50]; +%! hl = drawLine(line); +%! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); +%! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); +%! rmpath (privpath); +%! close all -%%!test -%%! box = [0 100 0 100]; -%%! hf = figure(); -%%! axis(box); -%%! line = [140 -30 10 10]; -%%! hl = drawLine(line); -%%! assertEqual(-1, hl); -%%! line = [-40 130 10 10]; -%%! hl = drawLine(line); -%%! assertEqual(-1, hl); +%!test +%! addpath (privpath,'-end') +%! box = [0 100 0 100]; +%! hf = figure(); +%! axis(box); +%! line = [20 70 10 10]; +%! edge = [0 50 50 100]; +%! hl = drawLine(line); +%! assertElementsAlmostEqual(edge([1 3]), get(hl, 'xdata')); +%! assertElementsAlmostEqual(edge([2 4]), get(hl, 'ydata')); +%! rmpath (privpath); +%! close all -%%!test -%%! box = [0 100 0 100]; -%%! hf = figure(); -%%! axis(box); -%%! line = [... -%%! 80 30 10 10; ... -%%! 20 70 10 10; ... -%%! 140 -30 10 10; ... -%%! -40 130 10 10]; -%%! edge = [... -%%! 50 0 100 50; ... -%%! 0 50 50 100]; -%%! hl = drawLine(line); -%%! assertEqual(4, length(hl)); -%%! assertElementsAlmostEqual(edge(1, [1 3]), get(hl(1), 'xdata')); -%%! assertElementsAlmostEqual(edge(1, [2 4]), get(hl(1), 'ydata')); -%%! assertElementsAlmostEqual(edge(2, [1 3]), get(hl(2), 'xdata')); -%%! assertElementsAlmostEqual(edge(2, [2 4]), get(hl(2), 'ydata')); -%%! assertEqual(-1, hl(3)); -%%! assertEqual(-1, hl(4)); +%!test +%! addpath (privpath,'-end') +%! box = [0 100 0 100]; +%! hf = figure(); +%! axis(box); +%! line = [140 -30 10 10]; +%! hl = drawLine(line); +%! assertEqual(-1, hl); +%! line = [-40 130 10 10]; +%! hl = drawLine(line); +%! assertEqual(-1, hl); +%! rmpath (privpath); +%! close all + +%!test +%! addpath (privpath,'-end') +%! box = [0 100 0 100]; +%! hf = figure(); +%! axis(box); +%! line = [... +%! 80 30 10 10; ... +%! 20 70 10 10; ... +%! 140 -30 10 10; ... +%! -40 130 10 10]; +%! edge = [... +%! 50 0 100 50; ... +%! 0 50 50 100]; +%! hl = drawLine(line); +%! assertEqual(4, length(hl)); +%! assertElementsAlmostEqual(edge(1, [1 3]), get(hl(1), 'xdata')); +%! assertElementsAlmostEqual(edge(1, [2 4]), get(hl(1), 'ydata')); +%! assertElementsAlmostEqual(edge(2, [1 3]), get(hl(2), 'xdata')); +%! assertElementsAlmostEqual(edge(2, [2 4]), get(hl(2), 'ydata')); +%! assertEqual(-1, hl(3)); +%! assertEqual(-1, hl(4)); +%! rmpath (privpath); +%! close all Modified: trunk/octave-forge/main/geometry/inst/geom2d/medianLine.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/medianLine.m 2012-03-22 22:05:06 UTC (rev 10006) +++ trunk/octave-forge/main/geometry/inst/geom2d/medianLine.m 2012-03-22 22:38:34 UTC (rev 10007) @@ -10,8 +10,8 @@ %% %% 1. Redistributions of source code must retain the above copyright notice, this %% list of conditions and the following disclaimer. -%% -%% 2. Redistributions in binary form must reproduce the above copyright notice, +%% +%% 2. Redistributions in binary form must reproduce the above copyright notice, %% this list of conditions and the following disclaimer in the documentation %% and/or other materials provided with the distribution. %% @@ -19,9 +19,9 @@ %% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE %% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE %% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -%% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +%% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR %% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -%% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +%% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS %% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN %% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) %% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE @@ -47,7 +47,7 @@ %% Creates the median of the @var{edge}. @var{edge} is a 1*4 array, containing [X1 Y1] %% coordinates of first point, and [X2 Y2], the coordinates of the second %% point. -%% +%% %% Example %% %% @example @@ -84,27 +84,27 @@ tab = varargin{1}; if size(tab, 2)==2 % input is an array of two points - x0 = tab(1,1); + x0 = tab(1,1); y0 = tab(1,2); - dx = tab(2,1)-x0; + dx = tab(2,1)-x0; dy = tab(2,2)-y0; else % input is an edge - x0 = tab(:, 1); + x0 = tab(:, 1); y0 = tab(:, 2); - dx = tab(:, 3) - tab(:, 1); + dx = tab(:, 3) - tab(:, 1); dy = tab(:, 4) - tab(:, 2); end - + elseif nargs==2 % input is given as two points, or two point arrays p1 = varargin{1}; p2 = varargin{2}; - x0 = p1(:, 1); + x0 = p1(:, 1); y0 = p1(:, 2); - dx = bsxfun(@minus, p2(:, 1), x0); + dx = bsxfun(@minus, p2(:, 1), x0); dy = bsxfun(@minus, p2(:, 2), y0); - + else error('Too many input arguments'); end @@ -115,23 +115,32 @@ endfunction +%!shared privpath +%! privpath = [fileparts(which('geom2d_Contents')) filesep() 'private']; + %!test +%! addpath (privpath,'-end') %! p1 = [0 0]; %! p2 = [10 0]; %! exp = [5 0 0 10]; %! lin = medianLine(p1, p2); %! assertElementsAlmostEqual(exp, lin); - +%! rmpath (privpath); + %!test +%! addpath (privpath,'-end') %! p1 = [0 0]; %! p2 = [10 0]; %! exp = [5 0 0 10]; %! lin = medianLine([p1 p2]); %! assertElementsAlmostEqual(exp, lin); +%! rmpath (privpath); %!test +%! addpath (privpath,'-end') %! p1 = [0 0; 10 10]; %! p2 = [10 0;10 20]; %! exp = [5 0 0 10; 10 15 -10 0]; %! lin = medianLine(p1, p2); %! assertElementsAlmostEqual(exp, lin); +%! rmpath (privpath); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-22 22:05:12
|
Revision: 10006 http://octave.svn.sourceforge.net/octave/?rev=10006&view=rev Author: jpicarbajal Date: 2012-03-22 22:05:06 +0000 (Thu, 22 Mar 2012) Log Message: ----------- geometry: Fixed bugs detected by Rafael (dev packager). Improved docstring of cbezier2poly. Verified all other shape2d functions. Moved test form shapetransfrom to shapecentriod Modified Paths: -------------- trunk/octave-forge/main/geometry/NEWS trunk/octave-forge/main/geometry/inst/geom2d/cbezier2poly.m trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m trunk/octave-forge/main/geometry/inst/shape2d/shapearea.m trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-03-22 17:54:01 UTC (rev 10005) +++ trunk/octave-forge/main/geometry/NEWS 2012-03-22 22:05:06 UTC (rev 10006) @@ -14,12 +14,13 @@ - @svg/path2polygon.m - Fix addpath/rmpath installation warnings - Fix octclip/src/Makefile + - Fix shapecentriod.m for piece-wise polynomial shapes. * Known issues - simplifypolygon.m returns empty polygons when points are repeated, i.e when the polygon is not correctly formed. - - shapecentriod.m gives wierd results for Bezier curves. + =============================================================================== geometry-1.4.0 Release Date: 2012-01-25 Release Manager: Juan Pablo Carbajal =============================================================================== Modified: trunk/octave-forge/main/geometry/inst/geom2d/cbezier2poly.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/cbezier2poly.m 2012-03-22 17:54:01 UTC (rev 10005) +++ trunk/octave-forge/main/geometry/inst/geom2d/cbezier2poly.m 2012-03-22 22:05:06 UTC (rev 10006) @@ -39,8 +39,8 @@ %% With only one input argument, calculates the polynomial @var{pp} of the cubic %% Bezier curve defined by the 4 control points stored in @var{points}. The first %% point is the inital point of the curve. The segment joining the first point -%% with the second point defines the tangent of the curve at the initial point. -%% The segment that joints the third point with the fourth defines the tanget at +%% with the second point (first center) defines the tangent of the curve at the initial point. +%% The segment that joints the third point (second center) with the fourth defines the tanget at %% the end-point of the curve, which is defined in the fourth point. %% @var{points} is either a 4-by-2 array (vertical concatenation of point %% coordinates), or a 1-by-8 array (horizotnal concatenation of point Modified: trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m 2012-03-22 17:54:01 UTC (rev 10005) +++ trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m 2012-03-22 22:05:06 UTC (rev 10006) @@ -29,21 +29,24 @@ function polygon = shape2polygon (shape, N=16) polygon = cell2mat ( ... - cellfun(@(x) func (x,N), shape,'UniformOutput',false) ); + cellfun (@(x) func (x,N), shape,'UniformOutput',false) ); - if size(polygon, 1) == 1 - polygon(2,1) = polyval(shape{1}(1,:),1); - polygon(2,2) = polyval(shape{1}(2,:),1); + %% TODO simply the polygon based on curvature +% polygon = unique (polygon, 'rows'); + + if size (polygon, 1) == 1 + polygon(2,1) = polyval (shape{1}(1,:), 1); + polygon(2,2) = polyval (shape{1}(2,:), 1); end endfunction -function y = func(x,N) +function y = func (x,N) - if size(x,2) > 2 - t = linspace(0,1-1/N,N).'; - y(:,1) = polyval(x(1,:),t); - y(:,2) = polyval(x(2,:),t); + if size (x,2) > 2 + t = linspace (0,1-1/N,N).'; + y(:,1) = polyval (x(1,:), t); + y(:,2) = polyval (x(2,:), t); else y = x(:,2).'; end Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapearea.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapearea.m 2012-03-22 17:54:01 UTC (rev 10005) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapearea.m 2012-03-22 22:05:06 UTC (rev 10006) @@ -26,10 +26,12 @@ %% @seealso{shapecentroid, shape2polygon, shapeplot} %% @end deftypefn -function A = shapearea (shape) +function [A ccw] = shapearea (shape) A = sum(cellfun (@Aint, shape)); if A < 0 + warning ('geom2d:shapearea:InvalidResult', ... + 'Shape has negative area. Assuming this is due to a clockwise parametrization of the boundary'); A = -A; end @@ -46,12 +48,16 @@ end -%!demo % non-convex bezier shape -%! weirdhearth ={[-17.6816 -34.3989 7.8580 3.7971; ... -%! 15.4585 -28.3820 -18.7645 9.8519]; ... -%! [-27.7359 18.1039 -34.5718 3.7878; ... -%! -40.7440 49.7999 -25.5011 2.2304]}; -%! A = shapearea (weirdhearth) +%!demo % non-convex piece-wise polynomial shape +%! boomerang = {[ 0 -2 1; ... +%! -4 4 0]; ... +%! [0.25 -1; ... +%! 0 0]; ... +%! [ 0 1.5 -0.75; ... +%! -3 3 0]; +%! [0.25 0.75; ... +%! 0 0]}; +%! A = shapearea (boomerang) %!test %! triangle = {[1 0; 0 0]; [-0.5 1; 1 0]; [-0.5 0.5; -1 1]}; Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-03-22 17:54:01 UTC (rev 10005) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-03-22 22:05:06 UTC (rev 10006) @@ -15,30 +15,39 @@ %% -*- texinfo -*- %% @deftypefn {Function File} { @var{cm} =} shapecentroid (@var{pp}) -%% Centroid of a plane shape defined with piecewise smooth polynomials. +%% Centroid of a simple plane shape defined with piecewise smooth polynomials. %% %% The shape is defined with piecewise smooth polynomials. @var{pp} is a %% cell where each elements is a 2-by-(poly_degree+1) matrix containing a pair %% of polynomials. %% @code{px(i,:) = pp@{i@}(1,:)} and @code{py(i,:) = pp@{i@}(2,:)}. %% +%% The edges of the shape should not self-intersect. This function does not check for the +%% sanity of the shape. +%% %% @seealso{shapearea, shape2polygon} %% @end deftypefn function cm = shapecentroid (shape) - cm = sum( cell2mat ( cellfun (@CMint, shape, 'UniformOutput', false))); + cm = sum( cell2mat ( cellfun (@CMint, shape, 'UniformOutput', false)), 1); A = shapearea(shape); cm = cm / A; + [~,id] = lastwarn ('',''); + if strcmp (id ,'geom2d:shapearea:InvalidResult') + lastwarn('Inverting centriod','geom2d:shapecentriod:InvalidResult'); + cm = -cm; + end + endfunction function dcm = CMint (x) px = x(1,:); py = x(2,:); - Px = polyint (conv(conv (px , px)/2 , polyder (py))); - Py = polyint (conv(-conv (py , py)/2 , polyder (px))); + Px = polyint (conv(conv (-px , py) , polyder (px))); + Py = polyint (conv(conv (px , py) , polyder (py))); dcm = zeros (1,2); dcm(1) = diff(polyval(Px,[0 1])); @@ -47,17 +56,22 @@ endfunction %!demo % non-convex bezier shape -%! weirdhearth ={[34.81947,-63.60585 41.35964,1.61093; ... -%! 73.22086,4.95439 7.1796,-34.7948]; ... -%! [30.26599,-50.0316 77.6279,8.52058; ... -%! -18.66371,58.02699 -168.20415,52.74819]}; -%! CoM = shapecentroid (weirdhearth) -%! Gcentriod = centroid(shape2polygon(weirdhearth)) +%! boomerang = {[ 0 -2 1; ... +%! -4 4 0]; ... +%! [0.25 -1; ... +%! 0 0]; ... +%! [ 0 1.5 -0.75; ... +%! -3 3 0]; +%! [0.25 0.75; ... +%! 0 0]}; +%! CoM = shapecentroid (boomerang) +%! Gcentriod = centroid(shape2polygon(boomerang)) %! -%! shapeplot(weirdhearth); +%! figure(1); clf; +%! shapeplot(boomerang,10,'-o'); %! hold on -%! drawPoint(CoM,'ok'); -%! drawPoint(Gcentriod,'or'); +%! drawPoint(CoM,'xk;shape centriod;'); +%! drawPoint(Gcentriod,'xr;point centriod;'); %! hold off %! axis equal @@ -71,10 +85,10 @@ %! CoM = shapecentroid (Lshape) %! Gcentriod = centroid (shape2polygon (Lshape)) %! -%! shapeplot(Lshape); +%! shapeplot(Lshape,10,'-o'); %! hold on -%! drawPoint(CoM,'ok'); -%! drawPoint(Gcentriod,'or'); +%! drawPoint(CoM,'xk;shape centriod;'); +%! drawPoint(Gcentriod,'xr;point centriod;'); %! hold off %! axis equal @@ -82,10 +96,12 @@ %! square = {[1 -0.5; 0 -0.5]; [0 0.5; 1 -0.5]; [-1 0.5; 0 0.5]; [0 -0.5; -1 0.5]}; %! CoM = shapecentroid (square); %! assert (CoM, [0 0], sqrt(eps)); + +%!test +%! square = {[1 -0.5; 0 -0.5]; [0 0.5; 1 -0.5]; [-1 0.5; 0 0.5]; [0 -0.5; -1 0.5]}; %! square_t = shapetransform (square,[1;1]); -%! CoM_t = shapecentroid (square_t); -%! assert (CoM, [0 0], sqrt(eps)); -%! assert (CoM_t, [1 1], sqrt(eps)); +%! CoM = shapecentroid (square_t); +%! assert (CoM, [1 1], sqrt(eps)); %!test %! circle = {[1.715729 -6.715729 0 5; ... @@ -98,3 +114,37 @@ %! -1.715729 6.715729 0 -5]}; %! CoM = shapecentroid (circle); %! assert (CoM , [0 0], 5e-3); + +%!shared shape +%! shape = {[-93.172 606.368 -476.054 291.429; ... +%! -431.196 637.253 11.085 163.791]; ... +%! [-75.3626 -253.2337 457.1678 328.5714; ... +%! 438.7659 -653.6278 -7.9953 380.9336]; ... +%! [-89.5841 344.9716 -275.3876 457.1429; ... +%! -170.3613 237.8858 1.0469 158.0765];... +%! [32.900 -298.704 145.804 437.143; ... +%! -243.903 369.597 -34.265 226.648]; ... +%! [-99.081 409.127 -352.903 317.143; ... +%! 55.289 -114.223 -26.781 318.076]; ... +%! [-342.231 191.266 168.108 274.286; ... +%! 58.870 -38.083 -89.358 232.362]}; + +%!test % x-Reflection +%! v = shapecentroid (shape)(:); +%! T = createLineReflection([0 0 1 0]); +%! nshape = shapetransform (shape, T); +%! vn = shapecentroid (nshape)(:); +%! assert(vn,T(1:2,1:2)*v); + +%!test % Rotation +%! v = shapecentroid (shape)(:); +%! T = createRotation(v.',pi/2); +%! nshape = shapetransform (shape, T); +%! vn = shapecentroid (nshape)(:); +%! assert(vn,v,1e-2); + +%!test % Translation +%! v = shapecentroid (shape)(:); +%! nshape = shapetransform (shape, -v); +%! vn = shapecentroid (nshape)(:); +%! assert(vn,[0; 0],1e-2); Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m 2012-03-22 17:54:01 UTC (rev 10005) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m 2012-03-22 22:05:06 UTC (rev 10006) @@ -109,36 +109,3 @@ %! axis square -%!shared shape -%! shape = {[-93.172 606.368 -476.054 291.429; ... -%! -431.196 637.253 11.085 163.791]; ... -%! [-75.3626 -253.2337 457.1678 328.5714; ... -%! 438.7659 -653.6278 -7.9953 380.9336]; ... -%! [-89.5841 344.9716 -275.3876 457.1429; ... -%! -170.3613 237.8858 1.0469 158.0765];... -%! [32.900 -298.704 145.804 437.143; ... -%! -243.903 369.597 -34.265 226.648]; ... -%! [-99.081 409.127 -352.903 317.143; ... -%! 55.289 -114.223 -26.781 318.076]; ... -%! [-342.231 191.266 168.108 274.286; ... -%! 58.870 -38.083 -89.358 232.362]}; - -%!test -%! v = shapecentroid (shape)(:); -%! nshape = shapetransform (shape, -v); -%! vn = shapecentroid (nshape)(:); -%! assert(vn,[0; 0],1e-2); - -%!test -%! v = shapecentroid (shape)(:); -%! T = createLineReflection([0 0 1 0]); -%! nshape = shapetransform (shape, T); -%! vn = shapecentroid (nshape)(:); -%! assert(vn,T(1:2,1:2)*v); - -%!test -%! v = shapecentroid (shape)(:); -%! T = createRotation(v.',pi/2); -%! nshape = shapetransform (shape, T); -%! vn = shapecentroid (nshape)(:); -%! assert(vn,v,1e-2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-22 17:54:10
|
Revision: 10005 http://octave.svn.sourceforge.net/octave/?rev=10005&view=rev Author: jpicarbajal Date: 2012-03-22 17:54:01 +0000 (Thu, 22 Mar 2012) Log Message: ----------- geometry: Improving docstring Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/geom2d/cbezier2poly.m Modified: trunk/octave-forge/main/geometry/inst/geom2d/cbezier2poly.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/cbezier2poly.m 2012-03-22 17:33:22 UTC (rev 10004) +++ trunk/octave-forge/main/geometry/inst/geom2d/cbezier2poly.m 2012-03-22 17:54:01 UTC (rev 10005) @@ -10,8 +10,8 @@ %% %% 1. Redistributions of source code must retain the above copyright notice, this %% list of conditions and the following disclaimer. -%% -%% 2. Redistributions in binary form must reproduce the above copyright notice, +%% +%% 2. Redistributions in binary form must reproduce the above copyright notice, %% this list of conditions and the following disclaimer in the documentation %% and/or other materials provided with the distribution. %% @@ -19,9 +19,9 @@ %% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE %% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE %% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -%% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +%% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR %% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -%% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +%% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS %% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN %% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) %% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE @@ -37,7 +37,11 @@ %% Returns the polynomial representation of the cubic Bezier defined by the control points @var{points}. %% %% With only one input argument, calculates the polynomial @var{pp} of the cubic -%% Bezier curve defined by the 4 control points stored in @var{points}. +%% Bezier curve defined by the 4 control points stored in @var{points}. The first +%% point is the inital point of the curve. The segment joining the first point +%% with the second point defines the tangent of the curve at the initial point. +%% The segment that joints the third point with the fourth defines the tanget at +%% the end-point of the curve, which is defined in the fourth point. %% @var{points} is either a 4-by-2 array (vertical concatenation of point %% coordinates), or a 1-by-8 array (horizotnal concatenation of point %% coordinates). @var{pp} is a 2-by-3 array, 1st row is the polynomial for the @@ -73,7 +77,7 @@ % compute coefficients of Bezier Polynomial pp = zeros(2,4); - + pp(:,4) = [p1(1); ... p1(2)]; pp(:,3) = [3 * c1(1) - 3 * p1(1); ... @@ -148,4 +152,3 @@ %! y2 = polyval(pp(2,:),t); %! assert(x,x2); %! assert(y,y2); - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-22 17:33:35
|
Revision: 10004 http://octave.svn.sourceforge.net/octave/?rev=10004&view=rev Author: jpicarbajal Date: 2012-03-22 17:33:22 +0000 (Thu, 22 Mar 2012) Log Message: ----------- geometry: deprecating svg functions. Adding license to python scripts Modified Paths: -------------- trunk/octave-forge/main/geometry/INDEX trunk/octave-forge/main/geometry/NEWS trunk/octave-forge/main/geometry/inst/io/@svg/parsePath.py trunk/octave-forge/main/geometry/inst/io/@svg/parseSVGData.py Added Paths: ----------- trunk/octave-forge/main/geometry/inst/io/deprecated/ trunk/octave-forge/main/geometry/inst/io/deprecated/private/ trunk/octave-forge/main/geometry/inst/io/deprecated/private/SVGstrPath2SVGpath.m trunk/octave-forge/main/geometry/inst/io/deprecated/private/formatSVGstr.m trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGPaths_py.m trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGdata.m trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGstrPath.m trunk/octave-forge/main/geometry/inst/io/deprecated/svgload.m trunk/octave-forge/main/geometry/inst/io/deprecated/svgnormalize.m trunk/octave-forge/main/geometry/inst/io/deprecated/svgpath2polygon.m trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py Removed Paths: ------------- trunk/octave-forge/main/geometry/inst/io/private/SVGstrPath2SVGpath.m trunk/octave-forge/main/geometry/inst/io/private/formatSVGstr.m trunk/octave-forge/main/geometry/inst/io/private/getSVGPaths_py.m trunk/octave-forge/main/geometry/inst/io/private/getSVGdata.m trunk/octave-forge/main/geometry/inst/io/private/getSVGstrPath.m trunk/octave-forge/main/geometry/inst/io/private/parsePath.py trunk/octave-forge/main/geometry/inst/io/svgload.m trunk/octave-forge/main/geometry/inst/io/svgnormalize.m trunk/octave-forge/main/geometry/inst/io/svgpath2polygon.m Modified: trunk/octave-forge/main/geometry/INDEX =================================================================== --- trunk/octave-forge/main/geometry/INDEX 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/INDEX 2012-03-22 17:33:22 UTC (rev 10004) @@ -144,9 +144,6 @@ drawGraph.m Geometric graphs manipulation Input - svgload - svgnormalize - svgpath2polygon @svg/svg @svg/plot @svg/getpath Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/NEWS 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,12 +1,15 @@ Summary of important user-visible changes for releases of the geometry package =============================================================================== -geometry-1.4.1 Release Date: 2012-03-18 Release Manager: Juan Pablo Carbajal +geometry-1.4.1 Release Date: 2012-03-22 Release Manager: Juan Pablo Carbajal =============================================================================== * Renamed functions - Contents.m renamed to geom2d_Contents to avoid clashes. +* Deprecated functions + - svgload, svgnormalize, svgpath2polygon: Use the methods in class svg. + * Bug fixes - @svg/path2polygon.m - Fix addpath/rmpath installation warnings Modified: trunk/octave-forge/main/geometry/inst/io/@svg/parsePath.py =================================================================== --- trunk/octave-forge/main/geometry/inst/io/@svg/parsePath.py 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/@svg/parsePath.py 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,5 +1,20 @@ #!/usr/bin/env python +## Copyright (c) 2012 Juan Pablo Carbajal <car...@if...> +## +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## 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 General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see <http://www.gnu.org/licenses/>. + import inkex, simplepath import sys #import getopt @@ -8,7 +23,7 @@ svg = inkex.Effect () svg.parse (filen) - + paths = svg.document.xpath ('//svg:path', namespaces=inkex.NSS) for path in paths: D = simplepath.parsePath (path.attrib['d']) @@ -17,14 +32,14 @@ for cmd,params in D: cmdlst.append(cmd) parlst.append(params) - + print 'svgpath = struct("cmd","{0}","data",{{{1}}});' \ .format(''.join(cmdlst),str(parlst).replace('[[','[').replace(']]',']')) print 'svgpathid = "{0}"; $'.format(path.attrib['id']) - - + + # ---------------------------- if __name__=="__main__": @@ -34,7 +49,7 @@ except getopt.GetoptError: usage() sys.exit(2) - + doHelp = 0 c = Context() c.doPrint = 1 Modified: trunk/octave-forge/main/geometry/inst/io/@svg/parseSVGData.py =================================================================== --- trunk/octave-forge/main/geometry/inst/io/@svg/parseSVGData.py 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/@svg/parseSVGData.py 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,5 +1,19 @@ #!/usr/bin/env python +## Copyright (c) 2012 Juan Pablo Carbajal <car...@if...> +## +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## 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 General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see <http://www.gnu.org/licenses/>. import inkex import sys #import getopt @@ -8,7 +22,7 @@ svg = inkex.Effect () svg.parse (filen) - + root = svg.document.xpath ('//svg:svg', namespaces=inkex.NSS) print 'data = struct("height",{0},"width",{1},"id","{2}");' \ .format(root[0].attrib['height'],root[0].attrib['width'], Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/private/SVGstrPath2SVGpath.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/private/SVGstrPath2SVGpath.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/private/SVGstrPath2SVGpath.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/private/SVGstrPath2SVGpath.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,103 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% 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 General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function SVGpath = SVGstrPath2SVGpath (SVGstrPath) + + nPaths = numel (SVGstrPath); + SVGpath = repmat (struct('coord', [], 'closed', [], 'id', []), 1, nPaths); + + for ip = 1:nPaths + path = SVGstrPath{ip}; + + % Match data + [s e te m] = regexpi (path, 'd="(?:(?!").)*'); + data=strtrim (m{1}); + % parse data + d = parsePathData (data); + SVGpath(ip).coord = d.coord; + SVGpath(ip).closed = d.closed; + + % Match id + [s e te m] = regexp (path, 'id="(?:(?!").)*'); + if ~isempty (m) + SVGpath(ip).id = strtrim (m{1}(5:end)); + end + end + +end + +function d = parsePathData (data) + + d = struct ('coord', [], 'closed', []); + + [s e te comm] = regexp (data, '[MmLlHhVvCcSsQqTtAaZz]{1}'); + % TODO + % This info could be used to preallocate d + [zcomm zpos] = ismember ({'Z','z'}, comm); + + if any (zcomm) + d.closed = true; + else + d.closed = false; + s(end+1) = length (data); + end + comm(zpos(zcomm)) = []; + ncomm = size (comm, 2); + for ic = 1:ncomm + + switch comm{ic} + case {'M','L'} + [x y] = strread (data(s(ic) + 1 : s(ic + 1) - 1), ... + '%f%f', 'delimiter', ', '); + coord = [x y]; + + case 'm' + [x y] = strread( data(s(ic) + 1 : s(ic + 1) - 1), ... + '%f%f', 'delimiter', ', '); + nc = size (x, 1); + coord = [x y]; + if ic == 1 + % relative moveto at begining of data. + % First coordinates are absolute, the rest are relative. + coord = cumsum (coord); + else + % Relative moveto. + % The coordinates are relative to the last one loaded + coord(1,:) =coord(1,:) + d.coord(end,:); + coord = cumsum(coord); + warning('svg2octWarning',['Relative moveto in path data.'... + ' May mean that the orginal path was not a simple polygon.' ... + ' If that is the case, the path will not display equally.']) + end + + case 'l' + % Relative lineto, coordinates are relative to last point loaded. + [x y] = strread( data(s(ic) + 1 : s(ic + 1) - 1), ... + '%f%f', 'delimiter', ', '); + nc = size (x, 1); + coord = [x y] + coord(1,:) =coord(1,:) + d.coord(end,:); + coord = cumsum(coord); + + otherwise + warning('svg2oct:Warning',... + 'Path data command "%s" not implemented yet.',comm{ic}); + end + + nc = size(coord,1); + d.coord(end+1:end+nc,:) = coord; + + end +end Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/private/formatSVGstr.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/private/formatSVGstr.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/private/formatSVGstr.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/private/formatSVGstr.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,24 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% 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 General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function svgF = formatSVGstr(svg) + + % Remove all newlines and tabs + svgF = strrep(svg,"\n",' '); + svgF = strrep(svgF,"\t",' '); + % Remove consecutive blanks + svgF = regexprep(svgF,' +',' '); + +end Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGPaths_py.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/private/getSVGPaths_py.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGPaths_py.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGPaths_py.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,113 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% 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 General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function Paths = getSVGPaths_py (svg, varargin) + + %% Call python script + if exist (svg,'file') + % read from file + [st str]=system (sprintf ('python parsePath.py %s', svg)); + + else + % inline SVG + [st str]=system (sprintf ('python parsePath.py < %s', svg)); + end + + %% Parse ouput + strpath = strsplit (str(1:end-1), '$', true); + + npaths = numel (strpath); + + %% Convert path data to polygons + for ip = 1:npaths + + eval (strpath{ip}); + %% FIXME: intialize struct with cell field + svgpath2.cmd = svgpath(1).cmd; + svgpath2.data = {svgpath.data}; + + nD = length(svgpath2.cmd); + pathdata = cell (nD-1,1); + + point_end=[]; + %% If the path is closed, last command is Z and we set initial point == final + if svgpath2.cmd(end) == 'Z' + nD -= 1; + point_end = svgpath2.data{1}; + end + + %% Initial point + points(1,:) = svgpath2.data{1}; + + for jp = 2:nD + switch svgpath2.cmd(jp) + case 'L' + %% Straigth segment to polygon + points(2,:) = svgpath2.data{jp}; + pp = [(points(2,:)-points(1,:))' points(1,:)']; + clear points + points(1,:) = [polyval(pp(1,:),1) polyval(pp(2,:),1)]; + + case 'C' + %% Cubic bezier to polygon + points(2:4,:) = reshape (svgpath2.data{jp}, 2, 3).'; + pp = cbezier2poly (points); + clear points + points(1,:) = [polyval(pp(1,:),1) polyval(pp(2,:),1)]; + end + + pathdata{jp-1} = pp; + end + + if ~isempty(point_end) + %% Straight segmet to close the path + points(2,:) = point_end; + pp = [(points(2,:)-points(1,:))' points(1,:)']; + + pathdata{end} = pp; + end + + Paths.(svgpathid).data = pathdata; + end +endfunction + +%!test +%! figure(1) +%! hold on +%! paths = getSVGPaths_py ('../drawing.svg'); +%! +%! % Get path ids +%! ids = fieldnames(paths); +%! npath = numel(ids); +%! +%! t = linspace (0, 1, 64); +%! +%! for i = 1:npath +%! x = []; y = []; +%! data = paths.(ids(i)).data; +%! +%! for j = 1:numel(data) +%! x = cat (2, x, polyval (data{j}(1,:),t)); +%! y = cat (2, y, polyval (data{j}(2,:),t)); +%! end +%! +%! plot(x,y,'-'); +%! end +%! axis ij +%! if strcmpi(input('You should see drawing.svg [y/n] ','s'),'n') +%! error ("didn't get what was expected."); +%! end +%! close + Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGdata.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/private/getSVGdata.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGdata.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGdata.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,33 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% 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 General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function svgData = getSVGdata(svg) + + svgData = struct('height',[],'width',[]); + attr = fieldnames(svgData); + nattr = numel(attr); + + [s e te data] = regexpi(svg,'<[ ]*svg(?:(?!>).)*>'); + data=strtrim(data{1}); + + for a = 1:nattr + pattr =sprintf('%s="(?:(?!").)*',attr{a}); + [s e te m] = regexpi(data,pattr); + m=strtrim(m{1}); + [dummy value] = strread(m,'%s%f','delimiter','"'); + svgData.(attr{a}) = value; + end + +end Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGstrPath.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/private/getSVGstrPath.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGstrPath.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGstrPath.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,20 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% 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 General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function strPath = getSVGstrPath(svg) + + [s e te strPath] = regexpi(svg,'<[ ]*path(?:(?!/>).)*/>'); + +end Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/svgload.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/svgload.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/svgload.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/svgload.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,62 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% 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 General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} @var{SVG} = loadSVG (@var{filename}) +%% Reads the plain SVG file @var{filename} and returns an SVG structure. +%% +%% In the current version only SVG path elements are parsed and stored in the field +%% path of the @var{SVG} structure. +%% The coordinates of the path are not modified in anyway. This produces the path +%% to be ploted vertically reflected. +%% +%% @seealso{svgnormalize, svgpath2polygon} +%% @end deftypefn + + +function SVG = svgload (filename) + + SVG = struct ('height', [], 'width', [], 'path', [], 'normalized', []); + + SVG.normalized = false; + + fid = fopen (filename); + svg = char (fread (fid, "uchar")'); + fclose (fid); + svgF = formatSVGstr (svg); + + % Get SVG Data + data = getSVGdata (svgF); + SVG.height = data.height; + SVG.width = data.width; + + % Get SVG Paths + SVGstrPath = getSVGstrPath (svgF); + SVGpath = SVGstrPath2SVGpath (SVGstrPath); + SVG.path = SVGpath; + +end + +%!demo +%! file = 'tmp__.svg'; +%! fid = fopen (file,'w'); +%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /></svg></body></html>'; +%! fprintf (fid,"%s\n",svgfile); +%! fclose (fid); +%! SVG = svgload (file); +%! SVG +%! plot([SVG.path.coord(:,1); SVG.path.coord(1,1)], ... +%! [SVG.path.coord(:,2); SVG.path.coord(1,2)]); +%! delete (file); Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/svgnormalize.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/svgnormalize.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/svgnormalize.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/svgnormalize.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,68 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% 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 General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} @var{SVGn} = loadSVG (@var{SVG}) +%% Scales and reflects the @var{SVG} structure and returns a modified @var{SVGn} +%% structure. +%% +%% The height and width of the SVG are scaled such that the diagonal of the +%% bounding box has length 1. Coordinates are trasnfomed such that a plot of the +%% paths coincides with the visualization of the original SVG. +%% +%% @seealso{svgload, svgpath2polygon} +%% @end deftypefn + +function SVGn = svgnormalize (SVG) + + SVGn = SVG; + if ~SVG.normalized + % Translate + TransV = [0, SVG.height/2]; + % Scale + Dnorm = sqrt (SVG.width ^ 2 + SVG.height ^ 2); + S = (1 / Dnorm) * eye (2); + for i = 1:numel (SVG.path) + nc = size (SVG.path(i).coord, 1); + % Translate to middle + T = repmat (TransV,nc, 1); + SVGn.path(i).coord = SVG.path(i).coord - T; + % Reflect + SVGn.path(i).coord(:, 2) = -SVGn.path(i).coord(:,2); + T(:,2) = -T(:,2); + % Translate to bottom + SVGn.path(i).coord = SVGn.path(i).coord - T; + %Scale + SVGn.path(i).coord = SVGn.path(i).coord * S; + end + SVGn.height = SVG.height / Dnorm; + SVGn.width = SVG.width / Dnorm; + SVGn.normalized = true; + end + +end + +%!demo +%! file = 'tmp__.svg'; +%! fid = fopen (file,'w'); +%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /></svg></body></html>'; +%! fprintf (fid,"%s\n",svgfile); +%! fclose (fid); +%! SVG = svgload (file); +%! SVGn = svgnormalize (SVG); +%! SVGn +%! plot([SVGn.path.coord(:,1); SVGn.path.coord(1,1)], ... +%! [SVGn.path.coord(:,2); SVGn.path.coord(1,2)]); +%! delete (file); Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/svgpath2polygon.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/svgpath2polygon.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/svgpath2polygon.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/svgpath2polygon.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,60 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% 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 General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} @var{P} = svgpath2polygon (@var{SVGpath}) +%% Converts the SVG path structure @var{SVGpath} to an array of polygons +%% compatible with the geometry package and matGeom (@url{http://matgeom.sf.net}). +%% +%% @var{SVGpath} is a substructure of the SVG structure output by loadSVG. This +%% function extracts the field named "coord" if there is only one path. If there +%% are more than oe path it puts the "coord" field of each path in the same +%% array, separated by nans. +%% +%% @seealso{svgnormalize, svgload} +%% @end deftypefn + +function P = svgpath2polygon (SVGpath) + + P = SVGpath(1).coord; + for ip = 2:numel (SVGpath) + P = [P; nan(1,2); SVGpath(ip).coord]; + end + +end + +%!demo +%! file = 'tmp__.svg'; +%! fid = fopen (file,'w'); +%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /></svg></body></html>'; +%! fprintf (fid,"%s\n",svgfile); +%! fclose (fid); +%! SVG = svgload (file); +%! SVG = svgnormalize (SVG); +%! P = svgpath2polygon (SVG.path); +%! plot (P(:,1),P(:,2)); +%! delete (file); + +%!demo +%! file = 'tmp__.svg'; +%! fid = fopen (file,'w'); +%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /><path d="M0,0 100,0 100,100 0,100 Z" /></svg></body></html>'; +%! fprintf (fid,"%s\n",svgfile); +%! fclose (fid); +%! SVG = svgload (file); +%! SVG = svgnormalize (SVG); +%! P = svgpath2polygon (SVG.path); +%! plot (P(:,1),P(:,2)); +%! delete (file); Deleted: trunk/octave-forge/main/geometry/inst/io/private/SVGstrPath2SVGpath.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/SVGstrPath2SVGpath.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/private/SVGstrPath2SVGpath.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,103 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% 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 General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function SVGpath = SVGstrPath2SVGpath (SVGstrPath) - - nPaths = numel (SVGstrPath); - SVGpath = repmat (struct('coord', [], 'closed', [], 'id', []), 1, nPaths); - - for ip = 1:nPaths - path = SVGstrPath{ip}; - - % Match data - [s e te m] = regexpi (path, 'd="(?:(?!").)*'); - data=strtrim (m{1}); - % parse data - d = parsePathData (data); - SVGpath(ip).coord = d.coord; - SVGpath(ip).closed = d.closed; - - % Match id - [s e te m] = regexp (path, 'id="(?:(?!").)*'); - if ~isempty (m) - SVGpath(ip).id = strtrim (m{1}(5:end)); - end - end - -end - -function d = parsePathData (data) - - d = struct ('coord', [], 'closed', []); - - [s e te comm] = regexp (data, '[MmLlHhVvCcSsQqTtAaZz]{1}'); - % TODO - % This info could be used to preallocate d - [zcomm zpos] = ismember ({'Z','z'}, comm); - - if any (zcomm) - d.closed = true; - else - d.closed = false; - s(end+1) = length (data); - end - comm(zpos(zcomm)) = []; - ncomm = size (comm, 2); - for ic = 1:ncomm - - switch comm{ic} - case {'M','L'} - [x y] = strread (data(s(ic) + 1 : s(ic + 1) - 1), ... - '%f%f', 'delimiter', ', '); - coord = [x y]; - - case 'm' - [x y] = strread( data(s(ic) + 1 : s(ic + 1) - 1), ... - '%f%f', 'delimiter', ', '); - nc = size (x, 1); - coord = [x y]; - if ic == 1 - % relative moveto at begining of data. - % First coordinates are absolute, the rest are relative. - coord = cumsum (coord); - else - % Relative moveto. - % The coordinates are relative to the last one loaded - coord(1,:) =coord(1,:) + d.coord(end,:); - coord = cumsum(coord); - warning('svg2octWarning',['Relative moveto in path data.'... - ' May mean that the orginal path was not a simple polygon.' ... - ' If that is the case, the path will not display equally.']) - end - - case 'l' - % Relative lineto, coordinates are relative to last point loaded. - [x y] = strread( data(s(ic) + 1 : s(ic + 1) - 1), ... - '%f%f', 'delimiter', ', '); - nc = size (x, 1); - coord = [x y] - coord(1,:) =coord(1,:) + d.coord(end,:); - coord = cumsum(coord); - - otherwise - warning('svg2oct:Warning',... - 'Path data command "%s" not implemented yet.',comm{ic}); - end - - nc = size(coord,1); - d.coord(end+1:end+nc,:) = coord; - - end -end Copied: trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py (from rev 10003, trunk/octave-forge/main/geometry/inst/io/private/parsePath.py) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import inkex, simplepath +import sys +#import getopt + +def parsePaths (filen=None): + + svg = inkex.Effect () + svg.parse (filen) + + paths = svg.document.xpath ('//svg:path', namespaces=inkex.NSS) + for path in paths: + D = simplepath.parsePath (path.attrib['d']) + cmdlst = []; + parlst = []; + for cmd,params in D: + cmdlst.append(cmd) + parlst.append(params) + + print 'svgpath = struct("cmd","{0}","data",{{{1}}});' \ + .format(''.join(cmdlst),str(parlst).replace('[[','[').replace(']]',']')) + + print 'svgpathid = "{0}"; $'.format(path.attrib['id']) + + + +# ---------------------------- + +if __name__=="__main__": + ''' + try: + optlist,args = getopt.getopt(sys.argv[1:],"thdp") + except getopt.GetoptError: + usage() + sys.exit(2) + + doHelp = 0 + c = Context() + c.doPrint = 1 + for opt in optlist: + if opt[0] == "-d": c.debug = 1 + if opt[0] == "-p": c.plot = 1 + if opt[0] == "-t": c.triangulate = 1 + if opt[0] == "-h": doHelp = 1 + + if not doHelp: + pts = [] + fp = sys.stdin + if len(args) > 0: + fp = open(args[0],'r') + for line in fp: + fld = line.split() + x = float(fld[0]) + y = float(fld[1]) + pts.append(Site(x,y)) + if len(args) > 0: fp.close() + + if doHelp or len(pts) == 0: + usage() + sys.exit(2) + ''' + svg = sys.argv[1] + parsePaths(svg) Deleted: trunk/octave-forge/main/geometry/inst/io/private/formatSVGstr.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/formatSVGstr.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/private/formatSVGstr.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,24 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% 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 General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function svgF = formatSVGstr(svg) - - % Remove all newlines and tabs - svgF = strrep(svg,"\n",' '); - svgF = strrep(svgF,"\t",' '); - % Remove consecutive blanks - svgF = regexprep(svgF,' +',' '); - -end Deleted: trunk/octave-forge/main/geometry/inst/io/private/getSVGPaths_py.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/getSVGPaths_py.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/private/getSVGPaths_py.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,113 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% 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 General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function Paths = getSVGPaths_py (svg, varargin) - - %% Call python script - if exist (svg,'file') - % read from file - [st str]=system (sprintf ('python parsePath.py %s', svg)); - - else - % inline SVG - [st str]=system (sprintf ('python parsePath.py < %s', svg)); - end - - %% Parse ouput - strpath = strsplit (str(1:end-1), '$', true); - - npaths = numel (strpath); - - %% Convert path data to polygons - for ip = 1:npaths - - eval (strpath{ip}); - %% FIXME: intialize struct with cell field - svgpath2.cmd = svgpath(1).cmd; - svgpath2.data = {svgpath.data}; - - nD = length(svgpath2.cmd); - pathdata = cell (nD-1,1); - - point_end=[]; - %% If the path is closed, last command is Z and we set initial point == final - if svgpath2.cmd(end) == 'Z' - nD -= 1; - point_end = svgpath2.data{1}; - end - - %% Initial point - points(1,:) = svgpath2.data{1}; - - for jp = 2:nD - switch svgpath2.cmd(jp) - case 'L' - %% Straigth segment to polygon - points(2,:) = svgpath2.data{jp}; - pp = [(points(2,:)-points(1,:))' points(1,:)']; - clear points - points(1,:) = [polyval(pp(1,:),1) polyval(pp(2,:),1)]; - - case 'C' - %% Cubic bezier to polygon - points(2:4,:) = reshape (svgpath2.data{jp}, 2, 3).'; - pp = cbezier2poly (points); - clear points - points(1,:) = [polyval(pp(1,:),1) polyval(pp(2,:),1)]; - end - - pathdata{jp-1} = pp; - end - - if ~isempty(point_end) - %% Straight segmet to close the path - points(2,:) = point_end; - pp = [(points(2,:)-points(1,:))' points(1,:)']; - - pathdata{end} = pp; - end - - Paths.(svgpathid).data = pathdata; - end -endfunction - -%!test -%! figure(1) -%! hold on -%! paths = getSVGPaths_py ('../drawing.svg'); -%! -%! % Get path ids -%! ids = fieldnames(paths); -%! npath = numel(ids); -%! -%! t = linspace (0, 1, 64); -%! -%! for i = 1:npath -%! x = []; y = []; -%! data = paths.(ids(i)).data; -%! -%! for j = 1:numel(data) -%! x = cat (2, x, polyval (data{j}(1,:),t)); -%! y = cat (2, y, polyval (data{j}(2,:),t)); -%! end -%! -%! plot(x,y,'-'); -%! end -%! axis ij -%! if strcmpi(input('You should see drawing.svg [y/n] ','s'),'n') -%! error ("didn't get what was expected."); -%! end -%! close - Deleted: trunk/octave-forge/main/geometry/inst/io/private/getSVGdata.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/getSVGdata.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/private/getSVGdata.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,33 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% 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 General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function svgData = getSVGdata(svg) - - svgData = struct('height',[],'width',[]); - attr = fieldnames(svgData); - nattr = numel(attr); - - [s e te data] = regexpi(svg,'<[ ]*svg(?:(?!>).)*>'); - data=strtrim(data{1}); - - for a = 1:nattr - pattr =sprintf('%s="(?:(?!").)*',attr{a}); - [s e te m] = regexpi(data,pattr); - m=strtrim(m{1}); - [dummy value] = strread(m,'%s%f','delimiter','"'); - svgData.(attr{a}) = value; - end - -end Deleted: trunk/octave-forge/main/geometry/inst/io/private/getSVGstrPath.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/getSVGstrPath.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/private/getSVGstrPath.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,20 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% 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 General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function strPath = getSVGstrPath(svg) - - [s e te strPath] = regexpi(svg,'<[ ]*path(?:(?!/>).)*/>'); - -end Deleted: trunk/octave-forge/main/geometry/inst/io/private/parsePath.py =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/parsePath.py 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/private/parsePath.py 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,64 +0,0 @@ -#!/usr/bin/env python - -import inkex, simplepath -import sys -#import getopt - -def parsePaths (filen=None): - - svg = inkex.Effect () - svg.parse (filen) - - paths = svg.document.xpath ('//svg:path', namespaces=inkex.NSS) - for path in paths: - D = simplepath.parsePath (path.attrib['d']) - cmdlst = []; - parlst = []; - for cmd,params in D: - cmdlst.append(cmd) - parlst.append(params) - - print 'svgpath = struct("cmd","{0}","data",{{{1}}});' \ - .format(''.join(cmdlst),str(parlst).replace('[[','[').replace(']]',']')) - - print 'svgpathid = "{0}"; $'.format(path.attrib['id']) - - - -# ---------------------------- - -if __name__=="__main__": - ''' - try: - optlist,args = getopt.getopt(sys.argv[1:],"thdp") - except getopt.GetoptError: - usage() - sys.exit(2) - - doHelp = 0 - c = Context() - c.doPrint = 1 - for opt in optlist: - if opt[0] == "-d": c.debug = 1 - if opt[0] == "-p": c.plot = 1 - if opt[0] == "-t": c.triangulate = 1 - if opt[0] == "-h": doHelp = 1 - - if not doHelp: - pts = [] - fp = sys.stdin - if len(args) > 0: - fp = open(args[0],'r') - for line in fp: - fld = line.split() - x = float(fld[0]) - y = float(fld[1]) - pts.append(Site(x,y)) - if len(args) > 0: fp.close() - - if doHelp or len(pts) == 0: - usage() - sys.exit(2) - ''' - svg = sys.argv[1] - parsePaths(svg) Deleted: trunk/octave-forge/main/geometry/inst/io/svgload.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/svgload.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/svgload.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,62 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% 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 General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -%% -*- texinfo -*- -%% @deftypefn {Function File} @var{SVG} = loadSVG (@var{filename}) -%% Reads the plain SVG file @var{filename} and returns an SVG structure. -%% -%% In the current version only SVG path elements are parsed and stored in the field -%% path of the @var{SVG} structure. -%% The coordinates of the path are not modified in anyway. This produces the path -%% to be ploted vertically reflected. -%% -%% @seealso{svgnormalize, svgpath2polygon} -%% @end deftypefn - - -function SVG = svgload (filename) - - SVG = struct ('height', [], 'width', [], 'path', [], 'normalized', []); - - SVG.normalized = false; - - fid = fopen (filename); - svg = char (fread (fid, "uchar")'); - fclose (fid); - svgF = formatSVGstr (svg); - - % Get SVG Data - data = getSVGdata (svgF); - SVG.height = data.height; - SVG.width = data.width; - - % Get SVG Paths - SVGstrPath = getSVGstrPath (svgF); - SVGpath = SVGstrPath2SVGpath (SVGstrPath); - SVG.path = SVGpath; - -end - -%!demo -%! file = 'tmp__.svg'; -%! fid = fopen (file,'w'); -%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /></svg></body></html>'; -%! fprintf (fid,"%s\n",svgfile); -%! fclose (fid); -%! SVG = svgload (file); -%! SVG -%! plot([SVG.path.coord(:,1); SVG.path.coord(1,1)], ... -%! [SVG.path.coord(:,2); SVG.path.coord(1,2)]); -%! delete (file); Deleted: trunk/octave-forge/main/geometry/inst/io/svgnormalize.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/svgnormalize.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/svgnormalize.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,68 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% 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 General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -%% -*- texinfo -*- -%% @deftypefn {Function File} @var{SVGn} = loadSVG (@var{SVG}) -%% Scales and reflects the @var{SVG} structure and returns a modified @var{SVGn} -%% structure. -%% -%% The height and width of the SVG are scaled such that the diagonal of the -%% bounding box has length 1. Coordinates are trasnfomed such that a plot of the -%% paths coincides with the visualization of the original SVG. -%% -%% @seealso{svgload, svgpath2polygon} -%% @end deftypefn - -function SVGn = svgnormalize (SVG) - - SVGn = SVG; - if ~SVG.normalized - % Translate - TransV = [0, SVG.height/2]; - % Scale - Dnorm = sqrt (SVG.width ^ 2 + SVG.height ^ 2); - S = (1 / Dnorm) * eye (2); - for i = 1:numel (SVG.path) - nc = size (SVG.path(i).coord, 1); - % Translate to middle - T = repmat (TransV,nc, 1); - SVGn.path(i).coord = SVG.path(i).coord - T; - % Reflect - SVGn.path(i).coord(:, 2) = -SVGn.path(i).coord(:,2); - T(:,2) = -T(:,2); - % Translate to bottom - SVGn.path(i).coord = SVGn.path(i).coord - T; - %Scale - SVGn.path(i).coord = SVGn.path(i).coord * S; - end - SVGn.height = SVG.height / Dnorm; - SVGn.width = SVG.width / Dnorm; - SVGn.normalized = true; - end - -end - -%!demo -%! file = 'tmp__.svg'; -%! fid = fopen (file,'w'); -%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /></svg></body></html>'; -%! fprintf (fid,"%s\n",svgfile); -%! fclose (fid); -%! SVG = svgload (file); -%! SVGn = svgnormalize (SVG); -%! SVGn -%! plot([SVGn.path.coord(:,1); SVGn.path.coord(1,1)], ... -%! [SVGn.path.coord(:,2); SVGn.path.coord(1,2)]); -%! delete (file); Deleted: trunk/octave-forge/main/geometry/inst/io/svgpath2polygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/svgpath2polygon.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/svgpath2polygon.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,60 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% 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 General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -%% -*- texinfo -*- -%% @deftypefn {Function File} @var{P} = svgpath2polygon (@var{SVGpath}) -%% Converts the SVG path structure @var{SVGpath} to an array of polygons -%% compatible with the geometry package and matGeom (@url{http://matgeom.sf.net}). -%% -%% @var{SVGpath} is a substructure of the SVG structure output by loadSVG. This -%% function extracts the field named "coord" if there is only one path. If there -%% are more than oe path it puts the "coord" field of each path in the same -%% array, separated by nans. -%% -%% @seealso{svgnormalize, svgload} -%% @end deftypefn - -function P = svgpath2polygon (SVGpath) - - P = SVGpath(1).coord; - for ip = 2:numel (SVGpath) - P = [P; nan(1,2); SVGpath(ip).coord]; - end - -end - -%!demo -%! file = 'tmp__.svg'; -%! fid = fopen (file,'w'); -%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /></svg></body></html>'; -%! fprintf (fid,"%s\n",svgfile); -%! fclose (fid); -%! SVG = svgload (file); -%! SVG = svgnormalize (SVG); -%! P = svgpath2polygon (SVG.path); -%! plot (P(:,1),P(:,2)); -%! delete (file); - -%!demo -%! file = 'tmp__.svg'; -%! fid = fopen (file,'w'); -%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /><path d="M0,0 100,0 100,100 0,100 Z" /></svg></body></html>'; -%! fprintf (fid,"%s\n",svgfile); -%! fclose (fid); -%! SVG = svgload (file); -%! SVG = svgnormalize (SVG); -%! P = svgpath2polygon (SVG.path); -%! plot (P(:,1),P(:,2)); -%! delete (file); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-03-22 15:08:39
|
Revision: 10003 http://octave.svn.sourceforge.net/octave/?rev=10003&view=rev Author: prnienhuis Date: 2012-03-22 15:08:33 +0000 (Thu, 22 Mar 2012) Log Message: ----------- Improved Java checks; some message text edits Modified Paths: -------------- trunk/octave-forge/main/io/inst/odsopen.m Modified: trunk/octave-forge/main/io/inst/odsopen.m =================================================================== --- trunk/octave-forge/main/io/inst/odsopen.m 2012-03-22 15:07:58 UTC (rev 10002) +++ trunk/octave-forge/main/io/inst/odsopen.m 2012-03-22 15:08:33 UTC (rev 10003) @@ -1,24 +1,25 @@ ## Copyright (C) 2009,2010,2011,2012 Philip Nienhuis <prnienhuis at users.sf.net> -## -## This program is free software; you can redistribute it and/or modify it under -## the terms of the GNU 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 General Public License for more -## details. -## -## You should have received a copy of the GNU General Public License along with -## this program; if not, see <http://www.gnu.org/licenses/>. +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 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 General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} @var{ods} = odsopen (@var{filename}) ## @deftypefnx {Function File} @var{ods} = odsopen (@var{filename}, @var{readwrite}) ## @deftypefnx {Function File} @var{ods} = odsopen (@var{filename}, @var{readwrite}, @var{reqintf}) ## Get a pointer to an OpenOffice_org spreadsheet in the form of return -## argument (struct) @var{ods}. +## argument @var{ods}. ## ## Calling odsopen without specifying a return argument is fairly useless! ## @@ -91,7 +92,7 @@ ## 2012-01-26 Fixed "seealso" help string ## 2012-02-26 Added ";" to suppress echo of filename f UNO ## -## Latest change on subfunctions below: 2012-02-01 +## Latest change on subfunctions below: 2012-03-22 function [ ods ] = odsopen (filename, rw=0, reqinterface=[]) @@ -305,6 +306,7 @@ # <other interfaces here> if (~odssupport) + printf ("None.\n"); warning ("No support for OpenOffice.org .ods I/O"); ods = []; else @@ -328,19 +330,20 @@ ## Copyright (C) 2009,2010,2011 Philip Nienhuis <prnienhuis at users.sf.net> -## -## This program is free software; you can redistribute it and/or modify it under -## the terms of the GNU 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 General Public License for more -## details. -## -## You should have received a copy of the GNU General Public License along with -## this program; if not, see <http://www.gnu.org/licenses/>. +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 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 General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} @var{odsinterfaces} = getodsinterfaces (@var{odsinterfaces}) @@ -388,19 +391,24 @@ ## 2011-09-03 Fixed order of odsinterfaces.<member> statement in Java detection try-catch ## '' Reset tmp1 (always allow interface rediscovery) for empty odsinterfaces arg ## 2011-09-18 Added temporary warning about UNO interface +## 2012-03-22 Improved Java checks (analogous to xlsopen) function [odsinterfaces] = getodsinterfaces (odsinterfaces) - persistent tmp1 = []; persistent jcp; + # tmp1 = [] (not initialized), 0 (No Java detected), or 1 (Working Java found) + persistent tmp1 = []; persistent jcp; # Java class path persistent uno_1st_time = 0; if (isempty (odsinterfaces.OTK) && isempty (odsinterfaces.JOD) && isempty (odsinterfaces.UNO)) # Assume no interface detection has happened yet - printf ("Detected interfaces: "); + printf ("Detected ODS interfaces: "); tmp1 = []; elseif (isempty (odsinterfaces.OTK) || isempty (odsinterfaces.JOD) || isempty (odsinterfaces.UNO)) - # At least one interface is requested by user - tmp1 = []; + # Can't be first call. Here one of the Java interfaces is requested + if (~tmp1) + # Check Java support again + tmp1 = []; + endif endif deflt = 0; @@ -422,21 +430,23 @@ tmp1 = 1; catch # No Java support + tmp1 = 0; if ~(isempty (odsinterfaces.OTK) && isempty (odsinterfaces.JOD) && isempty (odsinterfaces.UNO)) - # Some Java-based interface requested but Java support is absent - error ('No Java support found.'); + # Some Java-based interface explicitly requested but Java support is absent + xlsinterfaces.OTK = 0; + xlsinterfaces.JOD = 0; + xlsinterfaces.UNO = 0; + warning (' No Java support found (no Java JRE? no Java pkg installed AND loaded?'); else # No specific Java-based interface requested. Just return (needed for if # ever a non-Java based interfaces will be implemented) odsinterfaces.OTK = 0; odsinterfaces.JOD = 0; odsinterfaces.UNO = 0; + printf ("\n"); return; endif end_try_catch - elseif (~tmp1) - % Earlier on no Java support detected - error (" No Java support found."); endif # Try Java & ODF toolkit This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-03-22 15:08:09
|
Revision: 10002 http://octave.svn.sourceforge.net/octave/?rev=10002&view=rev Author: prnienhuis Date: 2012-03-22 15:07:58 +0000 (Thu, 22 Mar 2012) Log Message: ----------- Error message text edits Modified Paths: -------------- trunk/octave-forge/main/io/inst/xlsopen.m Modified: trunk/octave-forge/main/io/inst/xlsopen.m =================================================================== --- trunk/octave-forge/main/io/inst/xlsopen.m 2012-03-22 01:32:39 UTC (rev 10001) +++ trunk/octave-forge/main/io/inst/xlsopen.m 2012-03-22 15:07:58 UTC (rev 10002) @@ -466,7 +466,7 @@ if (isempty (xlsinterfaces.COM) && isempty (xlsinterfaces.POI) && isempty (xlsinterfaces.JXL) && isempty (xlsinterfaces.OXS) && isempty (xlsinterfaces.UNO)) # Looks like first call to xlsopen. Check Java support - printf ("Detected interfaces: "); + printf ("Detected XLS interfaces: "); tmp1 = []; elseif (isempty (xlsinterfaces.POI) || isempty (xlsinterfaces.JXL) || isempty (xlsinterfaces.OXS) || isempty (xlsinterfaces.UNO)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-22 01:32:45
|
Revision: 10001 http://octave.svn.sourceforge.net/octave/?rev=10001&view=rev Author: slackydeb Date: 2012-03-22 01:32:39 +0000 (Thu, 22 Mar 2012) Log Message: ----------- ga: remove TODO comments from test_ga Modified Paths: -------------- trunk/octave-forge/main/ga/inst/test_ga.m Modified: trunk/octave-forge/main/ga/inst/test_ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/test_ga.m 2012-03-22 01:32:26 UTC (rev 10000) +++ trunk/octave-forge/main/ga/inst/test_ga.m 2012-03-22 01:32:39 UTC (rev 10001) @@ -43,7 +43,3 @@ ## Genetic Algorithm test gaoptimset test ga -## TODO: split performance tests - -## TODO: review all unit tests (DONE: rastriginsfcn) -## TODO: write missing unit tests, or write per-function TODOs This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-22 01:32:33
|
Revision: 10000 http://octave.svn.sourceforge.net/octave/?rev=10000&view=rev Author: slackydeb Date: 2012-03-22 01:32:26 +0000 (Thu, 22 Mar 2012) Log Message: ----------- ga: add per-function TODO comment about unit tests Modified Paths: -------------- trunk/octave-forge/main/ga/inst/crossoverscattered.m trunk/octave-forge/main/ga/inst/fitscalingrank.m trunk/octave-forge/main/ga/inst/gacreationuniform.m trunk/octave-forge/main/ga/inst/mutationgaussian.m trunk/octave-forge/main/ga/inst/selectionstochunif.m Modified: trunk/octave-forge/main/ga/inst/crossoverscattered.m =================================================================== --- trunk/octave-forge/main/ga/inst/crossoverscattered.m 2012-03-21 22:32:29 UTC (rev 9999) +++ trunk/octave-forge/main/ga/inst/crossoverscattered.m 2012-03-22 01:32:26 UTC (rev 10000) @@ -35,3 +35,15 @@ xoverKids(1:n_children, 1:nvars) = \ b .* p1 + (ones (n_children, nvars) - b) .* p2; endfunction + + +## number of input arguments +# TODO + +## number of output arguments +# TODO + +## type of arguments +# TODO + +# TODO Modified: trunk/octave-forge/main/ga/inst/fitscalingrank.m =================================================================== --- trunk/octave-forge/main/ga/inst/fitscalingrank.m 2012-03-21 22:32:29 UTC (rev 9999) +++ trunk/octave-forge/main/ga/inst/fitscalingrank.m 2012-03-22 01:32:26 UTC (rev 10000) @@ -29,6 +29,17 @@ endfunction +## number of input arguments +# TODO + +## number of output arguments +# TODO + +## type of arguments +# TODO + +# TODO + %!shared scores, nParents, expectation %! scores = rand (20, 1); %! nParents = 32; Modified: trunk/octave-forge/main/ga/inst/gacreationuniform.m =================================================================== --- trunk/octave-forge/main/ga/inst/gacreationuniform.m 2012-03-21 22:32:29 UTC (rev 9999) +++ trunk/octave-forge/main/ga/inst/gacreationuniform.m 2012-03-22 01:32:26 UTC (rev 10000) @@ -50,4 +50,16 @@ ((ones (options.PopulationSize, 1) * (UB - LB)) .* \ rand (options.PopulationSize, GenomeLength)) + \ (ones (options.PopulationSize, 1) * LB); -endfunction \ No newline at end of file +endfunction + + +## number of input arguments +# TODO + +## number of output arguments +# TODO + +## type of arguments +# TODO + +# TODO Modified: trunk/octave-forge/main/ga/inst/mutationgaussian.m =================================================================== --- trunk/octave-forge/main/ga/inst/mutationgaussian.m 2012-03-21 22:32:29 UTC (rev 9999) +++ trunk/octave-forge/main/ga/inst/mutationgaussian.m 2012-03-22 01:32:26 UTC (rev 10000) @@ -45,4 +45,16 @@ mutationChildren(1:nc_parents, 1:nvars) = \ thisPopulation(parents(1, 1:nc_parents), 1:nvars) + \ expanded_current_std .* randn (nc_parents, nvars); -endfunction \ No newline at end of file +endfunction + + +## number of input arguments +# TODO + +## number of output arguments +# TODO + +## type of arguments +# TODO + +# TODO Modified: trunk/octave-forge/main/ga/inst/selectionstochunif.m =================================================================== --- trunk/octave-forge/main/ga/inst/selectionstochunif.m 2012-03-21 22:32:29 UTC (rev 9999) +++ trunk/octave-forge/main/ga/inst/selectionstochunif.m 2012-03-22 01:32:26 UTC (rev 10000) @@ -31,4 +31,16 @@ endwhile parents(1, index_steps) = index_line; endfor -endfunction \ No newline at end of file +endfunction + + +## number of input arguments +# TODO + +## number of output arguments +# TODO + +## type of arguments +# TODO + +# TODO This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-03-21 22:32:35
|
Revision: 9999 http://octave.svn.sourceforge.net/octave/?rev=9999&view=rev Author: prnienhuis Date: 2012-03-21 22:32:29 +0000 (Wed, 21 Mar 2012) Log Message: ----------- Updated to expected release data Modified Paths: -------------- trunk/octave-forge/main/io/DESCRIPTION Modified: trunk/octave-forge/main/io/DESCRIPTION =================================================================== --- trunk/octave-forge/main/io/DESCRIPTION 2012-03-21 22:31:50 UTC (rev 9998) +++ trunk/octave-forge/main/io/DESCRIPTION 2012-03-21 22:32:29 UTC (rev 9999) @@ -1,6 +1,6 @@ Name: io Version: 1.0.18 -Date: 2012-03-18 +Date: 2012-03-22 Author: various authors Maintainer: Philip Nienhuis <prn...@us...> Title: Input/Output This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |