% Example demonstrates how to optimize Relative Entropy with linear % constraints using Riskprog subroutine. % Discrete distribution with 100,000 atoms (variables) is estimated. clear; % load data load 'Data_CS_Entropyr'; % set number of variables for result verification I = 100000; % set solver parameters in internal structure "stroptions". stroptions.Linearization = 'On'; stroptions.Precision = 9; stroptions.Solver = 'BULDOZER'; % optimize problem [p_res, fval, status, output] = riskprog ('entropyr', [], p', [],[],[],[],[], Aeq , beq, lb,[], '', stroptions); % timing fprintf('Data loading time = %f sec.\n', output.data_loading_time); fprintf('Preprocessing time = %f sec.\n', output.preprocessing_time); fprintf('Solving time = %f sec.\n', output.solving_time); % display optimization result fprintf('Objective value from Riskprog = %.10f\n', fval); % verify result val_optimal = 0.0; for i=1:I val_optimal = val_optimal + p_res(i)*log(p_res(i)/p(i)); end % display verification result fprintf('Objective calculated for verification = %.10f\n', val_optimal); %=======================================================================| %American Optimal Decisions, Inc. Copyright | %Copyright ©American Optimal Decisions, Inc. 2007-2014. | %American Optimal Decisions (AOD) retains copyrights to this material. | % | %Permission to reproduce this document and to prepare derivative works | %from this document for internal use is granted, provided the copyright | %and “No Warranty” statements are included with all reproductions | %and derivative works. | % | %For information regarding external or commercial use of copyrighted | %materials owned by AOD, contact AOD at support@aorda.com. | %=======================================================================|