Example: Function call: buyin(0.001,matrix_1).Parameter = 0.001 and matrix_1:

 

x1

x2

x3

x4

0.5

1.3

1

1

1.1

0.9

1

1

2.5

0.01

1

1

0.002

1

1

1

 

at point_1:

 

component_name

value

x1

x2

x3

x4

-1

0

1

-1

 

 

MATLAB code (.\Aorda\PSG\MATLAB\Examples\Func_value_buyin.m) for function calculation:

 

%Define data:

H1 = [0.5 1.1 2.5 0.002;1.3 0.9 0.01 1;1 1 1 1;1 1 1 1];

a = [-1;0;1;-1];

alpha = 0.001;

 

%=======================================================================

%Calculation of function with PSG Subroutine 'functionvalue'

%Calculate buyin function with parameter 0.001 at point 'a':

val1 = functionvalue('buyin', alpha, H1, [], [], a);

%Display function value:

disp(sprintf('functionvalue = %g', val1));

%=======================================================================

%Calculation of function with PSG Subroutine 'tbpsg_function_value'

%Create the PSG matrix 'matrix_1'(structure containing header and matrix body) and pack it to structure 'toolboxstruc_arr':

toolboxstruc_arr(1) = tbpsg_matrix_pack('matrix_1', H1, [],  [], []);

%Create the PSG point 'point_1'(structure containing header and matrix body) and pack it to structure 'toolboxstruc_arr':

toolboxstruc_arr(2) = tbpsg_point_pack('point_1', a, []);

%Create the PSG parameter 'parameter_alpha' and pack it to structure 'toolboxstruc_arr':

toolboxstruc_arr(3) = tbpsg_parameter_pack('parameter_alpha', alpha);

%Calculate buyin function with parameter 0.001 at point 'point_1':

val2 = tbpsg_function_value('buyin(parameter_alpha,matrix_1)','point_1',toolboxstruc_arr);

%Display function value:

disp(sprintf('tbpsg_function_value = %g', val2));

%=======================================================================

%Creation of User Subroutine for calculating function value

%User subroutine is similar to the 'functionvalue'

%Create problem statement:

problem_statement = sprintf('%s\n',...

'calculate',...

'Point: point_1',...

'  buyin(parameter_alpha,matrix_1)',...

' ');

%Create Subroutine:

tbpsg_create_user_subroutine(problem_statement,toolboxstruc_arr,'.\','calculate_buyin');

%Uncomment section to call the user subroutine 'calculate_buyin':

%{

%Calculation of function with User Subroutine 'calculate_buyin':

[solution_str,outargstruc_arr] = calculate_buyin(H1,matrix_1_vars,a,point_1_vars,alpha);

%Extract function value from the solution report:

val = tbpsg_function_data(solution_str, outargstruc_arr);

%}

 

Program output:

 

functionvalue = 3

tbpsg_function_value = 3