Matlab/Octave with EC2
amazon-ec2, cloud, distributed-computing, matlab, octave
Solution
One idea that doesn't require additional licenses would be to deploy the MATLAB Compiler Runtime (MCR) on your EC2 instances. Then use the MATLAB Compiler to create executables of your code and run them on those EC2 instances.
The MCR is provided with MATLAB Compiler for distribution with your application and can be deployed royalty-free.
If you want to take this approach further, consider running a local job-queue that distributes work across available EC2 instances. This seems to be a nice write-up on how to do so.
Problem
I'd like to use Matlab with EC2, its basically an embarrassing parallel problem so I don't necessarily need the parallel toolbox. Reading the blog here: http://aws.typepad.com/aws/2008/11/parallel-comput.html The link to the white paper, actually takes you to a webpage where it says that the service is only available in USA and Canada (I'm UK based) but that you can register your interest. Moreover it seems there may be an issue with licences? If I have to buy a new license for each CPU its a non starter for me. My program doesn't really use any big MATLAB function like lsqmin, so in theory it should be easily convertible to Octave (I think). If using Matlab with EC2 is not possible for any of the reasons above can anyone tell me how to use Octave with EC2? ``` function [output]=DElambda(de,data,OF) P1=zeros(de.d,de.nP); Pu=zeros(de.d,de.nP); for i=1:de.d P1(i,:)=de.min(i,1)+(de.max(i,1)-de.min(i,1))*rand(de.nP,1); end P1(:,1:de.d)=diag(de.max); P1(:,de.d+1:2*de.d)=diag(de.min); for i=1:de.nP betas(:,i)=NSS_betas(P1(:,i),data); end Params=vertcat(betas,P1); Fbv=NaN(de.nG,1); Fbest=realmax; F=zeros(de.nP,1); P=zeros(de.nP,1); for i=1:de.nP F(i)=OF(Params(:,i)',data); P(i)=pen(P1(:,i),de,F(i)); F(i)=F(i)+P(i); end [Fbest indice] =min(F); xbest=Params(:,indice); Col=1:de.nP; for g=1:de.nG P0=P1; rowS=randperm(de.nP)'; colS=randperm(4)'; RS=circshift(rowS,colS(1)); R1=circshift(rowS,colS(2)); R2=circshift(rowS,colS(3)); R3=circshift(rowS,colS(4)); %mutate Pm=P0(:,R1)+de.F*(P0(:,R2)-P0(:,R3)); %extra mutation if de.R>0 Pm=Pm+de.r*randn(de.d,de.nP); end %crossover PmElements=rand(de.d,de.nP)<de.CR; %mPv(MI)=mP(Mi); if de.oneElementfromPm Row=unidrnd(de.d,1,de.nP); ExtraPmElements=sparse(Row,Col,1,de.d,de.nP); PmElements=PmElements|ExtraPmElements; end P0_Elements=~PmElements; Pu(:,RS)=P0(:,RS).*P0_Elements+PmElements.*Pm; %%%need to add penalty!!!!!!!!!!!! %select vector to enter next generation for i=1:de.nP betasPu(:,i)=NSS_betas(Pu(:,i),data); end ParamsPu=vertcat(betasPu,Pu); flag=0; for i=1:de.nP %for j=1:dates %Ftemp=feval(OF,Pu(:,i)',data,j); Ftemp=OF(ParamsPu(:,i)',data); %end %Ftemp=OF(Pu(:,i),data); Ptemp=pen(Pu(:,i),de,F(i)); Ftemp=Ftemp+Ptemp; if Ftemp<=F(i); P1(:,i)=Pu(:,i); F(i)=Ftemp; if Ftemp < Fbest Fbest=Ftemp; xbest=ParamsPu(:,i); flag=1; end else P1(:,i)=P0(:,i); end end if flag Fbv(g)=Fbest; end end output.Fbest=Fbest; output.xbest=xbest; output.Fbv=Fbv; end function penVal=pen(mP,pso,vF) minV=pso.min; maxV=pso.max; ww=pso.ww; A=mP-maxV; A=A+abs(A); B=minV-mP; B=B+abs(B); C=ww*((mP(1,:)+mP(2,:))-abs(mP(1,:)+mP(2,:))); penVal=ww*sum(A+B,1)*vF-C; end ```