MaplePrimes - Toolbox Posts and Questions
http://www.mapleprimes.com/tags/Toolbox
en-us2014 Maplesoft, A Division of Waterloo Maple Inc.Maplesoft Document SystemMon, 28 Jul 2014 06:17:16 GMTMon, 28 Jul 2014 06:17:16 GMTToolbox Questions and Posts on MaplePrimeshttp://www.mapleprimes.com/images/mapleprimeswhite.jpgMaplePrimes - Toolbox Posts and Questions
http://www.mapleprimes.com/tags/Toolbox
Restart Maple memory except variable?
http://www.mapleprimes.com/questions/201745-Restart-Maple-Memory-Except-Variable?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>Hi Mapleprimers,</p>
<p>I was wondering if there way a way to use restart(); and clear Maple's memory, but protect the memory in a certain variable? I would like to return the memory to the operating system, but keep a symholic function in memory.</p>
<p>Alternatively, is there a way to save a symbolic function to a file, then reload it at a seperate time?</p>
<p> </p><p>Hi Mapleprimers,</p>
<p>I was wondering if there way a way to use restart(); and clear Maple's memory, but protect the memory in a certain variable? I would like to return the memory to the operating system, but keep a symholic function in memory.</p>
<p>Alternatively, is there a way to save a symbolic function to a file, then reload it at a seperate time?</p>
<p> </p>201745Fri, 06 Jun 2014 15:01:35 Zteh_allchemistteh_allchemistMaple Toolbox for Matlab: Segmentation Violation?
http://www.mapleprimes.com/questions/201736-Maple-Toolbox-For-Matlab--Segmentation?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>Hi MaplePrime-ers,</p>
<p>I'm using Maple17 in Matlab 2012b to evaluate a symbolic function over a grid of values. The number of values is generally ~500k, and therefore I have a loop that dumps the solutions into MATLAB where the values are parsed and stored more efficiently.</p>
<p>I put this proceess in an optimization routine, and I keep getting crashes. The crashes are NOT repeatable. They generally happen after 4-10 times the routine has been called. </p>
<p>This is one of the stack dumps. Anybody have any ideas? I talked to MATLAB support, but they weren't very useful (they started pointing fingers).</p>
<blockquote>
<p><br>------------------------------------------------------------------------<br> Segmentation violation detected at Wed Jun 4 17:38:11 2014<br>------------------------------------------------------------------------</p>
<p>Configuration:<br> Crash Decoding : Disabled<br> Current Visual : 0x24 (class 4, depth 24)<br> Default Encoding: UTF-8<br> GNU C Library : 2.15 stable<br> MATLAB Root : /opt/Matlab/R2012b<br> MATLAB Version : 8.0.0.783 (R2012b)<br> Operating System: Linux 3.2.0-37-generic #58-Ubuntu SMP Thu Jan 24 15:28:10 UTC 2013 x86_64<br> Processor ID : x86 Family 6 Model 23 Stepping 6, GenuineIntel<br> Virtual Machine : Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode<br> Window System : The XFree86 Project, Inc (40300000), display wildnode0:15.0</p>
<p>Fault Count: 1</p>
<p><br>Abnormal termination:<br>Segmentation violation</p>
<p>Register State (from fault):<br> RAX = 00007f3bcc0a80c0 RBX = 00007f3b97fe6000<br> RCX = 0000000000000000 RDX = 00007f3bcc0a84a0<br> RSP = 00007f3b8cb29d60 RBP = 0000000000000003<br> RSI = 5851f42d4c957f2d RDI = 00007f3bde026360</p>
<p>R8 = 65a1566174cc9e28 R9 = 0000000000000002<br> R10 = 00007f3b8cb29d90 R11 = 0000000000002e88<br> R12 = 0000000000000001 R13 = 00007f3b8cb29df0<br> R14 = 0000000000000000 R15 = 0000000000000003</p>
<p>RIP = 00007f3b977d0604 EFL = 0000000000010283</p>
<p>CS = 0033 FS = 0000 GS = 0000</p>
<p>Stack Trace (from fault):<br>[ 0] 0x00007f3c962b01de /opt/Matlab/R2012b/bin/glnxa64/libmwfl.so+00516574 _ZN2fl4diag15stacktrace_base7captureERKNS0_14thread_contextEm+000158<br>[ 1] 0x00007f3c962b14b2 /opt/Matlab/R2012b/bin/glnxa64/libmwfl.so+00521394<br>[ 2] 0x00007f3c962b2ffe /opt/Matlab/R2012b/bin/glnxa64/libmwfl.so+00528382 _ZN2fl4diag13terminate_logEPKcRKNS0_14thread_contextE+000174<br>[ 3] 0x00007f3c9559f093 /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00557203 _ZN2fl4diag13terminate_logEPKcPK8ucontext+000067<br>[ 4] 0x00007f3c9559bb9d /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00543645<br>[ 5] 0x00007f3c9559d835 /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00550965<br>[ 6] 0x00007f3c9559da55 /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00551509<br>[ 7] 0x00007f3c9559e0fe /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00553214<br>[ 8] 0x00007f3c9559e295 /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00553621<br>[ 9] 0x00007f3c93a86cb0 /lib/x86_64-linux-gnu/libpthread.so.0+00064688<br>[ 10] 0x00007f3b977d0604 /opt/maple17/bin.X86_64_LINUX/libmaple.so+01824260<br>[ 11] 0x00007f3b977cfc48 /opt/maple17/bin.X86_64_LINUX/libmaple.so+01821768<br>[ 12] 0x00007f3b977d2f88 /opt/maple17/bin.X86_64_LINUX/libmaple.so+01834888<br>[ 13] 0x00007f3b9763d63f /opt/maple17/bin.X86_64_LINUX/libmaple.so+00173631<br>[ 14] 0x00007f3c93a7ee9a /lib/x86_64-linux-gnu/libpthread.so.0+00032410<br>[ 15] 0x00007f3c937ab3fd /lib/x86_64-linux-gnu/libc.so.6+01000445 clone+000109</p>
<p><br>If this problem is reproducible, please submit a Service Request via:<br> http://www.mathworks.com/support/contact_us/</p>
<p>A technical support engineer might contact you with further information.</p>
<p>Thank you for your help.</p>
</blockquote><p>Hi MaplePrime-ers,</p>
<p>I'm using Maple17 in Matlab 2012b to evaluate a symbolic function over a grid of values. The number of values is generally ~500k, and therefore I have a loop that dumps the solutions into MATLAB where the values are parsed and stored more efficiently.</p>
<p>I put this proceess in an optimization routine, and I keep getting crashes. The crashes are NOT repeatable. They generally happen after 4-10 times the routine has been called. </p>
<p>This is one of the stack dumps. Anybody have any ideas? I talked to MATLAB support, but they weren't very useful (they started pointing fingers).</p>
<blockquote>
<p><br />------------------------------------------------------------------------<br /> Segmentation violation detected at Wed Jun 4 17:38:11 2014<br />------------------------------------------------------------------------</p>
<p>Configuration:<br /> Crash Decoding : Disabled<br /> Current Visual : 0x24 (class 4, depth 24)<br /> Default Encoding: UTF-8<br /> GNU C Library : 2.15 stable<br /> MATLAB Root : /opt/Matlab/R2012b<br /> MATLAB Version : 8.0.0.783 (R2012b)<br /> Operating System: Linux 3.2.0-37-generic #58-Ubuntu SMP Thu Jan 24 15:28:10 UTC 2013 x86_64<br /> Processor ID : x86 Family 6 Model 23 Stepping 6, GenuineIntel<br /> Virtual Machine : Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode<br /> Window System : The XFree86 Project, Inc (40300000), display wildnode0:15.0</p>
<p>Fault Count: 1</p>
<p><br />Abnormal termination:<br />Segmentation violation</p>
<p>Register State (from fault):<br /> RAX = 00007f3bcc0a80c0 RBX = 00007f3b97fe6000<br /> RCX = 0000000000000000 RDX = 00007f3bcc0a84a0<br /> RSP = 00007f3b8cb29d60 RBP = 0000000000000003<br /> RSI = 5851f42d4c957f2d RDI = 00007f3bde026360</p>
<p>R8 = 65a1566174cc9e28 R9 = 0000000000000002<br /> R10 = 00007f3b8cb29d90 R11 = 0000000000002e88<br /> R12 = 0000000000000001 R13 = 00007f3b8cb29df0<br /> R14 = 0000000000000000 R15 = 0000000000000003</p>
<p>RIP = 00007f3b977d0604 EFL = 0000000000010283</p>
<p>CS = 0033 FS = 0000 GS = 0000</p>
<p>Stack Trace (from fault):<br />[ 0] 0x00007f3c962b01de /opt/Matlab/R2012b/bin/glnxa64/libmwfl.so+00516574 _ZN2fl4diag15stacktrace_base7captureERKNS0_14thread_contextEm+000158<br />[ 1] 0x00007f3c962b14b2 /opt/Matlab/R2012b/bin/glnxa64/libmwfl.so+00521394<br />[ 2] 0x00007f3c962b2ffe /opt/Matlab/R2012b/bin/glnxa64/libmwfl.so+00528382 _ZN2fl4diag13terminate_logEPKcRKNS0_14thread_contextE+000174<br />[ 3] 0x00007f3c9559f093 /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00557203 _ZN2fl4diag13terminate_logEPKcPK8ucontext+000067<br />[ 4] 0x00007f3c9559bb9d /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00543645<br />[ 5] 0x00007f3c9559d835 /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00550965<br />[ 6] 0x00007f3c9559da55 /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00551509<br />[ 7] 0x00007f3c9559e0fe /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00553214<br />[ 8] 0x00007f3c9559e295 /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00553621<br />[ 9] 0x00007f3c93a86cb0 /lib/x86_64-linux-gnu/libpthread.so.0+00064688<br />[ 10] 0x00007f3b977d0604 /opt/maple17/bin.X86_64_LINUX/libmaple.so+01824260<br />[ 11] 0x00007f3b977cfc48 /opt/maple17/bin.X86_64_LINUX/libmaple.so+01821768<br />[ 12] 0x00007f3b977d2f88 /opt/maple17/bin.X86_64_LINUX/libmaple.so+01834888<br />[ 13] 0x00007f3b9763d63f /opt/maple17/bin.X86_64_LINUX/libmaple.so+00173631<br />[ 14] 0x00007f3c93a7ee9a /lib/x86_64-linux-gnu/libpthread.so.0+00032410<br />[ 15] 0x00007f3c937ab3fd /lib/x86_64-linux-gnu/libc.so.6+01000445 clone+000109</p>
<p><br />If this problem is reproducible, please submit a Service Request via:<br /> http://www.mathworks.com/support/contact_us/</p>
<p>A technical support engineer might contact you with further information.</p>
<p>Thank you for your help.</p>
</blockquote>201736Wed, 04 Jun 2014 23:01:24 Zteh_allchemistteh_allchemistMay Live Webinars
http://www.mapleprimes.com/posts/200267-May-Live-Webinars?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>Maplesoft regularly hosts live webinars on a variety of topics. Below you will find details on some upcoming webinars we think may be of interest to the MaplePrimes community. For the complete list of upcoming webinars, <a href="http://www.maplesoft.com/webinars/live/index.aspx">visit our website</a>.</p>
<p><span> </span></p>
<p><strong><span>Hollywood Math (with more new examples!)</span></strong></p>
<p><span>Over its storied and intriguing history, Hollywood has entertained us with many mathematical moments in film. John Nash in “A Beautiful Mind,” the brilliant janitor in “Good Will Hunting,” the number theory genius in “Pi,” and even Abbott and Costello are just a few of the Hollywood “mathematicians” that come to mind.</span></p>
<p><span>Although the widespread presentation of mathematics on the silver screen is not always entirely accurate, it does serve as a great introduction to the study of mathematics in general. During this webinar Maplesoft will present a number of examples of mathematics in film. See relevant, exciting examples that you can use to engage your students.</span><span>At the end of the webinar you’ll be given an opportunity to download an application containing all of the Hollywood examples that we demonstrate.</span></p>
<p><span>To join us for the live presentation,<span class="apple-converted-space"> </span><a href="http://www.maplesoft.com/webinars/live/register.aspx?id=699"><span>please click here to register</span></a>.</span></p>
<p> </p>
<p><strong><span>Applications of Symbolic Computation in Control Design</span></strong></p>
<p><span>You may already use Maple and/or MapleSim within your organization to solve various problems, but did you know that they have capabilities for control design as well? In one of our upcoming featured webinars for this month, we will explore the <a href="http://www.maplesoft.com/products/toolboxes/control_design/?p=TC-4191">Control Design toolbox</a> including the ability to extract symbolic equations of plant models, perform symbolic linearization, design symbolic controllers, and generate very fast code for HIL testing.</span></p>
<p><span>The following examples will be demonstrated:</span></p>
<p><span>• PID Control</span></p>
<p><span>• LQR, Kalman filter design </span></p>
<p><span>• Gain scheduling</span></p>
<p><span>• Feedback linearization </span></p>
<p><span>To join us for the live presentation,<span class="apple-converted-space"> </span><a href="http://www.maplesoft.com/webinars/live/register.aspx?id=712&p=tc-4191"><span>please click here to register</span></a>.</span></p><p>Maplesoft regularly hosts live webinars on a variety of topics. Below you will find details on some upcoming webinars we think may be of interest to the MaplePrimes community. For the complete list of upcoming webinars, <a href="http://www.maplesoft.com/webinars/live/index.aspx">visit our website</a>.</p>
<p><span lang="EN-US"> </span></p>
<p><strong><span lang="EN-US">Hollywood Math (with more new examples!)</span></strong></p>
<p><span lang="EN-US">Over its storied and intriguing history, Hollywood has entertained us with many mathematical moments in film. John Nash in “A Beautiful Mind,” the brilliant janitor in “Good Will Hunting,” the number theory genius in “Pi,” and even Abbott and Costello are just a few of the Hollywood “mathematicians” that come to mind.</span></p>
<p><span lang="EN-US">Although the widespread presentation of mathematics on the silver screen is not always entirely accurate, it does serve as a great introduction to the study of mathematics in general. During this webinar Maplesoft will present a number of examples of mathematics in film. See relevant, exciting examples that you can use to engage your students.</span><span lang="EN-US">At the end of the webinar you’ll be given an opportunity to download an application containing all of the Hollywood examples that we demonstrate.</span></p>
<p><span>To join us for the live presentation,<span class="apple-converted-space"> </span><a href="http://www.maplesoft.com/webinars/live/register.aspx?id=699"><span>please click here to register</span></a>.</span></p>
<p> </p>
<p><strong><span lang="EN-US">Applications of Symbolic Computation in Control Design</span></strong></p>
<p><span>You may already use Maple and/or MapleSim within your organization to solve various problems, but did you know that they have capabilities for control design as well? In one of our upcoming featured webinars for this month, we will explore the <a href="http://www.maplesoft.com/products/toolboxes/control_design/?p=TC-4191">Control Design toolbox</a> including the ability to extract symbolic equations of plant models, perform symbolic linearization, design symbolic controllers, and generate very fast code for HIL testing.</span></p>
<p><span>The following examples will be demonstrated:</span></p>
<p><span>• PID Control</span></p>
<p><span>• LQR, Kalman filter design </span></p>
<p><span>• Gain scheduling</span></p>
<p><span>• Feedback linearization </span></p>
<p><span>To join us for the live presentation,<span class="apple-converted-space"> </span><a href="http://www.maplesoft.com/webinars/live/register.aspx?id=712&p=tc-4191"><span>please click here to register</span></a>.</span></p>200267Fri, 09 May 2014 17:05:39 ZkkoserskikkoserskiSystem of equations solve, solutions may be lost. Any suggestions?
http://www.mapleprimes.com/questions/201179-System-Of-Equations-Solve-Solutions?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>Hi MaplePrime-ers!</p>
<p>I've been using the Maple(17) toolbox in Matlab(2012b) to quickly enumerate systems of equations by: (i) solving them symbolically, (ii) using unapply to make them functions, (iii) then supplying the points (driver equations) to get the system solution. Speed is a must, because there may be 3 million+ systems to solve. Symbolics is also very important because I am evaluating topology, so the structure of the equations may change, and therefore a functional approach will not work.</p>
<p>I have had success (seen in the first code snippet). I would like similiar behaviour in the second code snippet, but sometimes I get '<strong>solutions may be lost'</strong> as an error message, or '<strong>Error, (in unapply) variables must be unique and of type name'</strong></p>
<p>The system of equations include: Linear equations, 5th order polynomials, absolute functions, and pieceiwse functions.</p>
<p>Here is code with a topology that solves:</p>
<blockquote>
<p>#Interconnection Equations<br>eq2[1] := FD_T + EM2_T = 0;<br>eq2[2] := ICE_T + GEN_T = 0;<br>eq2[3] := EM2_A + GEN_A + BAT_A = 0;<br>eq2[4] := -FD_W + EM2_W = 0;<br>eq2[5] := -ICE_W + GEN_W = 0;<br>eq2[6] := -EM2_V + GEN_V = 0;<br>eq2[7] := -EM2_V + BAT_V = 0;</p>
<p>#ICE<br>eq_c[1] := ICE_mdot_g=((671.5) + (-21.94)*ICE_T + (0.1942)*ICE_W + (0.5113)*ICE_T^2 + (-0.01271)*ICE_T*ICE_W + ( -0.0008761)*ICE_W^2 + (-0.006071)*ICE_T^3 + (9.867e-07)*ICE_T^2*ICE_W + (5.616e-05)*ICE_T*ICE_W^2 + (1.588e-06)*ICE_W^3 + (3.61e-05)*ICE_T^4 + (8.98e-07)*ICE_T^3*ICE_W + (-2.814e-07)*ICE_T^2*ICE_W^2 + (-8.121e-08)*ICE_T*ICE_W^3 + ( -8.494e-08 )*ICE_T^5 + (-2.444e-09)*ICE_T^4*ICE_W + (-9.311e-10)*ICE_T^3*ICE_W^2 + ( 5.835e-10)*ICE_T^2*ICE_W^3 ) *1/3600/1000 * ICE_T * ICE_W;</p>
<p>#BAT<br>eq_c[2] := BAT = 271;</p>
<p>#EM2<br>EM2_ReqPow_eq := (-148.3) + (4.267)*abs(EM2_W) + (12.77)*abs(EM2_T) + (-0.0364)*abs(EM2_W)^2 + ( 1.16)*abs(EM2_W)*abs(EM2_T) + (-0.258)*abs(EM2_T)^2 + ( 0.0001181)*abs(EM2_W)^3 + (-0.0005994)*abs(EM2_W)^2*abs(EM2_T) + ( 0.0001171)*abs(EM2_W)*abs(EM2_T)^2 + (0.001739 )*abs(EM2_T)^3 + (-1.245e-07 )*abs(EM2_W)^4 + ( 1.2e-06)*abs(EM2_W)^3*abs(EM2_T) + ( -1.584e-06)*abs(EM2_W)^2*abs(EM2_T)^2 + ( 4.383e-07)*abs(EM2_W)*abs(EM2_T)^3 + (-2.947e-06)*abs(EM2_T)^4;<br>eq_c[3] := EM2_P = piecewise( EM2_T = 0, 0, EM2_W = 0, 0, EM2_W*EM2_T < 0,-1 * EM2_ReqPow_eq, EM2_ReqPow_eq);<br>eq_c[4] := EM2_A = EM2_P/EM2_V;</p>
<p>#GEN<br>GEN_ReqPow_eq:= (-5.28e-12) + ( 3.849e-14)*abs(GEN_W) + (-71.9)*abs(GEN_T) + (-1.168e-16)*abs(GEN_W)^2 +(1.296)*abs(GEN_W)*abs(GEN_T) + (2.489)*abs(GEN_T)^2 + (1.451e-19)*abs(GEN_W)^3 + (0.0001326)*abs(GEN_W)^2*abs(GEN_T) + (-0.008141)*abs(GEN_W)*abs(GEN_T)^2 + (-0.004539)*abs(GEN_T)^3 +(-6.325e-23)*abs(GEN_W)^4 + (-2.091e-07)*abs(GEN_W)^3*abs(GEN_T) + ( 3.455e-06)*abs(GEN_W)^2*abs(GEN_T)^2 + ( 2.499e-05)*abs(GEN_W)*abs(GEN_T)^3 + (-5.321e-05)*abs(GEN_T)^4;<br>eq_c[5] := GEN_P = piecewise( GEN_T = 0, 0, GEN_W = 0, 0, GEN_W*GEN_T < 0,-1 * GEN_ReqPow_eq, GEN_ReqPow_eq);<br>eq_c[6] := GEN_A = GEN_P/GEN_V;</p>
<p>#ASSUMPTIONS<br>assume(BAT_V::nonnegative);<br>assume(FD_W::nonnegative);<br><br>#FINAL EQUATIONS</p>
<p>sys_eqs2 := convert(eq2,set) union {eq_c[1],eq_c[2],eq_c[3],eq_c[4],eq_c[5],eq_c[6]};</p>
<p>#Selecting which variables to solve for:</p>
<p>drivers2:= { ICE_T,ICE_W,FD_T,FD_W};<br>symvarnames2:=select(type,indets(convert(sys_eqs2,list)),name);<br>notdrivers2:=symvarnames2 minus drivers2;<br><br><br></p>
<p>#Symbolic solve</p>
<p>sol2:=solve(sys_eqs2,notdrivers2) assuming real:<br>symb_sol2:=unapply(sol2,convert(drivers2,list)):<br><br><br>#Enumerate (there will generally be about 40, not 6)</p>
<p>count := 0;<br>for i1 from 1 to 40 do<br> for i2 from 1 to 40 do<br> for i3 from 1 to 40 do<br> for i4 from 1 to 40 do<br> count := count + 1;<br> solsol2(count) := symb_sol2(i1,i2,i3,i4);<br> od; <br> od;<br> od;<br>od;<br>count;</p>
</blockquote>
<p><br><br></p>
<p>This works great! I would like simliar output in my second code snippet, but this time with more inputs to symb_sol. However, if I try and change the interconnection equations a little, and add a piecewise function, and another driver... <strong>(differences in bold)</strong></p>
<blockquote>
<p>#Interconnection Equations<br>eq1[1] := FD_T+EM2_T = 0;<br><strong>eq1[2] := ICE_T+GBb_T = 0;</strong><br><strong>eq1[3] := GEN_T+GBa_T = 0;</strong><br>eq1[4] := EM2_A+GEN_A+BAT_A = 0;<br>eq1[5] := -FD_W+EM2_W = 0;<br><strong>eq1[6] := -GEN_W+GBa_W = 0;</strong><br><strong>eq1[7] := -ICE_W+GBb_W = 0;</strong><br>eq1[8] := -EM2_V+GEN_V = 0;<br>eq1[9] := -EM2_V+BAT_V = 0;</p>
<p>#ICE<br>eq_c[1] := ICE_mdot_g=((671.5) + (-21.94)*ICE_T + (0.1942)*ICE_W + (0.5113)*ICE_T^2 + (-0.01271)*ICE_T*ICE_W + ( -0.0008761)*ICE_W^2 + (-0.006071)*ICE_T^3 + (9.867e-07)*ICE_T^2*ICE_W + (5.616e-05)*ICE_T*ICE_W^2 + (1.588e-06)*ICE_W^3 + (3.61e-05)*ICE_T^4 + (8.98e-07)*ICE_T^3*ICE_W + (-2.814e-07)*ICE_T^2*ICE_W^2 + (-8.121e-08)*ICE_T*ICE_W^3 + ( -8.494e-08 )*ICE_T^5 + (-2.444e-09)*ICE_T^4*ICE_W + (-9.311e-10)*ICE_T^3*ICE_W^2 + ( 5.835e-10)*ICE_T^2*ICE_W^3 ) *1/3600/1000 * ICE_T * ICE_W;</p>
<p>#BAT<br>eq_c[2] := BAT = 271;</p>
<p>#EM2<br>EM2_ReqPow_eq := (-148.3) + (4.267)*abs(EM2_W) + (12.77)*abs(EM2_T) + (-0.0364)*abs(EM2_W)^2 + ( 1.16)*abs(EM2_W)*abs(EM2_T) + (-0.258)*abs(EM2_T)^2 + ( 0.0001181)*abs(EM2_W)^3 + (-0.0005994)*abs(EM2_W)^2*abs(EM2_T) + ( 0.0001171)*abs(EM2_W)*abs(EM2_T)^2 + (0.001739 )*abs(EM2_T)^3 + (-1.245e-07 )*abs(EM2_W)^4 + ( 1.2e-06)*abs(EM2_W)^3*abs(EM2_T) + ( -1.584e-06)*abs(EM2_W)^2*abs(EM2_T)^2 + ( 4.383e-07)*abs(EM2_W)*abs(EM2_T)^3 + (-2.947e-06)*abs(EM2_T)^4;<br>eq_c[3] := EM2_P = piecewise( EM2_T = 0, 0, EM2_W = 0, 0, EM2_W*EM2_T < 0,-1 * EM2_ReqPow_eq, EM2_ReqPow_eq);<br>eq_c[4] := EM2_A = EM2_P/EM2_V;</p>
<p>#GEN<br>GEN_ReqPow_eq:= (-5.28e-12) + ( 3.849e-14)*abs(GEN_W) + (-71.9)*abs(GEN_T) + (-1.168e-16)*abs(GEN_W)^2 +(1.296)*abs(GEN_W)*abs(GEN_T) + (2.489)*abs(GEN_T)^2 + (1.451e-19)*abs(GEN_W)^3 + (0.0001326)*abs(GEN_W)^2*abs(GEN_T) + (-0.008141)*abs(GEN_W)*abs(GEN_T)^2 + (-0.004539)*abs(GEN_T)^3 +(-6.325e-23)*abs(GEN_W)^4 + (-2.091e-07)*abs(GEN_W)^3*abs(GEN_T) + ( 3.455e-06)*abs(GEN_W)^2*abs(GEN_T)^2 + ( 2.499e-05)*abs(GEN_W)*abs(GEN_T)^3 + (-5.321e-05)*abs(GEN_T)^4;<br>eq_c[5] := GEN_P = piecewise( GEN_T = 0, 0, GEN_W = 0, 0, GEN_W*GEN_T < 0,-1 * GEN_ReqPow_eq, GEN_ReqPow_eq);<br>eq_c[6] := GEN_A = GEN_P/GEN_V;</p>
<p><strong>#GB</strong><br><strong>FiveSpeedGearbox_R := proc(ig) </strong><br><strong>local i ,eq;</strong><br><strong>i[1]:=3.32;</strong><br><strong>i[2]:=2;</strong><br><strong>i[3]:=1.36;</strong><br><strong>i[4]:=1.01;</strong><br><strong>i[5]:=0.82;</strong><br><strong>eq:= piecewise(ig=1,i[1],ig=2, i[2],ig=3,i[3],ig=4,i[4],ig=5,i[5],1); </strong><br><strong>return eq(ig);</strong><br><strong>end proc;</strong></p>
<p><br><strong>eq_c[7] := GBb_T = -1/GB_R * GBa_T;</strong><br><strong>eq_c[8] := GBb_W = GB_R * GBa_W;</strong><br><strong>eq_c[9] := GB_R = FiveSpeedGearbox_R(ig);</strong></p>
<p> </p>
<p>#System Equations<br>sys_eqs := convert(eq1,set) union convert(eq_c,set);</p>
<p><strong> </strong></p>
<p> #Solve for variables<br>symvarnames:=select(type,indets(convert(sys_eqs,list)),name);<br><strong>drivers:= {ig, ICE_T,ICE_W,FD_T,FD_W};</strong><br>not_drivers := symvarnames minus drivers;<br><br>#Assumptinons</p>
<p>assume(BAT_V::nonnegative);<br>assume(FD_W::nonnegative);<br><br></p>
<p>sol:=(solve(sys_eqs,not_drivers) assuming real);</p>
<p>symb_sol:=unapply(sol,convert(drivers,list)): ---> <strong>Error, (in unapply) variables must be unique and of type name</strong></p>
<p><strong>Subsequent parts don't work...</strong></p>
<p><strong>count := 0;</strong><br><strong>for i1 from 1 to 40 do</strong><br><strong> for i2 from 1 to 40 do</strong><br><strong> for i3 from 1 to 40 do</strong><br><strong> for i4 from 1 to 40 do</strong><br><strong> for i5 from 1 to 40 do</strong><br><strong> count := count + 1;</strong><br><strong> solsol2(count) := symb_sol2(i1,i2,i3,i4,5);</strong><br><strong> od;</strong><br><strong> od; </strong><br><strong> od;</strong><br><strong> od;</strong><br><strong>od;</strong><br><strong>count;</strong></p>
</blockquote>
<p>While running the last line sol:, 1 of 2 things will happen, depending on the solver. Maple17 will take a long time (30+ minutes) to solve, then report nothing, or sol will solve, but will report "some solutions have been lost".</p>
<p>Afterwards, evaluating symb_sol(0,0,0,0,0) will return a viable solution (real values for each of the variables). Whereas evaluating symb_sol(0,X,0,0,0), where X <> 0, will return and empty list [].</p>
<p>Does anyone know how to (i) speed up the symbolic solve time? (ii) Return ALL of the solutions?</p>
<p> </p>
<p>Thanks in advance for reading this. I've really no idea why this isn't working. I've also attached two worksheets with the code: <a href="/view.aspx?sf=201179_question/noGB.mw">noGB.mw</a> <a href="/view.aspx?sf=201179_question/withGB.mw">withGB.mw</a></p>
<p> Adam</p><p>Hi MaplePrime-ers!</p>
<p>I've been using the Maple(17) toolbox in Matlab(2012b) to quickly enumerate systems of equations by: (i) solving them symbolically, (ii) using unapply to make them functions, (iii) then supplying the points (driver equations) to get the system solution. Speed is a must, because there may be 3 million+ systems to solve. Symbolics is also very important because I am evaluating topology, so the structure of the equations may change, and therefore a functional approach will not work.</p>
<p>I have had success (seen in the first code snippet). I would like similiar behaviour in the second code snippet, but sometimes I get '<strong>solutions may be lost'</strong> as an error message, or '<strong>Error, (in unapply) variables must be unique and of type name'</strong></p>
<p>The system of equations include: Linear equations, 5th order polynomials, absolute functions, and pieceiwse functions.</p>
<p>Here is code with a topology that solves:</p>
<blockquote>
<p>#Interconnection Equations<br>eq2[1] := FD_T + EM2_T = 0;<br>eq2[2] := ICE_T + GEN_T = 0;<br>eq2[3] := EM2_A + GEN_A + BAT_A = 0;<br>eq2[4] := -FD_W + EM2_W = 0;<br>eq2[5] := -ICE_W + GEN_W = 0;<br>eq2[6] := -EM2_V + GEN_V = 0;<br>eq2[7] := -EM2_V + BAT_V = 0;</p>
<p>#ICE<br>eq_c[1] := ICE_mdot_g=((671.5) + (-21.94)*ICE_T + (0.1942)*ICE_W + (0.5113)*ICE_T^2 + (-0.01271)*ICE_T*ICE_W + ( -0.0008761)*ICE_W^2 + (-0.006071)*ICE_T^3 + (9.867e-07)*ICE_T^2*ICE_W + (5.616e-05)*ICE_T*ICE_W^2 + (1.588e-06)*ICE_W^3 + (3.61e-05)*ICE_T^4 + (8.98e-07)*ICE_T^3*ICE_W + (-2.814e-07)*ICE_T^2*ICE_W^2 + (-8.121e-08)*ICE_T*ICE_W^3 + ( -8.494e-08 )*ICE_T^5 + (-2.444e-09)*ICE_T^4*ICE_W + (-9.311e-10)*ICE_T^3*ICE_W^2 + ( 5.835e-10)*ICE_T^2*ICE_W^3 ) *1/3600/1000 * ICE_T * ICE_W;</p>
<p>#BAT<br>eq_c[2] := BAT = 271;</p>
<p>#EM2<br>EM2_ReqPow_eq := (-148.3) + (4.267)*abs(EM2_W) + (12.77)*abs(EM2_T) + (-0.0364)*abs(EM2_W)^2 + ( 1.16)*abs(EM2_W)*abs(EM2_T) + (-0.258)*abs(EM2_T)^2 + ( 0.0001181)*abs(EM2_W)^3 + (-0.0005994)*abs(EM2_W)^2*abs(EM2_T) + ( 0.0001171)*abs(EM2_W)*abs(EM2_T)^2 + (0.001739 )*abs(EM2_T)^3 + (-1.245e-07 )*abs(EM2_W)^4 + ( 1.2e-06)*abs(EM2_W)^3*abs(EM2_T) + ( -1.584e-06)*abs(EM2_W)^2*abs(EM2_T)^2 + ( 4.383e-07)*abs(EM2_W)*abs(EM2_T)^3 + (-2.947e-06)*abs(EM2_T)^4;<br>eq_c[3] := EM2_P = piecewise( EM2_T = 0, 0, EM2_W = 0, 0, EM2_W*EM2_T < 0,-1 * EM2_ReqPow_eq, EM2_ReqPow_eq);<br>eq_c[4] := EM2_A = EM2_P/EM2_V;</p>
<p>#GEN<br>GEN_ReqPow_eq:= (-5.28e-12) + ( 3.849e-14)*abs(GEN_W) + (-71.9)*abs(GEN_T) + (-1.168e-16)*abs(GEN_W)^2 +(1.296)*abs(GEN_W)*abs(GEN_T) + (2.489)*abs(GEN_T)^2 + (1.451e-19)*abs(GEN_W)^3 + (0.0001326)*abs(GEN_W)^2*abs(GEN_T) + (-0.008141)*abs(GEN_W)*abs(GEN_T)^2 + (-0.004539)*abs(GEN_T)^3 +(-6.325e-23)*abs(GEN_W)^4 + (-2.091e-07)*abs(GEN_W)^3*abs(GEN_T) + ( 3.455e-06)*abs(GEN_W)^2*abs(GEN_T)^2 + ( 2.499e-05)*abs(GEN_W)*abs(GEN_T)^3 + (-5.321e-05)*abs(GEN_T)^4;<br>eq_c[5] := GEN_P = piecewise( GEN_T = 0, 0, GEN_W = 0, 0, GEN_W*GEN_T < 0,-1 * GEN_ReqPow_eq, GEN_ReqPow_eq);<br>eq_c[6] := GEN_A = GEN_P/GEN_V;</p>
<p>#ASSUMPTIONS<br>assume(BAT_V::nonnegative);<br>assume(FD_W::nonnegative);<br><br>#FINAL EQUATIONS</p>
<p>sys_eqs2 := convert(eq2,set) union {eq_c[1],eq_c[2],eq_c[3],eq_c[4],eq_c[5],eq_c[6]};</p>
<p>#Selecting which variables to solve for:</p>
<p>drivers2:= { ICE_T,ICE_W,FD_T,FD_W};<br>symvarnames2:=select(type,indets(convert(sys_eqs2,list)),name);<br>notdrivers2:=symvarnames2 minus drivers2;<br><br><br></p>
<p>#Symbolic solve</p>
<p>sol2:=solve(sys_eqs2,notdrivers2) assuming real:<br>symb_sol2:=unapply(sol2,convert(drivers2,list)):<br><br><br>#Enumerate (there will generally be about 40, not 6)</p>
<p>count := 0;<br>for i1 from 1 to 40 do<br> for i2 from 1 to 40 do<br> for i3 from 1 to 40 do<br> for i4 from 1 to 40 do<br> count := count + 1;<br> solsol2(count) := symb_sol2(i1,i2,i3,i4);<br> od; <br> od;<br> od;<br>od;<br>count;</p>
</blockquote>
<p><br><br></p>
<p>This works great! I would like simliar output in my second code snippet, but this time with more inputs to symb_sol. However, if I try and change the interconnection equations a little, and add a piecewise function, and another driver... <strong>(differences in bold)</strong></p>
<blockquote>
<p>#Interconnection Equations<br>eq1[1] := FD_T+EM2_T = 0;<br><strong>eq1[2] := ICE_T+GBb_T = 0;</strong><br><strong>eq1[3] := GEN_T+GBa_T = 0;</strong><br>eq1[4] := EM2_A+GEN_A+BAT_A = 0;<br>eq1[5] := -FD_W+EM2_W = 0;<br><strong>eq1[6] := -GEN_W+GBa_W = 0;</strong><br><strong>eq1[7] := -ICE_W+GBb_W = 0;</strong><br>eq1[8] := -EM2_V+GEN_V = 0;<br>eq1[9] := -EM2_V+BAT_V = 0;</p>
<p>#ICE<br>eq_c[1] := ICE_mdot_g=((671.5) + (-21.94)*ICE_T + (0.1942)*ICE_W + (0.5113)*ICE_T^2 + (-0.01271)*ICE_T*ICE_W + ( -0.0008761)*ICE_W^2 + (-0.006071)*ICE_T^3 + (9.867e-07)*ICE_T^2*ICE_W + (5.616e-05)*ICE_T*ICE_W^2 + (1.588e-06)*ICE_W^3 + (3.61e-05)*ICE_T^4 + (8.98e-07)*ICE_T^3*ICE_W + (-2.814e-07)*ICE_T^2*ICE_W^2 + (-8.121e-08)*ICE_T*ICE_W^3 + ( -8.494e-08 )*ICE_T^5 + (-2.444e-09)*ICE_T^4*ICE_W + (-9.311e-10)*ICE_T^3*ICE_W^2 + ( 5.835e-10)*ICE_T^2*ICE_W^3 ) *1/3600/1000 * ICE_T * ICE_W;</p>
<p>#BAT<br>eq_c[2] := BAT = 271;</p>
<p>#EM2<br>EM2_ReqPow_eq := (-148.3) + (4.267)*abs(EM2_W) + (12.77)*abs(EM2_T) + (-0.0364)*abs(EM2_W)^2 + ( 1.16)*abs(EM2_W)*abs(EM2_T) + (-0.258)*abs(EM2_T)^2 + ( 0.0001181)*abs(EM2_W)^3 + (-0.0005994)*abs(EM2_W)^2*abs(EM2_T) + ( 0.0001171)*abs(EM2_W)*abs(EM2_T)^2 + (0.001739 )*abs(EM2_T)^3 + (-1.245e-07 )*abs(EM2_W)^4 + ( 1.2e-06)*abs(EM2_W)^3*abs(EM2_T) + ( -1.584e-06)*abs(EM2_W)^2*abs(EM2_T)^2 + ( 4.383e-07)*abs(EM2_W)*abs(EM2_T)^3 + (-2.947e-06)*abs(EM2_T)^4;<br>eq_c[3] := EM2_P = piecewise( EM2_T = 0, 0, EM2_W = 0, 0, EM2_W*EM2_T < 0,-1 * EM2_ReqPow_eq, EM2_ReqPow_eq);<br>eq_c[4] := EM2_A = EM2_P/EM2_V;</p>
<p>#GEN<br>GEN_ReqPow_eq:= (-5.28e-12) + ( 3.849e-14)*abs(GEN_W) + (-71.9)*abs(GEN_T) + (-1.168e-16)*abs(GEN_W)^2 +(1.296)*abs(GEN_W)*abs(GEN_T) + (2.489)*abs(GEN_T)^2 + (1.451e-19)*abs(GEN_W)^3 + (0.0001326)*abs(GEN_W)^2*abs(GEN_T) + (-0.008141)*abs(GEN_W)*abs(GEN_T)^2 + (-0.004539)*abs(GEN_T)^3 +(-6.325e-23)*abs(GEN_W)^4 + (-2.091e-07)*abs(GEN_W)^3*abs(GEN_T) + ( 3.455e-06)*abs(GEN_W)^2*abs(GEN_T)^2 + ( 2.499e-05)*abs(GEN_W)*abs(GEN_T)^3 + (-5.321e-05)*abs(GEN_T)^4;<br>eq_c[5] := GEN_P = piecewise( GEN_T = 0, 0, GEN_W = 0, 0, GEN_W*GEN_T < 0,-1 * GEN_ReqPow_eq, GEN_ReqPow_eq);<br>eq_c[6] := GEN_A = GEN_P/GEN_V;</p>
<p><strong>#GB</strong><br><strong>FiveSpeedGearbox_R := proc(ig) </strong><br><strong>local i ,eq;</strong><br><strong>i[1]:=3.32;</strong><br><strong>i[2]:=2;</strong><br><strong>i[3]:=1.36;</strong><br><strong>i[4]:=1.01;</strong><br><strong>i[5]:=0.82;</strong><br><strong>eq:= piecewise(ig=1,i[1],ig=2, i[2],ig=3,i[3],ig=4,i[4],ig=5,i[5],1); </strong><br><strong>return eq(ig);</strong><br><strong>end proc;</strong></p>
<p><br><strong>eq_c[7] := GBb_T = -1/GB_R * GBa_T;</strong><br><strong>eq_c[8] := GBb_W = GB_R * GBa_W;</strong><br><strong>eq_c[9] := GB_R = FiveSpeedGearbox_R(ig);</strong></p>
<p> </p>
<p>#System Equations<br>sys_eqs := convert(eq1,set) union convert(eq_c,set);</p>
<p><strong> </strong></p>
<p> #Solve for variables<br>symvarnames:=select(type,indets(convert(sys_eqs,list)),name);<br><strong>drivers:= {ig, ICE_T,ICE_W,FD_T,FD_W};</strong><br>not_drivers := symvarnames minus drivers;<br><br>#Assumptinons</p>
<p>assume(BAT_V::nonnegative);<br>assume(FD_W::nonnegative);<br><br></p>
<p>sol:=(solve(sys_eqs,not_drivers) assuming real);</p>
<p>symb_sol:=unapply(sol,convert(drivers,list)): ---> <strong>Error, (in unapply) variables must be unique and of type name</strong></p>
<p><strong>Subsequent parts don't work...</strong></p>
<p><strong>count := 0;</strong><br><strong>for i1 from 1 to 40 do</strong><br><strong> for i2 from 1 to 40 do</strong><br><strong> for i3 from 1 to 40 do</strong><br><strong> for i4 from 1 to 40 do</strong><br><strong> for i5 from 1 to 40 do</strong><br><strong> count := count + 1;</strong><br><strong> solsol2(count) := symb_sol2(i1,i2,i3,i4,5);</strong><br><strong> od;</strong><br><strong> od; </strong><br><strong> od;</strong><br><strong> od;</strong><br><strong>od;</strong><br><strong>count;</strong></p>
</blockquote>
<p>While running the last line sol:, 1 of 2 things will happen, depending on the solver. Maple17 will take a long time (30+ minutes) to solve, then report nothing, or sol will solve, but will report "some solutions have been lost".</p>
<p>Afterwards, evaluating symb_sol(0,0,0,0,0) will return a viable solution (real values for each of the variables). Whereas evaluating symb_sol(0,X,0,0,0), where X <> 0, will return and empty list [].</p>
<p>Does anyone know how to (i) speed up the symbolic solve time? (ii) Return ALL of the solutions?</p>
<p> </p>
<p>Thanks in advance for reading this. I've really no idea why this isn't working. I've also attached two worksheets with the code: <a href="/view.aspx?sf=201179_question/noGB.mw">noGB.mw</a> <a href="/view.aspx?sf=201179_question/withGB.mw">withGB.mw</a></p>
<p> Adam</p>201179Wed, 19 Mar 2014 20:56:01 Zteh_allchemistteh_allchemistMapleSim 6.4 is now available
http://www.mapleprimes.com/posts/200211-MapleSim-64-Is-Now-Available?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>MapleSim 6.4 includes more powerful tools for creating custom components, performance enhancements, and enhancements to the model generators for Simulink® and FMI. </p>
<p>We have also made important updates to the MapleSim Control Design Toolbox. This toolbox now offers a more complete set of algorithms for PID control, new commands for computing closed-loop transfer functions, and numerous improvements to existing commands. These enhancements allow engineers to design a greater variety of controllers and controller-observer systems while taking advantage of the greater flexibility and analysis options available through the use of symbolic parameters. </p>
<p>See <a href="http://www.maplesoft.com/products/maplesim/new/index.aspx?ref=mapleprimes">What’s New in MapleSim 6.4</a> and <a href="http://www.maplesoft.com/products/toolboxes/control_design/whatsnew.aspx?ref=mapleprimes">What’s New in the MapleSim Control Design Toolbox</a> for details.</p>
<p> </p>
<p>eithne</p><p>MapleSim 6.4 includes more powerful tools for creating custom components, performance enhancements, and enhancements to the model generators for Simulink® and FMI. </p>
<p>We have also made important updates to the MapleSim Control Design Toolbox. This toolbox now offers a more complete set of algorithms for PID control, new commands for computing closed-loop transfer functions, and numerous improvements to existing commands. These enhancements allow engineers to design a greater variety of controllers and controller-observer systems while taking advantage of the greater flexibility and analysis options available through the use of symbolic parameters. </p>
<p>See <a href="http://www.maplesoft.com/products/maplesim/new/index.aspx?ref=mapleprimes">What’s New in MapleSim 6.4</a> and <a href="http://www.maplesoft.com/products/toolboxes/control_design/whatsnew.aspx?ref=mapleprimes">What’s New in the MapleSim Control Design Toolbox</a> for details.</p>
<p> </p>
<p>eithne</p>200211Wed, 19 Mar 2014 18:23:47 ZeithneeithneGlobal Optimization - XYZ problem
http://www.mapleprimes.com/questions/200854-Global-Optimization--XYZ-Problem?ref=Feed:MaplePrimes:Tagged With Toolbox
<p><a href="/ViewTemp.ashx?f=179135_1391645206/Data.xlsx">Data.xlsx</a></p>
<form name="worksheet_form">
<p><a href="/ViewTemp.ashx?f=179135_1391645206/XY.mw">XY.mw</a><a href="/ViewTemp.ashx?f=179135_1391645206/XYZ.mw"><br></a></p>
<p><a href="/ViewTemp.ashx?f=179135_1391645206/XYZ.mw">XYZ.mw</a></p>
<p> </p>
</form>
<p>Hello,</p>
<p>I'm using the Global Optimization Toolbox to solve some examples and fit equations to a given data, finding "unknown" parameters. I generated the data on Excel, and I already know the values of these parameters.</p>
<p>The XY case is (there is no problem here, I just put as a example I follow):</p>
<p style="padding-left: 60px;">> with(GlobalOptimization);<br>> with(plots);<br>> <br>> X := ExcelTools:-Import("F:\\Data.xlsx", "Plan1", "I5:I25");<br>> Y := ExcelTools:-Import("F:\\Data.xlsx", "Plan1", "J5:J25");<br>> <br>> XY := zip( (X, Y) -> [X, Y] , X, Y);<br>> fig1 := plot(XY, style = point, view = [.9 .. 3.1, 6 .. 40]);</p>
<p style="padding-left: 60px;"><br>> Model := A+B*x+C*x^2+D*cos(x)+E*exp(x):<br>> VarInterv := [A = 0 .. 10, B = 0 .. 10, C = -10 .. 10, D = 0 .. 10, E = 0 .. 10];<br><br></p>
<p style="padding-left: 60px;">> ModelSubs := proc (x, val)</p>
<p style="padding-left: 60px;"> subs({x = val}, Model)</p>
<p style="padding-left: 60px;"> end proc;</p>
<p style="padding-left: 60px;"><br>> SqEr := expand(add((ModelSubs(x, X(i))-Y(i))^2, i = 1 .. 21));<br>> CoefList := GlobalSolve(SqEr, op(VarInterv), timelimit = 5000);<br>> <br>> Model := subs(CoefList[2], Model):</p>
<p style="padding-left: 60px;"> </p>
<p>I could find the right values of A, B, C, D and E. </p>
<p> </p>
<p>My problem is in the XYZ case, where I don't know how to "write" the right instruction. My last attempt was:</p>
<p style="padding-left: 60px;">> with(GlobalOptimization);<br>> with(plots);<br><br>> X := ExcelTools:-Import("F:\\Data.xlsx", "Plan1", "Q5:Q25"); X2 := convert(X, list);<br>> Y := ExcelTools:-Import("F:\\Data.xlsx", "Plan1", "R5:R25"); Y2 := convert(Y, list);<br>> Z := ExcelTools:-Import("F:\\Data.xlsx", "Plan1", "S5:S25"); Z2 := convert(Z, list);<br>> NElem := numelems(X);</p>
<p style="padding-left: 60px;">> pointplot3d(X2, Y2, Z2, axes = normal, labels = ["X", "Y", "Z"], symbol = box, color = red);</p>
<p style="padding-left: 60px;"> </p>
<p style="padding-left: 60px;">> Model := A*x+B*y+C*sin(x*y)+D*exp(x/y);<br><br>> VarInterv := [A = 0 .. 10, B = 0 .. 10, C = 0 .. 10, D = 0 .. 10];<br><br>> ModelSubs:=proc({x,y},val)</p>
<p style="padding-left: 60px;">subs({(x,y)=val},Model)</p>
<p style="padding-left: 60px;">end proc:<br><strong>Error, missing default value for option(s)</strong></p>
<p style="padding-left: 60px;">> SqEr := expand(add((ModelSubs(x, y, X(i), Y(i))-Z(i))^2, i = 1 .. NElem));<br>> CoefList := GlobalSolve(SqEr, op(Range), timelimit = 5000);<br><strong>Error, (in GlobalOptimization:-GlobalSolve) finite bounds must be provided for all variables</strong></p>
<p style="padding-left: 60px;"> </p>
<p>My actual problem involves six equations, six parameters and four or five independent variables on each equation, but I alread developed a way to solve two or more equations simultaneously.</p>
<p>Thanks</p><p><a href="/ViewTemp.ashx?f=179135_1391645206/Data.xlsx">Data.xlsx</a></p>
<form name="worksheet_form">
<p><a href="/ViewTemp.ashx?f=179135_1391645206/XY.mw">XY.mw</a><a href="/ViewTemp.ashx?f=179135_1391645206/XYZ.mw"><br></a></p>
<p><a href="/ViewTemp.ashx?f=179135_1391645206/XYZ.mw">XYZ.mw</a></p>
<p> </p>
</form>
<p>Hello,</p>
<p>I'm using the Global Optimization Toolbox to solve some examples and fit equations to a given data, finding "unknown" parameters. I generated the data on Excel, and I already know the values of these parameters.</p>
<p>The XY case is (there is no problem here, I just put as a example I follow):</p>
<p style="padding-left: 60px;">> with(GlobalOptimization);<br>> with(plots);<br>> <br>> X := ExcelTools:-Import("F:\\Data.xlsx", "Plan1", "I5:I25");<br>> Y := ExcelTools:-Import("F:\\Data.xlsx", "Plan1", "J5:J25");<br>> <br>> XY := zip( (X, Y) -> [X, Y] , X, Y);<br>> fig1 := plot(XY, style = point, view = [.9 .. 3.1, 6 .. 40]);</p>
<p style="padding-left: 60px;"><br>> Model := A+B*x+C*x^2+D*cos(x)+E*exp(x):<br>> VarInterv := [A = 0 .. 10, B = 0 .. 10, C = -10 .. 10, D = 0 .. 10, E = 0 .. 10];<br><br></p>
<p style="padding-left: 60px;">> ModelSubs := proc (x, val)</p>
<p style="padding-left: 60px;"> subs({x = val}, Model)</p>
<p style="padding-left: 60px;"> end proc;</p>
<p style="padding-left: 60px;"><br>> SqEr := expand(add((ModelSubs(x, X(i))-Y(i))^2, i = 1 .. 21));<br>> CoefList := GlobalSolve(SqEr, op(VarInterv), timelimit = 5000);<br>> <br>> Model := subs(CoefList[2], Model):</p>
<p style="padding-left: 60px;"> </p>
<p>I could find the right values of A, B, C, D and E. </p>
<p> </p>
<p>My problem is in the XYZ case, where I don't know how to "write" the right instruction. My last attempt was:</p>
<p style="padding-left: 60px;">> with(GlobalOptimization);<br>> with(plots);<br><br>> X := ExcelTools:-Import("F:\\Data.xlsx", "Plan1", "Q5:Q25"); X2 := convert(X, list);<br>> Y := ExcelTools:-Import("F:\\Data.xlsx", "Plan1", "R5:R25"); Y2 := convert(Y, list);<br>> Z := ExcelTools:-Import("F:\\Data.xlsx", "Plan1", "S5:S25"); Z2 := convert(Z, list);<br>> NElem := numelems(X);</p>
<p style="padding-left: 60px;">> pointplot3d(X2, Y2, Z2, axes = normal, labels = ["X", "Y", "Z"], symbol = box, color = red);</p>
<p style="padding-left: 60px;"> </p>
<p style="padding-left: 60px;">> Model := A*x+B*y+C*sin(x*y)+D*exp(x/y);<br><br>> VarInterv := [A = 0 .. 10, B = 0 .. 10, C = 0 .. 10, D = 0 .. 10];<br><br>> ModelSubs:=proc({x,y},val)</p>
<p style="padding-left: 60px;">subs({(x,y)=val},Model)</p>
<p style="padding-left: 60px;">end proc:<br><strong>Error, missing default value for option(s)</strong></p>
<p style="padding-left: 60px;">> SqEr := expand(add((ModelSubs(x, y, X(i), Y(i))-Z(i))^2, i = 1 .. NElem));<br>> CoefList := GlobalSolve(SqEr, op(Range), timelimit = 5000);<br><strong>Error, (in GlobalOptimization:-GlobalSolve) finite bounds must be provided for all variables</strong></p>
<p style="padding-left: 60px;"> </p>
<p>My actual problem involves six equations, six parameters and four or five independent variables on each equation, but I alread developed a way to solve two or more equations simultaneously.</p>
<p>Thanks</p>200854Thu, 06 Feb 2014 00:06:16 ZLeo BNLeo BNRestricting solve (not fsolve) to real solutions?
http://www.mapleprimes.com/questions/200516-Restricting-Solve-not-Fsolve-To-Real-Solutions?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>Hi MaplePrimers,</p>
<p>I'm trying to solve a system of algebraic equations using 'solve' [float]. I'd prefer to use 'solve' over 'fsolve', as 'solve' solves my system in about 0.05s, whereas fsolve takes about 5 seconds. I need to solve the system repeatedly at a different points, so time is important. I don't know why there is such a large difference in time ... </p>
<p>I have a few piecewise functions of order 3 to 5. It solves fine with the other (piecewise) equations, but adding one piecewise function which gives me an error while trying to solve:</p>
<blockquote>
<p>Error, (in RootOf) _Z occurs but is not the dependent variable.</p>
</blockquote>
<p>I think this is due to solve finding multiple solutions. Is there a way to limit solve to only real solutions?</p>
<p>Thanks in advance!</p><p>Hi MaplePrimers,</p>
<p>I'm trying to solve a system of algebraic equations using 'solve' [float]. I'd prefer to use 'solve' over 'fsolve', as 'solve' solves my system in about 0.05s, whereas fsolve takes about 5 seconds. I need to solve the system repeatedly at a different points, so time is important. I don't know why there is such a large difference in time ... </p>
<p>I have a few piecewise functions of order 3 to 5. It solves fine with the other (piecewise) equations, but adding one piecewise function which gives me an error while trying to solve:</p>
<blockquote>
<p>Error, (in RootOf) _Z occurs but is not the dependent variable.</p>
</blockquote>
<p>I think this is due to solve finding multiple solutions. Is there a way to limit solve to only real solutions?</p>
<p>Thanks in advance!</p>200516Tue, 17 Dec 2013 17:01:19 Zteh_allchemistteh_allchemistCalc II related question
http://www.mapleprimes.com/questions/149897-Calc-II-Related-Question?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>How would i go about integrating</p>
<p>(1)/(x^2+2)</p>
<p> </p>
<p>I know it has to do something with arc tan but it doesnt match up completely what would I be able to do?</p><p>How would i go about integrating</p>
<p>(1)/(x^2+2)</p>
<p> </p>
<p>I know it has to do something with arc tan but it doesnt match up completely what would I be able to do?</p>149897Sat, 27 Jul 2013 20:01:13 Zcoach299coach299Programming in Maple Language
http://www.mapleprimes.com/posts/148752-Programming-In-Maple-Language?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>In this article I want to discuss the right way to store and build Maple code.</p>
<p>As mentioned in the <a href="http://www.mapleprimes.com/maplesoftblog/148653-Introducing-The-Maple-IDE">Introducing the Maple IDE</a> post, over 90 percent of the algorithms built into Maple are implemented using Maple language. The code of the algorithms is stored as Maple Libraries (.mla files).</p>
<p>As <p>In this article I want to discuss the right way to store and build Maple code.</p>
<p>As mentioned in the <a href="http://www.mapleprimes.com/maplesoftblog/148653-Introducing-The-Maple-IDE">Introducing the Maple IDE</a> post, over 90 percent of the algorithms built into Maple are implemented using Maple language. The code of the algorithms is stored as Maple Libraries (.mla files).</p>
<p>As <a href="http://www.maplesoft.com/support/help/Maple/view.aspx?path=repository/management">Managing Maple Repositories</a> help page states, a Maple Library (also Maple Repository) is the recommended way for storing Maple procedures and packages. Moreover, the concept of Code Libraries is standard and widely used in programming, for example <a href="http://en.wikipedia.org/wiki/JAR_(file_format)">JARs in Java</a>. The libraries help you to store, reuse and share your code easily.</p>
<p>Maple IDE automates creating of Maple Libraries completely. Your library will be build automatically during the coding and will be updated immediately after each code change. No manual actions are required to pack your code into a Maple Library.</p>
<p>Nevertheless, there are important cases, when you do not need to create Maple Libraries. The cases require the in-place code editor in Maple interface which was introduced in Maple 17.</p>
<p>These cases are: <br> - creating of temporary small procedures which will be used once.<br> - creating of documents where Maple code should be shown in place. For example, Maple help pages or tutorials about Maple language.<br> - creating of documents where the author want to show a small part of the code to the reader.</p>
<p><br> Of course, if your work is one of the above, but you have many lines of code or your code is not temporary, use the IDE to:</p>
<p>- develop using <a href="http://digi-area.com/CasStudio/Maple/guide/tasks/task-code-editor.php">full-featured code editor</a> (syntax coloring and error detection, code formatting and outline, content assist, code navigation, refactoring, code templates etc.)<br> - create Maple Libraries on-the-fly with automated builders<br> - <a href="http://digi-area.com/CasStudio/Maple/guide/tasks/task-running.php">test and debug</a> your code directly from the environment<br> - be sure that the code will not be lost using <a href="http://digi-area.com/CasStudio/Maple/guide/tasks/task-localhistory.php">build-in history</a> or version control systems (SVN, GIT etc.)<br> - spread your work easily using version control services such as <a href="https://github.com/">Github</a>, <a href="http://sourceforge.net/">Sourcefordge</a>, <a href="https://code.google.com/">Google Code</a> etc.</p>148752Sun, 23 Jun 2013 18:07:17 ZSandraBeaverSandraBeaverIntroducing the Maple IDE
http://www.mapleprimes.com/maplesoftblog/148653-Introducing-The-Maple-IDE?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>Everyone knows that Maple combines a smart user interface with a highly sophisticated mathematical engine, where common tasks are performed quickly and seamlessly with point, click and drag operations. Of equal importance, however, is the fact that Maple is also backed by a comprehensive programming language. Also called "Maple", this language combines elements from procedural languages (like C), functional languages (like Lisp) as well as object oriented languages (like C++...<p>Everyone knows that Maple combines a smart user interface with a highly sophisticated mathematical engine, where common tasks are performed quickly and seamlessly with point, click and drag operations. Of equal importance, however, is the fact that Maple is also backed by a comprehensive programming language. Also called "Maple", this language combines elements from procedural languages (like C), functional languages (like Lisp) as well as object oriented languages (like C++). Programming in this language is easy to learn and results in powerful code, due to high-level constructs (like <a href="http://www.maplesoft.com/support/help/Maple/view.aspx?path=map&term=map">map</a> and <a href="http://www.maplesoft.com/support/help/Maple/view.aspx?path=seq&term=seq">seq</a>), built-in knowledge of mathematical data structures and concepts, support for writing multi-threaded, parallel programs as well as a very rich library of existing commands and algorithms.</p>
<p>In fact, over 90 percent of the algorithms built into Maple have been implemented using this same programming language. Our developers, as well as our partners in research labs around the world, use the Maple language to create new Maple functionality. This same language is available to any Maple user for writing scripts, implementing new algorithms and extending the Maple system. Millions of lines of Maple code have been created, with more being produced every day.</p>
<p>The <a href="http://www.maplesoft.com/products/toolboxes/IDE/index.aspx">Maple IDE</a>, which we just released today, will make it dramatically easier to create, manage and update libraries of Maple code. Together with our partner DigiArea Inc., we have created a modern development environment on top of the popular Eclipse framework. Features include the ability to quickly browse and search through source hierarchies, highlighting based on syntactic and semantic properties of the code, navigation, testing and much more. Programming medium to large libraries in Maple is suddenly a feasible option for more customers.</p>
<p>The new IDE will continue to evolve and you can expect a steady stream of new features in the near future. At the same time, we also continue to add coding functionality to our worksheet interface (like the <a href="http://www.maplesoft.com/products/maple/new_features/codeeditor.aspx">code edit region in Maple 17</a> ) for writing small procedures and for developing <a href="http://www.maplesoft.com/products/MobiusProject/">Möbius Apps</a> .</p>
<p>Whether you are new to programming in Maple or whether you are a seasoned expert, I urge you to give the Maple IDE a try. I know that many of you are relying on trusted companions like vi, emacs and notepad for your code development. I have switched to the IDE and I can say that I don't miss vi (much <img src="/view.aspx?sf=148653/463968/smiley2.JPG" alt=""> ).</p>148653Wed, 19 Jun 2013 23:41:52 ZLaurent BernardinLaurent BernardinMaple NAG connector can't find the library
http://www.mapleprimes.com/questions/148179-Maple-NAG-Connector-Cant-Find-The-Library?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>Hi, <br><br>I've bought NAG C Library for my mac in order to use it in Maple.<br><br>However, it seems that Maple doesn't know where to search for it. <br>Indeed, it returns<br> <br>Error, (in NAG:-h03abc) external linking: error loading external library libnagc_nag.dylib: dlopen(libnagc_nag.dylib, 129): image not found <br><br>I've installed NAG C Library in usr/Library</p>
<p> </p>
<p>Thank you very much for your help </p><p>Hi, <br><br>I've bought NAG C Library for my mac in order to use it in Maple.<br><br>However, it seems that Maple doesn't know where to search for it. <br>Indeed, it returns<br> <br>Error, (in NAG:-h03abc) external linking: error loading external library libnagc_nag.dylib: dlopen(libnagc_nag.dylib, 129): image not found <br><br>I've installed NAG C Library in usr/Library</p>
<p> </p>
<p>Thank you very much for your help </p>148179Thu, 06 Jun 2013 23:43:19 Zmartin_zmartin_zMoney Ball with Maple: How to Optimize the 2013 Blue Jays Lineup So They Can Start Winning
http://www.mapleprimes.com/posts/147767-Money-Ball--With-Maple-How-To-Optimize?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>One of the most basic decisions a baseball manager has to make is how to arrange the batting order. There are many heuristics and models for estimating the productivity of a given order. My personal favourite is the use of simulation, but by far the most elegant solution from a mathematical perspective uses probability matrices and Markov chains. An excellent treatment of this topic can be found in Dr. Joel S. Sokol's article,
<p>One of the most basic decisions a baseball manager has to make is how to arrange the batting order. There are many heuristics and models for estimating the productivity of a given order. My personal favourite is the use of simulation, but by far the most elegant solution from a mathematical perspective uses probability matrices and Markov chains. An excellent treatment of this topic can be found in Dr. Joel S. Sokol's article, <a href="http://archive.ite.journal.informs.org/Vol5No1/Sokol/index.php#Sokol2003">An Intuitive Markov Chain Lesson From Baseball</a>.</p>
<p><br>The basic idea is to define a set of states that correspond to the number of outs and the configuration of runners on base. There are 8 possible runner locations and 3 possible number of outs, giving a total of 8x3 = 24 states. With each state there is a corresponding probability of getting to that state. 24 states is good enough for a half inning of baseball. The model needs to be extended to cover 9 innings, plus a "game over" state. By iteratively applying transition matrices in the same order as the lineup, a game can be simulated to calculate the expected number of runs scored.</p>
<p>The full worksheet can be found here: <a href="/view.aspx?sf=147767/462226/BJMarkovBall.mw">BJMarkovBall.mw</a></p>
<p><br>Let's use one of the starting lineups the first quarter of the 2013 Blue Jays. We'll use the 2012 batting data to build the model:</p>
<p><code> data := Matrix(<br>[ #HR 3B 2B 1B BB OUT Name <br> [11, 3, 26, 95, 33, 359, Brett_Lawrie_3B], <br> [11,10, 25, 113, 36, 400, Melky_Cabrera_DH], <br> [27, 0, 14, 39, 59, 252, Jose_Bautista_RF], <br> [42, 0, 24, 86, 84, 390, Edwin_Encarnacion_1B], <br> [18, 0, 16, 47, 18, 266, JP_Arencibia_C], <br> [ 8, 3, 24, 80, 29, 332, Rajai_Davis_LF], <br> [23, 5, 21, 77, 47, 439, Colby_Rasmus_CF], <br> [ 0+1, 0+4, 5+3, 11+55, 14+25, 69+181, Mark_DeRosa_2B_Emilio_Bonifacio_2B],<br> [ 2, 0, 11, 61, 25, 215, Maicer_Izturis_SS]<br>]):#no Adam Lind</code></p>
<p>The code for setting up these calculations is in the code-region below.</p>
<p> </p>
<p><code> </code></p>
<pre><code># Markov Model
createmat := proc( stats )
local i, j, total, h, t, d, s, w, o, smallmat, transmat;
if min(stats) < 0 then
error "probabilities can not be negative";
end if;
# convert counts to probabilities
total := add(i,i in stats);
h := stats[1] / total;
t := stats[2] / total;
d := stats[3] / total;
s := stats[4] / total;
w := stats[5] / total;
o := stats[6] / total;
# this submatrix will appear for each inning and each number of outs -
# it gives the probabilities of changing states when an out does not
# occur.
smallmat := Matrix(8,8,datatype=float[8]);
smallmat(1,..) := ;
smallmat(2,..) := ;
smallmat(3,..) := ;
smallmat(4,..) := ;
smallmat(5,..) := ;
smallmat(6,..) := ;
smallmat(7,..) := ;
smallmat(8,..) := ;
transmat := Matrix( 9*24+1 , 9*24+1, datatype=float[8] );
for i from 1 to 9*3 do
transmat( (i-1)*8+1 .. (i-1)*8+8 , (i-1)*8+1 .. (i-1)*8+8 ) := smallmat;
end do;
# Now, when an out occurs and it's not the third out, just advance to
# the same inning and same on-base state with one more out.
for i from 1 to 9 do
for j from 1 to 2 do
transmat( (i-1)*24+(j-1)*8+1 .. (i-1)*24+(j-1)*8+8 ,
(i-1)*24+(j-1)*8+9 .. (i-1)*24+(j-1)*8+16 ) :=
o . LinearAlgebra:-IdentityMatrix(8);
end do;
# In each inning, the third out goes to the next inning's
# "0 out, 0 on base" state regardless of who was on base before.
transmat( (i-1)*24+17 .. (i-1)*24+24 , i*24+1 ) := o . Matrix(8,1,fill=1);
end do;
# The final "game over" state can only go to itself.
transmat( 9*24+1 , 9*24+1 ) := 1;
end proc:
playermatrices := Array(1..9):
for i from 1 to 9 do
playermatrices[i] := createmat(data[i,1..-2]);
end do:
smallmat := Matrix([
[ 1, 0, 0, 0, 0, 0, 0, 0 ],
[ 2, 1, 1, 1, 0, 0, 0, 0 ],
[ 2, 1, 1, 1, 0, 0, 0, 0 ],
[ 2, 1, 1, 1, 0, 0, 0, 0 ],
[ 3, 2, 2, 2, 1, 1, 1, 0 ],
[ 3, 2, 2, 2, 1, 1, 1, 0 ],
[ 3, 2, 2, 2, 1, 1, 1, 0 ],
[ 4, 3, 3, 3, 2, 2, 2, 1 ]
]):
createrunmatrix := proc( smalllmat )
local i;
local runmatrix := Matrix(9*24+1,9*24+1,datatype=float[8]);
for i from 1 to 9*3 do
runmatrix( (i-1)*8+1 .. (i-1)*8+8 , (i-1)*8+1 .. (i-1)*8+8 ) := smallmat;
end do;
runmatrix;
end proc:
runmatrix := createrunmatrix(smallmat):
calculate := proc( ord, playermatrices, runmatrix)
uses ArrayTools;
local M, situation, runs, batter;
situation := Matrix( 1 , 9*24+1, datatype=float[8] );
situation(1) := 1;
runs := 0;
batter := 0;
while situation(9*24+1) < 0.99 do
M := playermatrices[ord[batter+1]];
runs := runs + add(i, i in situation . (runmatrix *~ M));
situation := situation . M;
# Get next batter
batter := (batter + 1) mod 9;
end do;
runs;
end proc:
MaxWithIndex := proc( r )
rtable_scanblock(r, [1 .. upperbound(r,1)],
(val, ind, res)->`if`(res[2] < val, [ind, val], res), [[1], r[1]]);
end proc:
MinWithIndex := proc( r )
rtable_scanblock(r, [1 .. upperbound(r,1)],
(val, ind, res)->`if`(res[2] > val, [ind, val], res), [[1], r[1]]);
end proc:
</code></pre>
<p><code> </code></p>
<p>Now we simply pick an order permutation, say, in the given order:</p>
<pre><code>ord := [1,2,3,4,5,6,7,8,9]:</code></pre>
<p>Then we can calculate the expected number of runs this lineup will generate.</p>
<pre><code>runs := calculate(ord,playermatrices,runmatrix);</code></pre>
<p style="text-align: center;"><em>4.330150441827209</em></p>
<p>The permutation that has the 9th batter lead-off will, as expected, generate fewer runs (but not by much!).</p>
<pre><code>ord := [9,2,3,4,5,6,7,8,1]:
runs := calculate(ord,playermatrices,runmatrix);
</code></pre>
<p><code> </code></p>
<p style="text-align: center;"> <br><em>4.320882424139622</em></p>
<p style="text-align: left;">But what is the best possible ordering? We can iterate through all possibilities. There are 9! permutations</p>
<pre><code>combinat:-numbperm(9);</code></pre>
<p style="text-align: center;"><em>362880</em></p>
<p style="text-align: left;">Trying a smaller sample -- the first 100 permutations, we can get a sense of how long this will take. At the same time we'll store the result of each calculation in an array. The <a href="http://www.maplesoft.com/support/help/Maple/view.aspx?path=combinat/rankperm&term=unrankperm">unrankperm</a> command helps us iterate through all possible permutations. </p>
<pre><code>Nperm := 100:
num_players := upperbound(playermatrices,1):
r := Array(1..Nperm,datatype=float[8]):
t := time[real]():
for i from 1 to Nperm do
ord := combinat:-unrankperm(i,num_players);
r[i] := calculate(ord,playermatrices,runmatrix);
od:
printf("serial time for %d permutations: %0.3f seconds\n",Nperm,time[real]()-t);
</code></pre>
<p style="text-align: center;"><em>serial time for 100 permutations: 7.997 seconds</em></p>
<p style="text-align: left;"><br>Before optimizing the code, the time to calculate 20 permutations was 12.044 seconds. That means it would have taken about 12.044*9!/(60*(20*60)) = <em>60.70176001</em> hours to iterate through all possibilities. Even with optimized serial code, I was looking at an 8 hour computation. Here's how the code looks after being restructured to split up the problem over many cpus. </p>
<pre><code>
calculateall := proc( playermatrices, runmatrix, { NP::posint := 0 } )
uses Grid, combinat;
local r, me, a, b, span, ord, n, i, num_perm, num_players, file;
global calculate;
num_players := upperbound(playermatrices,1);
num_perm := `if`( NP > 0, NP, numbperm(num_players));
# decide which partition this node should work on
me := MyNode();
n := NumNodes();
span := num_perm / n;
a := trunc(me*span+1);
b := trunc((me+1)*span);
# calculate results
r := Array(1..b-a+1,datatype=float[8]):
printf("Node %d/%d handling permutations %d .. %d\n", me,n,a,b);
for i from a to b do
ord := combinat:-unrankperm(i,num_players);
r[i-a+1] := calculate(ord,playermatrices,runmatrix);
od:
#uncomment to store results
#file := cat("markovresult",me,".m");
#save(r, file);
# send results back to node 0
if me = 0 then
ArrayTools:-Concatenate( 2, r, seq(Receive(i),i=1..n-1) );
else
Send(0,r);
end if;
end proc:
</code></pre>
<p>Here's a sample run using the parallel method.</p>
<pre><code>t := time[real]():
r := Grid:-Launch(calculateall,playermatrices,runmatrix,NP=100,imports=[calculate],allexternal=false );
printf("parallel time for 100 permutations: %0.3f\n",time[real]()-t);
</code></pre>
<pre><em>
Node 1/4 handling permutations 26 .. 50
Node 2/4 handling permutations 51 .. 75
Node 3/4 handling permutations 76 .. 100
Node 0/4 handling permutations 1 .. 25
[1 .. 100 Array ]
[Data Type: anything ]
[Storage: rectangular]
[Order: Fortran_order]
parallel time for 100 permutations: 5.375
</em></pre>
<p>This parallel method simply splits the calculations up evenly based on the number of nodes in the pool. It doesn't account for situations where it takes longer to process some of the permutations. Scaling this up to NP=1000, we observed a serial time of 71.7 seconds, compared to a parallel time of 35.4 seconds on an older 4-core box. It is my guess that memory contention severely limited the performance on a single computer, where 4 processors had to share access to the heap, and at 1000 permutations, about 5GB of memory is accessed -- "memory used" from a pool of 95MB per process. We'll look at performance over a distributed cluster below, after we analyse the results. Examining the result computed after the first set of iterations, we see a better predicted runs from the 26th permutation. The recommendation so far is to swap the #5 and #6 hitters and drop the 8th batter down to the 9th spot.</p>
<p> </p>
<pre><code>MaxWithIndex(r);
</code></pre>
<p style="text-align: center;"><em>[[26], 4.332527095304076]</em></p>
<p> </p>
<pre><code>combinat:-unrankperm(26,9);
</code></pre>
<p style="text-align: center;"><em>[1, 2, 3, 4, 6, 5, 7, 9, 8]</em></p>
<p>We need to run through the full computation to find the best results.</p>
<p>It turns out the best result is as follows:</p>
<pre><code>best_perm := [[298945], 4.35010071731]:
ord := combinat:-unrankperm(best_perm[1][1],9);
</code></pre>
<p style="text-align: center;"><em>[8, 4, 3, 2, 5, 1, 6, 7, 9]</em></p>
<pre><code>best := data[ord];
</code></pre>
<pre><img src="/view.aspx?sf=147767/462226/BJMarkovBall_12.gif" alt=""></pre>
<p>This seems like a very surprising result until you show some further statistics -- each batters slugging average, on-base-percentage, and on-base-plus-slugging. The OPS column hints at how the new order was arrived at. The stand-out statistic is something called on-base-plus-slugging (OPS), which is a measure of a player's ability to both get on base, and get extra-base hits. It also turns out that the #1 spot in the lineup is not the most important one, rather #2, #3, and #4 are the key spots. And yes, even though Jose Bautista hit only .241 last year, he still deserves to be in one of the clean-up spots (at least in this Jays lineup).</p>
<p> </p>
<pre><code>show_stats := proc( lineup )
local S, i, Hits, AB;
S := Array(1..10,1..11):
S[1,..] := :
S[2..10,..] := lineup:
for i from 1 to 9 do
Hits := add(lineup[i,j],j=1..4);
AB := Hits + lineup[i,6];
S[i+1,8] := evalf(Hits/AB,3);
S[i+1,9] := evalf((4*lineup[i,1]+3*lineup[i,2]+2*lineup[i,3]+lineup[i,4])/AB,3);
S[i+1,10] := evalf((Hits+best[i,5])/AB,3):
S[i+1,11] := S[i+1,8] + S[i+1,9];
od:
interface(rtablesize=15):
S;
end proc:
show_stats( best );
</code></pre>
<p><img src="/view.aspx?sf=147767/462226/BJMarkovBall_13.gif" alt=""></p>
<p>A key thing to note is that changing the order of a lineup of major-leaguers does not make a huge impact on the expected run production (from a statistical point of view). Here we see the worst possible ordering will only lead to a drop in run production of 1 run every 5 or 6 games. The impact is much greater when putting together a beer-league lineup where the players have a much wider range of ability.</p>
<pre><code>
worst_perm := [[141719], 4.17480299108879]:
ord := combinat:-unrankperm(worst_perm[1][1],9);</code></pre>
<p style="text-align: center;"><em>[4, 6, 1, 8, 9, 7, 5, 2, 3]</em></p>
<pre><code>show_stats(data[ord]);
</code></pre>
<pre><code><img src="/view.aspx?sf=147767/462226/BJMarkovBall_15.gif" alt=""><br></code></pre>
<pre><code>
ExpectedChangeInRunProduction := best_perm[2] - worst_perm[2];
</code></pre>
<p style="text-align: center;"><em>0.175297726</em></p>
<p>This result was computed using 256 nodes on an Opteron-based computer in 192 seconds. A sample run of 100 permutations in serial took 12.79 seconds, leading to an estimate of 12.79*9!*(1/100) = 46412.35200 seconds for a full serial run. This is very close to the total parallel time -- 192*256 = 49152 seconds, indicating that the distribitued computation scaled linearly. But, instead of waiting almost 13 hours for that serial run to complete, the parallel answer was available in 3.2 minutes (using only 3% of the capacity of orca's 8320 cores).</p>
<pre><code>
Statistics:-ColumnGraph([46412, 192],
datasetlabels = ["serial", "parallel"],
labels = ["","time in seconds"]);
</code></pre>
<pre><code><br></code></pre>
<pre><code><img src="/view.aspx?sf=147767/462226/BJMarkovBall_21.gif" alt=""><br></code></pre>147767Mon, 27 May 2013 18:45:33 ZPaulPaulNew global optimization toolbox
http://www.mapleprimes.com/posts/146980-New-Global-Optimization-Toolbox?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>We have just released a new, more powerful version of the Maple Global Optimization Toolbox. </p>
<p>For this new release, Maplesoft has partnered with Noesis Solutions to develop a new version of the Maple Global Optimization Toolbox that is powered by Optimus technology. Optimus, from Noesis Solutions, is a platform for simulation process integration and design optimization that includes powerful optimization algorithms. This advanced technology is now available...<p>We have just released a new, more powerful version of the Maple Global Optimization Toolbox. </p>
<p>For this new release, Maplesoft has partnered with Noesis Solutions to develop a new version of the Maple Global Optimization Toolbox that is powered by Optimus technology. Optimus, from Noesis Solutions, is a platform for simulation process integration and design optimization that includes powerful optimization algorithms. This advanced technology is now available to Maple users as the engine behind the Global Optimization Toolbox, reducing execution times and expanding the scope of problems this toolbox can solve.</p>
<p>Visit <a href="http://www.maplesoft.com/products/toolboxes/globaloptimization/">Maple Global Optimization Toolbox</a> to learn more about this toolbox and see what’s new in this release.</p>
<p> </p>
<p>eithne</p>146980Wed, 08 May 2013 23:58:23 ZeithneeithneMapleSim Connector C code api?
http://www.mapleprimes.com/questions/145427-MapleSim-Connector-C-Code-Api?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>Hello,</p>
<p>I have a model in MapleSim for which I've generated the optimized C code using the connector toolbox, and I'd like to work with it directly. I was wondering if there is any documentation or examples of how to do this? I haven't been able to find any online.</p>
<p>Thanks! </p><p>Hello,</p>
<p>I have a model in MapleSim for which I've generated the optimized C code using the connector toolbox, and I'd like to work with it directly. I was wondering if there is any documentation or examples of how to do this? I haven't been able to find any online.</p>
<p>Thanks! </p>145427Wed, 03 Apr 2013 19:53:21 ZtdewolftdewolfCalling theTemplate Optimization from a batch file
http://www.mapleprimes.com/questions/143874-Calling-TheTemplate-Optimization-From?ref=Feed:MaplePrimes:Tagged With Toolbox
<p>Hello everybody,</p>
<p>I' m trying to run completely The optmization template from a batch file (.bat) and wonder how to :</p>
<ol>
<li> Make the buttons working automatically.</li>
<li> What command should be used in a batch file to execute utterly a maple program</li>
<li>What kind of script file can be perfect for Matlab / Maple.</li>
</ol>
<p>The point is to run in parallel Matlab and Maple, using a script file(.bat) or another external script format.<p>Hello everybody,</p>
<p>I' m trying to run completely The optmization template from a batch file (.bat) and wonder how to :</p>
<ol>
<li> Make the buttons working automatically.</li>
<li> What command should be used in a batch file to execute utterly a maple program</li>
<li>What kind of script file can be perfect for Matlab / Maple.</li>
</ol>
<p>The point is to run in parallel Matlab and Maple, using a script file(.bat) or another external script format.<br>I would appreciate any suggestion or simple tutorial.</p>
<p>Thanks very much</p>
<p>Best regards.</p>
<p> </p>143874Mon, 25 Feb 2013 03:58:43 ZElOrcheElOrche