23rd November 2008

What finally worked

I have a quad core machine at my desk so I run multiple MATLAB windows.  These multiple windows allowed me to test some distributed computing processes.  As a result I set up a script for allowing the multiple windows to run.  I was using Stateflow in the model which requires a compile before each run.  As a result the model had to be run from a temporary directory.

This temporary directory was the first sign that the function, when distributed, is working.  The second sign was when the output file is saved.

Long story short, the batch command worked.  The batch command works but only with the PathDependencies and FileDependencies properties set.  The function is something like this

jj = batch(‘monte_sim_loop’, ‘matlabpool’, 0, ‘PathDependencies’, {…}, ‘FileDependencies’, {…});

The matlabpool set to 0 is important.  I tried to using a matlabpool of 3 for my initial runs.  It tied up 4 nodes but only run 1 instance of the sim.  Then I created a loop

for ii = 1:15

  jj = batch(…

end

The reason that a matlabpool of 3 tied up 4 nodes was that the matlabpool property is for how many additional nodes you want running.  It originally appeared to be an overhead function that was created.  A coworker discovered the matlabpool command already assumes 1 node and so anything higher than 0 ties up that many extra PCs for the 1 job task.  Since I just want my jobs distributed (not parallel) I set the property to 0.   When I ran the loop above, 15 computers were tied up and 15 nodes worth of results were produced.

If you know more, please share

I invite anyone and everyone who knows more about how to use the Parallel Computing Toolbox to share.  Use the comments to share.  Or if you like I welcome guest bloggers.

Thanks

Previous, related, posting

MATLAB’s Parallel Computing Toolbox First Impression

20th November 2008

Monte Carlo Runs

For work I’ve been asked to run a Monte Carlo analysis.  The analysis is one where I vary a large set of parameters in a large Simulink simulation.  Any given simulation will take between 40 minutes and a few hours.  So obivously generating thousands of runs with a single computer would take months.

In the lead up to this analysis I asked a few questions.  First, I found a bank of parallel computing resources at work.  I asked them if it was possible and the answer was “Yes” with my take away being that it was doable and easy.  It may be doable, it is not easy.  Second, I went to Mathworks training (on modeling for aerospace system which had a session on parallel computing) and asked some questions about how to run parallel operations.  I also left this session thinking it would be easy.

The online help is worthless

When you are running a model of any complexity there are a lot of parameters to set.  If you are building models correctly you will be setting these parameters via variables not hard coding.  This means that the simulation workspace must have all those variables.

The Mathworks help with regard to the Parallel Toolbox and Simulink simulations is pretty meager.  One of the easiest means of distributing the simulation is through the use of the parfor keyword instead of the for keyword.  The meager help suggests that simulation must be run from within a function because parfor requires a static workspace and Simulink creates variables in whatever workspace it runs from.  So the help suggests using a dummy function as a wrapper for the sim command.

The help forgets to mention that running a simulation from a function’s workspace is simple – once you find that help but finding that help was a little buried.  (If you want to know how look up the simset function and the SrcWorkspace and DstWorkspace properties.)  I have run several simulations from within a function’s workspace on a single PC.  However, doing so from within a dummy function called from a parfor loop doesn’t work like it does from a single PC.  And the error messages are obtuse.

Obtuse Error Messages

I spent days attempting to get the simulations distributed to the various nodes.  The error messages provided at this stage were reasonably straight forward.  However, once the simulation was distributed to the nodes the error became far less useful.  The first couple of times there was no obvious error.  After digging through a long log file a cowroker found the errors and helped me fix them.  That said, I think they were listed as warnings in the log file not errors.

Next Post:  What finally appears to have worked

18th September 2008

MATLAB Pricing

MATLAB is a great tool.  I use it every day and have few complaints.  However, I’d like to use it for personal purposes.  The price of MATLAB makes its use for personal purposes cost prohibitive.  As of Sept. 14th, 2008 the prices are

  • MATLAB: $1900
  • Simulink: $3000
  • Control System Toolbox: $1000
  • Signal Processing Toolbox: $800

This is the basic MATLAB package I’ve always had as a professional.  Sometimes I have other toolboxes but I always have at least these.  Can most of us afford $6700 for personal use?

The MATLAB Monopoly

If MATLAB had any real competition, would the price still be $1900 for just MATLAB?  There are 2 competitors that I know of and neither is really a true competitor.  The first competitor is OCTAVE a free MATLAB like program.  In my brief examination of OCTAVE for use on my website I found it to be lacking most of the functionality of MATLAB.  The second competitor I come across is SimApp.  I’ve been in contact with a marketing person here in Colorado for SimApp and the price I was given was $500.  They have several licenses but I haven’t dug around the site to see what license you get for $500.  SimApp is a much smaller application with much less to it than MATLAB.

The purpose of SimApp is to offer only what we need most of the time and to do so at a reasonable price.  Mathworks offers items in toolboxes for the same purpose – at I assume that’s why.  However, their prices aren’t reasonable.

Is there justification for MATLAB’s price?

Like Microsoft, Mathworks is the only game in town and they set whatever price they want.  The price is high and I don’t like it but is it justified?

The Mathworks updates MATLAB about twice a year.  For the most part it is bug fixes and minor improvements.  Very rarely is there serious new functionality included in these updates.  For MATLAB 2008a the major upgrade is in Object Oriented programming.  The new interface is light years better than the old but the functionality isn’t new.

Most of the improvements I heard of over the last couple of years have involved improved plotting tools.  Some tools are new like a GUI interface to allow for interactive regression on the plot.  The other plotting improvements are bug fixes in my opinion (i.e. bugs like the aspect ratios not remaining fixed in certain uses of the saveas function).  After all these years, they still haven’t gotten the bode plot right in my opinion.

Conclusion

This latest round of installations for MATLAB 2008a really made me and a lot of my coworkers very angry.  There was a lot of extra work to get it installed.  And the only reason for our having the extra was that Mathworks didn’t do the work themselves.  In essence Mathworks let the users do beta testing of the MATLAB 2008a installation process on a full release version.  Kind of like every new Microsoft operating system, this program wasn’t ready for general release.

Since many of us who use and love MATLAB have long been cranky about the price for an individual license, there is some latent hostility and strong beliefs about knocking the chip off Mathworks’ shoulder.

MATLAB is a great program and every company has a right to set their own price to maximize profit.  That doesn’t mean users have to happy about it.  Companies with real competition worry more about irritating their customers.  That or they go out of business.

P.S.: 64 bit MATLAB

I have a 64 bit Quad core PC.  I installed 64 bit MATLAB on it.  However, anything in Simulink that requires a compiler doesn’t work.  Mathworks doesn’t ship a compatible compiler.  The only compiler compatible with Simulink on a 64 bit installation is a special installation of Microsoft’s Visual Studio 2005 Professional.  It seem kind of silly to install a $300 program just for the compiler.

Obviously, Mathworks should have included a compatible compiler.  The tech support was very helpful in this but only after I got nasty with them.  And the first level tech suggested more than one incorrect fix and this got to be time consuming.

15th September 2008

Control System Modeling: Purpose

I’m going to use model and simulation as synonyms in this post.

The purpose of modeling in any discipline, including control systems, is to answer a question; often a very specific question is answered.  There are several reasons for why any given model only answers a small set of questions.  Budget and Schedule.

Modeling Complexity

Budget and schedule force engineers to model only those aspects deemed necessary to answer the question posed.

Modeling the universe in detail – even the very localized universe around a small object – takes a lot of work and time.  Budget and schedule concerns always force engineers to start with first principles and then model progressive deeper levels of details and fidelity.  The deeper layers are only modeled if the desired level of result accuracy requires this extra fidelity.

There are several reasons for keeping a model as simple as possible:

  1. Initial time to development goes up with complexity
  2. Time required for maintanence goes up with complexity
  3. Odds of a mistake go up with complexity
  4. Time between simulation start and delivery of results goes up with complexity

My observation is that items #1 through #3 increase roughly exponentially with complexity.  Turn around time (#4) increases but the amount of increase is highly dependent on the slowest part of the model as it exists prior to the increase in fidelity.

Control System Modeling: Pitfalls

Expanded Purpose

Engineers and other professionals who do not create or run simulations on a regular basis often forget about the narrow focus of a good model.  As a result these people often ask for results the model is not designed to produce.  Obviously the engineer being asked for the results needs to consider the request very carefully.  There may be an assumption built into the model which invalidates its use for this expanded purpose.

Juggling Programs

Each day that I work on a model I go through a process of “loading my RAM” or short term memory.  In order to work on the model and produce meaningful results a certain number of details and parameters must be loaded up into short term memory.  I find this process takes no more than 30 minutes and rarely takes more than 45 minutes.

The pitfall is in assuming you can juggle certain types of work.  Last summer I was asked to juggle modeling work and hardware maintanence work.  The hardware work needed me for 30 minutes at a time about 4 or 5 times a day.  As a result the hardware work repeatedly interrupted my efforts on the modeling work.  The interruptions came about every hour and a half.  So I used half of my time in between “loading my RAM”.

After about 2 or 3 weeks of trying to juggle the hardware and the modeling work I realized I was never gonig to get anything done on the model if I didn’t set some limits.  I asked the two programs how they wanted me to handle the problem.  The basic response was just deal with it.  So I decided to tell the hardware guys that 2 days a week they couldn’t bother me, except for emergencies.  No one was happy but it was the best I could do.

06th September 2008

I’ve used MATLAB for my day-to-day tasks for over 7 years now.  If you include the time I’ve spent using MATLAB in school I’ve been using it for close to 10 years.  In general I think MATLAB and Simulink are great products and the Mathworks has done a lot to develop an image as the industry standard tool.

MATLAB 2008a Installation woes

That said, MATLAB 2008a has a new installation and activation procedure.  This requires either an active internet connection or a lot of jumping through hoops.  We just love that when we consider installing it on classified PCs that, by design, have no internet connection.

On my unclassified PC I had no apparent problems with the MATLAB 2008a installation and activation.  It took a little bit of time for the Mathworks server to get to provide my PC with the necessary go-ahead commands but that didn’t bother me.  At least until I couldn’t use MATLAB 2008a after the first reboot.  Yeah the license file includes the PC name in it – and that name appears to be case sensitive – so on reboot our company network somehow changed the case and I couldn’t use MATLAB 2008a.

2008a Uninstall woes

On top of that our company license allows for MATLAB to be installed on up to 4 PCs and up to 2 PCs can run MATLAB concurrently under the same license.  I’ve got 5 PCs at work.  I tested 2008a on the oldest PC as the most of the newer ones were tied up doing some heavy duty data reduction.  I wanted to be sure that 2008a performed just like the previous versions did.  2008a performed just fine.  At least until I attempted to uninstall it.

Uninstallation requires a deactivation process.  Much like the activation process, the deactivation process did not work like it should.  In fact, it didn’t work at all for me.  I had to talk to Mathworks tech support who then killed the oldest PC’s activation on their end.  On about the 3rd try with support I was finally able to deactivate that installation.

2008a: The bottom line…

Don’t install 2008a unless you have a really good reason for doing so.  I’m one of the early adopters in my company and I’ll probably skip the installation 2008b.  I’m hoping that by the 2009a version that Mathworks will have it head out of its ass.

Mathworks has every right to dictate license terms.  They have every right to dictate installation procedures.  And I have every right to be pissed that their new installation process wasted a whole lot of my time.

I have only detailed the problems I’ve had.  Others in my company have had a whole slew of other problems.  These problems are ameturish and should not happen in a product as old as MATLAB.  Changing the installation process that worked just fine (as far as this user is concerned) should either (a) make my life easier as the user or (b) at least be no worse.  Unfortunately, the new process is terrible.  It is horrible and whoever let it get through the Mathworks QA dept. should be smacked with dogbert’s wand of wisdom.

Post tags: ,

Powered by Yahoo! Answers

SEO Powered by Platinum SEO from Techblissonline