Giter Club home page Giter Club logo

serial2parallelmanager's Introduction

Serial2ParallelManager

If a program is serial, but has to read and write files in order to interface with other programs, MATLAB can only run one instance of the serial program at a time, despite having the capability to perform parallel computation. Thus, if we were able to perform these serial computations across multiple cores, we could expect a decrease in the time to execute the program for many varying inputs.

The Serial2ParallelManager MATLAB class achieves this by creating a directory structure where the files necessary for running are copied to separate folders where the MATLAB parallel workers perform the execution of the serial program and the subsequent analysis.

This is particularly useful when parfor loops are present; this is the case when performing MOGA optimizations using ga or gamultiobj.

Example Use Cases

We provide a couple of possible use cases that call a program called ImpactZexeWin.exe that reads in a files ImpactZ.in and particle.in and outputs text files fort.1001. The precompiled windows version of the program that is available here is by default serial, though this class should work for the mpi linux versions of the program if the number of processors cores is specified is 1.

parfor Loop

gamultiobj Optimization

%% --------Set up parallel pool and file structure---------

numCores = 10;
parpoolfiles = ["optFunct.m"];
Serial2ParallelManager.setupParpool(parpoolfiles,numCores);

homeDir = pwd;
copyFiles = {'ImpactZ_original.in','ImpactZexeWin.exe','particle.in'};
obj = Serial2ParallelManager(homeDir,copyFiles);
obj.setupDirWorkers();

%% -------------------Run Opitmization----------------------

maxGrad = 15;
KE = 27.9704E+06;
[gamma, beta] = KE2betaGamma(KE);

maxK = 0.2998*maxGrad/beta/(KE*1e-9);
ub = [1,0,1,1,0,1]*maxK;
lb = [0,-1,0,0,-1,0]*maxK;

betaXTuned = 4.525263797052626;
alphaXTuned = 24.890411508540677;
phaseAdvanceTuned = +5;

objectiveFunc = @(Qvals) obj.run(@optFunct,Qvals,betaXTuned,alphaXTuned,phaseAdvanceTuned);

nvars = length(ub);

options = optimoptions('gamultiobj',...
                       'Display','Iter',....
                       'UseParallel',true,...
                       'UseVectorized',false,...
                       'PopulationSize',200,...
                       'MaxGenerations',10);
[x,fval,exitflag,output,population,scores] = gamultiobj(objectiveFunc,nvars,...
    [],[],[],[],lb,ub,options);

serial2parallelmanager's People

Contributors

lm314 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.