%Main-file for calculating external stimuli for a regulatory network
%causing a switch between two steady states of the regulatory network
%For details see corresponding paper
%Date Dec 21, 2017

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Parameters determined by the network
%numNodes:     	Number of nodes of the network 
%numControls:  	Number of controls of the network
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Parameters determined by the user
%timeInterval:  Number, time discretization for the ordinary differential equations
%timeHorizon:   Number, time duration, [0, timeHorizon], in which network is simulated
%alpha:         Number, Weights the contribution of the controls to the target functional
%initialState:  1 x numNodes row vector, The steady state the network is in at the beginning, that is time t=0
%finalState:    1 x numNodes row vector, The steady state in which the network is expected to be at the latest at the final time, t=timeHorizon

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%tol1=10^-1;         %Tolerance for |x(i)-xd(i)|<tol1 for i=1,...,numNodes at the final time timeHorizon, input for the function combinatorial_method
%tol2=10^-6;         %Tolerance for the stopping criterion for the sequential quadratic Hamiltonian method, input in function SQH_method
%tol3=10^-4;         %Tolerance for the stopping criterion for the projected gradient method, input in function projected_gradient_method
%T_int=10^-1;        %Tolerance to determine smallest duration of application of external stimuli causing a switch, combinatorial_method         
%max_Num=4;          %Input in function combinatorial_method, Maximum number of external stimuli applied at once to the network in order to find a set of external stimuli that cause the desired switch, max_Num = 1,...,numControls
%max_iter=10000;     %Maximum number of updates on the control for the sequential quadratic Hamiltonian method or maximum number of iterations of the projected gradient method

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%flags
%combi_method=1;                 %If flag equals 1, a combinatorial search with the function combinatorial_method by trial and error search is performed in ordert to determine external stimuli causing the desired switch, if flag equals 0 it is not performed
%local_optimization_method=1;    %If flag equals 0, no local optimization method is performed, if local_optimization_method equals 1, then the sequential quadratic Hamiltonian (SQH) method is performed, if local_optimization_method equals 2, then a projected gradient method is performed

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Variables
%x:         numNodes x ((timeHorizon/timeInterval)+1)-matrix, state of the network, row i corresponds 
%           to the  node i, i=1,...,numNodes, column j corresponds to
%           the time t=(j-1)*timeInterval, j=1,...,((timeHorizon/timeInterval)+1), entry (i,j) corresponds to value x(i) of the i-th
%           node at time t=(j-1)*timeInterval
%xd:        numNodes x ((timeHorizon/timeInterval)+1)-matrix, Desired state
%           of the netword at final time timeHorizon, row i corresponds to the desired
%           state of node i, i=1,...,numNodes, column j corresponds to the time 
%           t=(j-1)*timeInterval, j=1,...,((timeHorizon/timeInterval)+1), entry (i,j) value of the i-th
%           desired state xd(i) of node i at time t=(j-1)*timeInterval
%u:         numControls x (timeHorizon/timeInterval)-matrix, external stimuli, row
%           i corresponds to the external stimulus u(i), i=1,...,numControls, column j
%           corresponds to the time t=(j-1)*timeInterval,
%           j=1,...,(timeHorizon/timeInterval), entry (i,j) value of the i-th
%           external stimulus u(i) at time t=(j-1)*timeInterval
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
