“Wie man den Matlab -Code in Python umwandelt” Code-Antworten

Matlab nach Python

Install SMOP:

$ git clone https://github.com/victorlei/smop
$ cd smop
$ python setup.py install --user

then run:
$ smop file.m
this will convert file.m in file.py
MitchAloha

Wie man Matlab -Skripte in Python umwandelt

matlab code  to python 
Wide-eyed Willet

Wie man den Matlab -Code in Python umwandelt

% Grey Wolf Optimizer
function [Alpha_score,Alpha_pos,Convergence_curve]=GWO(SearchAgents_no,Max_iter,lb,ub,dim,fobj)
% initialize alpha, beta, and delta_pos
Alpha_pos=zeros(1,dim);
Alpha_score=inf; %change this to -inf for maximization problems

Beta_pos=zeros(1,dim);
Beta_score=inf; %change this to -inf for maximization problems

_
            
Gadisa Dagne

Wie man den Matlab -Code in Python umwandelt

        % Update Alpha, Beta, and Delta
        if fitness<Alpha_score
            Alpha_score=fitness; % Update alpha
            Alpha_pos=Positions(i,:);
        end
        
        if fitness>Alpha_score && fitness<Beta_score
            Beta_score
Gadisa Dagne

Wie man den Matlab -Code in Python umwandelt

Delta_pos=zeros(1,dim);
Delta_score=inf; %change this to -inf for maximization problems

%Initialize the positions of search agents
Positions=initialization(SearchAgents_no,dim,ub,lb);
Convergence_curve=zeros(1,Max_iter);
velocity = .3*randn(SearchAgents_no,dim) ;
w=0.5+rand()/2;
l=0;% Loop counter

% Main loop
while l<Max_iter
    for i=1:size(Positions,1)
        
        % Return back the search agents that go beyond the boundaries of the search space
        Flag4ub=Positions(i,:)>ub;
        Flag4lb=Positions(i,:)<lb;
        Positions(i,:)=(Positions(i,:).*(~(Flag4ub+Flag4lb)))+ub.*Flag4ub+lb.*Flag4lb;
        
        % Calculate objective function for each search agent
        fitness=fobj(Positions(i,:));
        
        
Gadisa Dagne

Ähnliche Antworten wie “Wie man den Matlab -Code in Python umwandelt”

Fragen ähnlich wie “Wie man den Matlab -Code in Python umwandelt”

Weitere verwandte Antworten zu “Wie man den Matlab -Code in Python umwandelt” auf Java

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen