WSMLink and ParallelTable

I (somewhat) understand how distribution works in parallelization. I would like to run WSMLink on multiple kernels, but I suspect that WSMLink makes calls to WSM and not to the Mathematica kernel. Is there a way to parallelize WSM? I tried DistributedContexts->“WSMLink`” but that didn’t do it either.

If I explain my goal, someone will probably have a better idea of how to accomplish it. I know there is sensitive analysis in WSM, but I want to vary specific parameters in a well defined way. I’d like to run this parameter study by scripting instead of using a GUI. So in Mathematica I tried

parVals={1,2,3,4}; 
ParallelTable[WSMSimulate[myModel,WSMParameterValues->{component.parameter->val},{val,parVals}]

But that returns

WSMLink`WSMSimulate[myModel,WSMLink`MSMParameterValues->component.parameter->val},{val,parVals}]

Parallel parameter sweeps are actually built-in:

parVals={1,2,3,4}; 
WSMSimulate["myModel",WSMParameterValues->{"component.parameter" -> parVals}]

That will run simulations in parallel and return a list of simulation results.

Using the parallel Mathematica kernels (Parallelize, ParallelTable, ParallelEvaluate…) with WSMLink is not recommended. For starters, it would require every Mathematica slave kernel establishing a connection to SystemModeler.

The SystemModeler kernel cannot handle more than one request at the time, so the speedups are not likely to be significant. Also, a normal license only allows for one connection at a time between Mathematica/WSMLink ↔ SystemModeler.

Perfect! Thanks Malte.

With this information, can I confirm a couple things with you?

  1. Presumably I can set multiple parameters with Lists of the same length parsList={"component.parameter"->{1,2,3,4},"component.parameter1"->{2,3,4,5}}
  2. And hopefully I can mix scalars and lists parsList={"component.parameter"->{1,2,3,4},"component.parameter1"->2}
  3. And finally, what happens if my lists are unequal lengths? Will I get an error? parsList={"component.parameter"->{1,2,3,4},"component.parameter1"->{2,3}}
  1. Yes. In this case it will run four simulations.

  2. Yes. In this case it will run four simulations. “component.parameter1” will be 2 in all four simulations.

  3. Yes, this is an error. There is no straightforward way WSMSimulate could guess what you are trying to do, so you get:

     WSMSimulate::pil: There are WSMParameterValues and/or WSMInitialValues with different lengths. >>
    

Great. I guess I could have ran those cases for myself, so I appreciate you responding so I didn’t have to :slight_smile: