samin syntax error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

samin syntax error

daltonj283
I'm getting a syntax error for the samin function even though I've been using
the exact syntax given in the help command and online. The function I'm
trying to minimize works just fine and has a single input vector, I'm just
not sure what is wrong here.

Global_Bang_Minim.m

T0=[0.74; 0.74; 0.1; .74; .28; .56; .28; .56];
LB=zeros(8,1);
UB=(.75)*ones(8,1);
nt=100;
ns=100;
rt=1e-3;
maxevals=1e8;
neps=1000;
functol=1e-7;
paramtol=1e-7;
verbosity=2;
minarg=1;
[t,Er,con,details]=samin(“Bangcost”,{T0},{LB,UB,nt,ns,rt,maxevals,neps,functol,paramtol,verbosity,minarg})

Command Line:
>>Global_Bang_Minim
parse error near line 15 of file /Users/admin/Documents/Global_Bang_Minim.m

  syntax error

>>> [t,Er,con,details]=samin(“Bangcost”,{T0},{LB,UB,nt,ns,rt,maxevals,neps,functol,paramtol,verbosity,minarg})
                                                                                           
^




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: samin syntax error

daltonj283
The error actually points just under the last bracket just after minarg.



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: samin syntax error

mmuetzel
In reply to this post by daltonj283
If this isn't caused by pasting to nabble, the error might be caused by the
pretty quotation marks around “Bangcost”. Please, try with 'Bangcost' or
"Bangcost". Those are the two kinds of strings Octave understands.



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: samin syntax error

daltonj283
Ok I understand where that was coming from, I was using Text Editor to edit my scripts and it gave me those fancy quotation marks. Octave is now running my global minimization script but it's taking a very long time and hasn't printed out any "temperatures." It may be because of the use of the unique function in Bangcost. When I was using Matlab I had to use their uniquetol function because Matlab was reading numbers with a lot of decimals as different when they were really the same, and then trying to solve my ode over a time interval of 0, eventually erroring out after hours of trying to solve it. Here are the functions I'm using for this:

function Er=Bangcost(T)
  tf=.75;
  N=[1 1 1 1 2 2];
  Y0=[1; 0; 0];
  Ts=[T; tf];
  Tsu=unique(Ts);
  Tsu(Tsu==0)=[];
  n=1;
  a=0;
  while (n <= length(Tsu))
    [Ti,Y]=ode45(@(t,y)bangodefun(t,y,T,N),[a Tsu(n)],Y0);
    S=length(Ti);
    Y0=Y(S,:).';
    a=Tsu(n);
    n++;
  endwhile
  YT=(1/sqrt(3))*[1; 1; 1];
  Er=1-((Y0.'*YT)*(Y0.'*YT)');
endfunction

function dydt=bangodefun(t,y,T,N)
  X=[Delta1(t,T(1:N(1))); Delta2(t,T(N(1)+1:sum(N(1:2)))); Delta3(t,T(sum(N(1:2))+1:sum(N(1:3)))); Delta4(t,T(sum(N(1:3))+1:sum(N(1:4)))); Delta5(t,T(sum(N(1:4))+1:sum(N(1:5)))); Delta6(t,T(sum(N(1:5))+1:sum(N(1:6))))];
  H=Hamil(X);
  dydt=-i*H*y;
endfunction

function [ H ] = Hamil( X )
  H=[X(1)+X(2)-X(3) -2*X(5) -2*X(6); -2*X(5) X(1)-X(2)+X(3) -2*X(4); -2*X(6) -2*X(4) X(2)-X(1)+X(3)];
endfunction

function [B1]=Delta1(t,tB1)
  n1=length(tB1);
  tsB1=sort(tB1);
  n=1;
  while n<=n1
    if t<=tsB1(n)
        B1=(1+(-1)^(n))/2;
        n=n1+1;
    elseif t>tsB1(n1)
        B1=mod(n1,2);
        n=n1+1;
    else
        n=n+1;
    end
  end
end

function [B2]=Delta2(t,tB2)
  n2=length(tB2);
  tsB2=sort(tB2);
  n=1;
  while n<=n2
    if t<=tsB2(n)
        B2=(1+(-1)^(n))/2;
        n=n2+1;
    elseif t>tsB2(n2)
        B2=mod(n2,2);
        n=n2+1;
    else
        n=n+1;
    end
  end
end

function [B3]=Delta3(t,tB3)
  n3=length(tB3);
  tsB3=sort(tB3);
  n=1;
  while n<=n3
    if t<=tsB3(n)
        B3=(1+(-1)^(n))/2;
        n=n3+1;
    elseif t>tsB3(n3)
        B3=mod(n3,2);
        n=n3+1;
    else
        n=n+1;
    end
  end
end

function [J1]=Delta4(t,tJ1)
  n4=length(tJ1);
  tsJ1=sort(tJ1);
  n=1;
  while n<=n4
    if t<=tsJ1(n)
        J1=(1+(-1)^(n))/2;
        n=n4+1;
    elseif t>tsJ1(n4)
        J1=mod(n4,2);
        n=n4+1;
    else
        n=n+1;
    end
  end
end

function J2=Delta5(t,tJ2)
  n5=length(tJ2);
  tsJ2=sort(tJ2);
  n=1;
  while (n <= n5)
    if t<=tsJ2(n)
        J2=(1+(-1)^(n+1))/2;
        n=n5+1;
    elseif t>tsJ2(n5)
        J2=-1*(mod(n5,2)-1);
        n=n5+1;
    else
        n=n+1;
    endif
  endwhile
endfunction

function [J3]=Delta6(t,tJ3)
  n6=length(tJ3);
  tsJ3=sort(tJ3);
  n=1;
  while n<=n6
    if t<=tsJ3(n)
        J3=(1+(-1)^(n+1))/2;
        n=n6+1;
    elseif t>tsJ3(n6)
        J3=-1*(mod(n6,2)-1);
        n=n6+1;
    else
        n=n+1;
    endif
  endwhile
endfunction





Thanks,
Dalton

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: samin syntax error

daltonj283
Also will Octave keep running if I shut my computer/it enters sleep mode? I have a Mac btw.

Dalton

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave