Home > RAVEN > checkSolution.m

checkSolution

PURPOSE ^

Checks if a solution from Mosek is feasible and optimal

SYNOPSIS ^

function [isFeasible isOptimal]=checkSolution(res)

DESCRIPTION ^

   Checks if a solution from Mosek is feasible and optimal

   res             the output structure from mosekopt

   isFeasible      true if the solution is feasible
   isoptimal       true if the solution is optimal

   This function also throws an error if the license has expired.

   Usage: [isFeasible isOptimal]=checkSolution(res)

   Rasmus Agren, 2013-07-05

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [isFeasible isOptimal]=checkSolution(res)
0002 %   Checks if a solution from Mosek is feasible and optimal
0003 %
0004 %   res             the output structure from mosekopt
0005 %
0006 %   isFeasible      true if the solution is feasible
0007 %   isoptimal       true if the solution is optimal
0008 %
0009 %   This function also throws an error if the license has expired.
0010 %
0011 %   Usage: [isFeasible isOptimal]=checkSolution(res)
0012 %
0013 %   Rasmus Agren, 2013-07-05
0014 %
0015 
0016 if res.rcode==1001
0017     throw(MException('','The Mosek licence has expired'));
0018 end
0019 if res.rcode==1008
0020     throw(MException('','The Mosek licence file is missing'));
0021 end
0022 if res.rcode==1010
0023     throw(MException('','The Mosek licence used only supports small problems (up to 300 variables). Have you requested the correct licence?'));
0024 end
0025 isFeasible=false;
0026 isOptimal=false;
0027 if isfield(res,'sol')
0028     if isfield(res.sol,'bas')
0029         %There are several types of infeasibilities, but I consider them
0030         %all to be the same
0031         if isempty(strfind(res.sol.bas.prosta,'INFEASIBLE'))
0032             isFeasible=true;
0033         end
0034         %There are several types of optimality, but I consider them all to
0035         %be the same
0036         if any(strfind(res.sol.bas.solsta,'OPTIMAL'))
0037             isOptimal=true;
0038         end
0039     else
0040         if isfield(res.sol,'int')
0041             %There are several types of infeasibilities, but I consider them
0042             %all to be the same
0043             if isempty(strfind(res.sol.int.prosta,'INFEASIBLE'))
0044                 isFeasible=true;
0045             end
0046             %There are several types of optimality, but I consider them all to
0047             %be the same
0048             if any(strfind(res.sol.int.solsta,'OPTIMAL'))
0049                 isOptimal=true;
0050             end
0051         else
0052             %This is when the interior point solver is used. That is currently
0053             %not the case
0054             return;
0055         end
0056     end
0057 end
0058 end

Generated on Tue 16-Jul-2013 21:50:02 by m2html © 2005