function varargout = frontend_gloptipoly(varargin) % FRONTEND_GLOPTIPOLY M-file for frontend_gloptipoly.fig % FRONTEND_GLOPTIPOLY, by itself, creates a new FRONTEND_GLOPTIPOLY or raises the existing % singleton*. % % H = FRONTEND_GLOPTIPOLY returns the handle to a new FRONTEND_GLOPTIPOLY or the handle to % the existing singleton*. % % FRONTEND_GLOPTIPOLY('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in FRONTEND_GLOPTIPOLY.M with the given input arguments. % % FRONTEND_GLOPTIPOLY('Property','Value',...) creates a new FRONTEND_GLOPTIPOLY or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before frontend_gloptipoly_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to frontend_gloptipoly_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help frontend_gloptipoly % Last Modified by GUIDE v2.5 09-Jan-2007 13:58:35 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @frontend_gloptipoly_OpeningFcn, ... 'gui_OutputFcn', @frontend_gloptipoly_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT global out; global sed; % --- Executes just before frontend_gloptipoly is made visible. function frontend_gloptipoly_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to frontend_gloptipoly (see VARARGIN) % Choose default command line output for frontend_gloptipoly handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes frontend_gloptipoly wait for user response (see UIRESUME) % uiwait(handles.figure1); clear P; clear poly; clear pars; pars.fid=0; % --- Outputs from this function are returned to the command line. function varargout = frontend_gloptipoly_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes when user attempts to close frontend_gloptipoly. function frontend_gloptipoly_CloseRequestFcn(hObject, eventdata, handles) % hObject handle to warn_self (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) delete(handles.figure1); % --- Executes on button press in pushbutton_calc. function pushbutton_calc_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_calc (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global out; global sed; clear P; clear lasterror; global P; % get variables vars=get(handles.edit_vars,'String'); try %remove trailing whitespaces pat = '[\ ]*$'; vars=regexprep(vars, pat, ''); %remove leading whitespaces pat = '^[\ ]'; vars=regexprep(vars, pat, ''); % make a comma and a space separated list of them pat = '[,;\ ]*'; varsListString = regexprep(vars, pat, ','); varsListString2= regexprep(vars, pat, ' '); catch, warn('string','wrong format in variables field (use space separeted list).','title','parse error'); uicontrol(handles.edit_vars); return; end; try eval(['syms ',varsListString2]);, catch, warn('string','wrong format in variables field (use space separeted list).','title','parse error'); uicontrol(handles.edit_vars); return; end; try eval(['varsList= [',varsListString,'];']);, catch, warn('string','wrong format in variables field (use space separeted list).','title','parse error'); uicontrol(handles.edit_vars); return; end; % get scaling scale=get(handles.edit_scaling,'String'); try %remove trailing whitespaces pat = '[\ ]*$'; scale=regexprep(scale, pat, ''); %remove leading whitespaces pat = '^[\ ]'; scale=regexprep(scale, pat, ''); % make a comma and a space separated list of them pat = '[,;\ ]*'; scaleListString = regexprep(scale, pat, ','); catch, warn('string','wrong format in variables field (use space separeted list).','title','parse error'); uicontrol(handles.edit_scaling); return; end; if ~strcmp(scale,''), try eval(['scaleList=[',scaleListString,'];']);, catch, warn('string','wrong format in scale field (use space separeted list of numbers).','title','parse error'); uicontrol(handles.edit_scaling); return; end; for item= scaleList if ~isa(item,'numeric'), warn('string','non number in scale field (use space separeted list of numbers).','title','parse error'); uicontrol(handles.edit_scaling); return; end; end; tmp1=size(scaleList); tmp1=tmp1(2); tmp2=size(varsList); tmp2=tmp2(2); if tmp1>tmp2, scaleList=scaleList(1,1:tmp2); elseif tmp10, pars.eps=eps; end; else, warn('string','wrong format in sedumi option epsilon (use a number).','title','parse error'); uicontrol(handles.text_sedumiEps); return; end; % radius=get(handles.edit_sedumiRadius,'String'); % try % remove trailing whitespaces % pat = '[\ ]*$'; radius=regexprep(radius, pat, ''); % remove leading whitespaces % pat = '^[\ ]'; radius=regexprep(radius, pat, ''); % if ~strcmp(radius,''), % radius=eval(radius); % else % radius=[]; % end; % catch, % warn('string','wrong format in sedumi option radius (use a number).','title','parse error'); % uicontrol(handles.edit_sedumiRadius); % return; % end; % % % if isa(radius,'numeric'), % if length(radius)>0, % pars.radius=radius; % end; % else, % warn('string','wrong format in sedumi option radius (use a number2).','title','parse error'); % uicontrol(handles.edit_sedumiRadius); % return; % end; ranktol=get(handles.edit_sedumiRanktol,'String'); try %remove trailing whitespaces pat = '[\ ]*$'; ranktol=regexprep(ranktol, pat, ''); %remove leading whitespaces pat = '^[\ ]'; ranktol=regexprep(ranktol, pat, ''); if ~strcmp(ranktol,''), ranktol=eval(ranktol); else ranktol=[]; end; catch, warn('string','wrong format in option rank tol. (use a number).','title','parse error'); uicontrol(handles.edit_sedumiRanktol); return; end; if isa(ranktol,'numeric'), if length(ranktol)>0, pars.ranktol=ranktol; end; else, warn('string','wrong format in sedumi option rank tol. (use a number2).','title','parse error'); uicontrol(handles.edit_sedumiRanktol); return; end; sedumi_fid=get(handles.radiobutton_sedumiout_show,'Value'); if sedumi_fid==0, pars.fid=0; end; poly=get(handles.edit_poly,'String'); max =get(handles.popupmenu_task,'Value'); n =1+get(handles.popupmenu_order,'Value'); set(handles.pushbutton_check,'Enable','off'); try dummy=eval(poly);, catch, warn('string','Target function is not a polynomial in the given variables.','title','parse error'); uicontrol(handles.edit_poly); return; end; disp(' '); disp('==========================================================================='); try if max==1, P{1}=defipoly(['min ',poly], varsListString); else, P{1}=defipoly(['max ',poly], varsListString); end; catch, warn('string','Error while calling defipoly. Wrong tokens in polynomial?','title','parse error'); uicontrol(handles.edit_poly); return; end; k=1; for i=1:8, edit =eval(['handles.edit_constraints' ,num2str(i)]); box =eval(['handles.checkbox_constraints' ,num2str(i)]); if get(box,'Value')==1 & ~strcmp(get(edit,'String'),''), pop =eval(['handles.popupmenu_constraints',num2str(i)]); if get(pop,'Value')==1, ieq='<= '; elseif get(pop,'Value')==2, ieq='>= '; else ieq='== '; end; k=k+1; poly= get(edit,'String'); pat = '^[\ ]*'; poly=regexprep(poly, pat, ''); pat = '[\ ]*$'; poly=regexprep(poly, pat, ''); if strcmp(poly,''); set(box, 'Value',0); else, try dummy=eval(get(edit,'String')); catch, k=k-1; warn('string',['constraint ',num2str(k),' in line ', num2str(i),' is not a polynomial in the given variables.'],'title','parse error'); uicontrol(edit); return; end; try P{k}=defipoly([ieq,get(edit,'String')], varsListString); catch, k=k-1; warn('string',['error calling defipoly on polynomial constraint ',num2str(k),' line ', num2str(i),'.'],'title','parse error'); uicontrol(edit); return; end; end; end; end; set(handles.text_solverStatus,'String','calling sedumi...'); set(handles.text_value, 'String',' '); set(handles.text_noSols, 'String',' '); drawnow; try [out,sed]=my_gloptipoly(P,n,pars);, catch, try [out,sed]=my_gloptipoly(P,n);, catch, err=lasterror; errMess=err.message; disp(errMess); %remove first line indcatin error origin. pat='^.*\n';errMess=regexprep(errMess, pat, ''); warn('string',['error calling gloptipoly: ',errMess],'title','parse error'); set(handles.text_solverStatus,'String','error'); return; end; end; if out.status==1 | out.status==0, if (out.status==1), set(handles.text_solverStatus,'String', 'solved'); else, set(handles.text_solverStatus,'String', 'lower bound'); end; set(handles.text_value,'String',out.obj); sol=out.sol; noSols=size(sol); noSols=noSols(2); set(handles.text_noSols,'String' ,num2str(noSols)); if noSols>0 set(handles.pushbutton_check,'Enable','on'); tmp.P=P; tmp.sol=out.sol; set(handles.pushbutton_check,'UserData',tmp); disp('solutions:'); disp([out.sol{:}]); else disp('no solutions extracted.'); end; else, set(handles.text_solverStatus,'String','no result'); set(handles.text_value, 'String',' '); set(handles.text_noSols, 'String',' '); end; % --- Executes on button press in pushbutton_clear. function pushbutton_clear_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_clear (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.edit_poly,'String',''); %disp(get(handles.edit_poly,'String')) function edit_poly_Callback(hObject, eventdata, handles) % hObject handle to edit_poly (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_poly as text % str2double(get(hObject,'String')) returns contents of edit_poly as a double % --- Executes during object creation, after setting all properties. function edit_poly_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_poly (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in pushbutton_plot. function pushbutton_plot_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_plot (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) do_plot(handles); function do_plot(handles) % get variables vars=get(handles.edit_vars,'String'); try %remove trailing whitespaces pat = '[\ ]*$'; vars=regexprep(vars, pat, ''); %remove leading whitespaces pat = '^[\ ]'; vars=regexprep(vars, pat, ''); % make a space separated list of them pat = '[,;\ ]*'; varsList2= regexprep(vars, pat, ' '); catch, warn('string','wrong format in variables field (use space separeted list).','title','parse error'); uicontrol(handles.edit_vars); return; end; try eval(['syms ',varsList2]);, catch, warn('string','wrong format in variables field (use space separeted list).','title','parse error'); uicontrol(handles.edit_vars); return; end; % oops this is buggy: % if the number of % spaces in the STRING containing the space separated vars % greater than 1. then there are more than 3 variables. if length(findstr(varsList2, ' '))>1, warn('string','can not plot a polynomial in more than 2 variables.','title','Plot error'); toggle_plotVisible(0,handles); return end; try p=eval(get(handles.edit_poly,'String')); catch, if length(varsList2)<18, warn('string',['input is not a polynomial in the given variables ',varsList2],'title','Plot error'); else warn('string','input is not a polynomial in the given variables','title','Plot error'); end; toggle_plotVisible(0,handles); return end; try xMin=eval(get(handles.edit_xMin,'String')); catch warn('string','plot: min x not well defined','title','Min x not well defined'); uicontrol(handles.edit_xMin); return; end; try xMax=eval(get(handles.edit_xMax,'String')); catch warn('string','plot: max x not well defined','title','Max x not well defined'); uicontrol(handles.edit_xMax); return; end; if xMin==xMax warn('string','plot: max and min x coincide','title','Plot error'); uicontrol(handles.edit_xMax); return; end; try yMin=eval(get(handles.edit_yMin,'String')); catch warn('string','plot: min y not well defined','title','Min y not well defined'); uicontrol(handles.edit_yMin); return; end; try yMax=eval(get(handles.edit_yMax,'String')); catch warn('string','plot: max y not well defined','title','Max y not well defined'); uicontrol(handles.edit_yMax); return; end; if yMin==yMax warn('string','plot: max and min y coincide','title','Plot error'); uicontrol(handles.edit_yMax); return; end; if get(handles.radiobutton_3D_1,'Value')==1, set(handles.axes1, 'Visible','on'); ezsurfc(p,[xMin,xMax,yMin,yMax]); try catch, warn('string','error when plotting','title','Plot error'); toggle_plotVisible(0,handles); return end; else, startValue=get(handles.edit_plotLinesIntervalStart,'String'); try startValue=str2num(startValue);, catch, warn('string','plot: inteval start contains illegal tokens (should be a number).','title','Max y not well defined'); uicontrol(handles.edit_plotLinesIntervalStart); return; end; if ~isa(startValue,'numeric'), warn('string','plot: inteval start contains illegal tokens (should be a number).','title','Max y not well defined'); uicontrol(handles.edit_plotLinesIntervalStart); return; end; endValue=get(handles.edit_plotLinesIntervalEnd,'String'); try endValue=str2num(endValue);, catch, warn('string','plot: inteval end contains illegal tokens (should be a number).','title','Max y not well defined'); uicontrol(handles.edit_plotLinesIntervalEnd); return; end; if ~isa(endValue,'numeric'), warn('string','plot: inteval end contains illegal tokens (should be a number).','title','Max y not well defined'); uicontrol(handles.edit_plotLinesIntervalEnd); return; end; linesNo=get(handles.edit_plotLinesNo,'String'); try linesNo=str2num(linesNo);, catch, warn('string','plot: number of lines contains illegal tokens (should be an integer).','title','Max y not well defined'); uicontrol(handles.edit_plotLinesNo); return; end; if ~isa(linesNo,'numeric') warn('string',[class(linesNo),'plot: number of lines contains illegal tokens (should be an integer).'],'title','Max y not well defined'); uicontrol(handles.edit_plotLinesNo); return; end; linesNo=round(linesNo); if linesNo <=0 linesNo=1; end; if startValue==endValue endValue=startValue+1; end; delta=(endValue-startValue)/linesNo; levelList=startValue: delta :endValue; set(handles.axes1, 'Visible','on'); ezcontour(p,[xMin,xMax,yMin,yMax],90); set(get(gca,'Children'),'LevelList',levelList); set(get(gca,'Children'),'ShowText','on'); end; function toggle_plotVisible(state,handles) if state==0, set(handles.axes1,'Visible','off'); for child=get(handles.axes1,'Children');, try set(child,'Visible','off');, catch, end; end; else, set(handles.axes1,'Visible','on'); for child=get(handles.axes1,'Children');, try set(child,'Visible','on');, catch, end; end; end; % --- Executes on selection change in listbox1. function listbox1_Callback(hObject, eventdata, handles) % hObject handle to listbox1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns listbox1 contents as cell array % contents{get(hObject,'Value')} returns selected item from listbox1 % --- Executes during object creation, after setting all properties. function listbox1_CreateFcn(hObject, eventdata, handles) % hObject handle to listbox1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in popupmenu_order. function popupmenu_order_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_order (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns popupmenu_order contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_order % --- Executes during object creation, after setting all properties. function popupmenu_order_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_order (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end %-------------------------------------------------------------------------- % CONSTRAINTS %-------------------------------------------------------------------------- function activate_constraint(n,state,handles) edit =eval(['handles.edit_constraints' ,num2str(n)]); popup=eval(['handles.popupmenu_constraints',num2str(n)]); check=eval(['handles.checkbox_constraints' ,num2str(n)]); if state~=get(check,'Value') set(check,'Value',state); end; if state==1, set(edit, 'ForegroundColor', [0,0,0]); set(popup,'ForegroundColor', [0,0,0]); else, set(edit, 'ForegroundColor', [0.5,0.5,0.5]); set(popup,'ForegroundColor', [0.5,0.5,0.5]); end; % --- Executes on button press in checkbox_constraints1. function checkbox_constraints1_Callback(hObject, eventdata, handles) % hObject handle to checkbox_constraints1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(1,get(hObject,'Value'),handles); % Hint: get(hObject,'Value') returns toggle state of checkbox_constraints1 function edit_constraints1_Callback(hObject, eventdata, handles) % hObject handle to edit_constraints1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(1,1,handles); % Hints: get(hObject,'String') returns contents of edit_constraints1 as text % str2double(get(hObject,'String')) returns contents of edit_constraints1 as a double % --- Executes during object creation, after setting all properties. function edit_constraints1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_constraints1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in popupmenu_constraints1. function popupmenu_constraints1_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_constraints1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(1,1,handles); % Hints: contents = get(hObject,'String') returns popupmenu_constraints1 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_constraints1 % --- Executes during object creation, after setting all properties. function popupmenu_constraints1_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_constraints1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in checkbox_constraints2. function checkbox_constraints2_Callback(hObject, eventdata, handles) % hObject handle to checkbox_constraints2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(2,get(hObject,'Value'),handles); % Hint: get(hObject,'Value') returns toggle state of checkbox_constraints2 function edit_constraints2_Callback(hObject, eventdata, handles) % hObject handle to edit_constraints2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(2,1,handles); % Hints: get(hObject,'String') returns contents of edit_constraints2 as text % str2double(get(hObject,'String')) returns contents of edit_constraints2 as a double % --- Executes during object creation, after setting all properties. function edit_constraints2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_constraints2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in popupmenu_constraints2. function popupmenu_constraints2_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_constraints2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(2,1,handles); % Hints: contents = get(hObject,'String') returns popupmenu_constraints2 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_constraints2 % --- Executes during object creation, after setting all properties. function popupmenu_constraints2_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_constraints2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in checkbox_constraints3. function checkbox_constraints3_Callback(hObject, eventdata, handles) % hObject handle to checkbox_constraints3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(3,get(hObject,'Value'),handles); % Hint: get(hObject,'Value') returns toggle state of checkbox_constraints3 function edit_constraints3_Callback(hObject, eventdata, handles) % hObject handle to edit_constraints3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(3,1,handles); % Hints: get(hObject,'String') returns contents of edit_constraints3 as text % str2double(get(hObject,'String')) returns contents of edit_constraints3 as a double % --- Executes on selection change in popupmenu_constraints3. function popupmenu_constraints3_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_constraints3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(3,1,handles); % Hints: contents = get(hObject,'String') returns popupmenu_constraints3 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_constraints3 % --- Executes during object creation, after setting all properties. function popupmenu_constraints3_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_constraints3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in checkbox_constraints4. function checkbox_constraints4_Callback(hObject, eventdata, handles) % hObject handle to checkbox_constraints4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(4,get(hObject,'Value'),handles); % Hint: get(hObject,'Value') returns toggle state of checkbox_constraints4 function edit_constraints4_Callback(hObject, eventdata, handles) % hObject handle to edit_constraints4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(4,1,handles); % Hints: get(hObject,'String') returns contents of edit_constraints4 as text % str2double(get(hObject,'String')) returns contents of edit_constraints4 as a double % --- Executes during object creation, after setting all properties. function edit_constraints4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_constraints4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in popupmenu_constraints4. function popupmenu_constraints4_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_constraints4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(4,1,handles); % Hints: contents = get(hObject,'String') returns popupmenu_constraints4 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_constraints4 % --- Executes during object creation, after setting all properties. function popupmenu_constraints4_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_constraints4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in checkbox_constraints5. function checkbox_constraints5_Callback(hObject, eventdata, handles) % hObject handle to checkbox_constraints5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(5,get(hObject,'Value'),handles); % Hint: get(hObject,'Value') returns toggle state of checkbox_constraints5 function edit_constraints5_Callback(hObject, eventdata, handles) % hObject handle to edit_constraints5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(5,1,handles); % Hints: get(hObject,'String') returns contents of edit_constraints5 as text % str2double(get(hObject,'String')) returns contents of edit_constraints5 as a double % --- Executes during object creation, after setting all properties. function edit_constraints5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_constraints5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in popupmenu_constraints5. function popupmenu_constraints5_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_constraints5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(5,1,handles); % Hints: contents = get(hObject,'String') returns popupmenu_constraints5 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_constraints5 % --- Executes during object creation, after setting all properties. function popupmenu_constraints5_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_constraints5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in checkbox_constraints6. function checkbox_constraints6_Callback(hObject, eventdata, handles) % hObject handle to checkbox_constraints6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(6,get(hObject,'Value'),handles); % Hint: get(hObject,'Value') returns toggle state of checkbox_constraints6 function edit_constraints6_Callback(hObject, eventdata, handles) % hObject handle to edit_constraints6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(6,1,handles); % Hints: get(hObject,'String') returns contents of edit_constraints6 as text % str2double(get(hObject,'String')) returns contents of edit_constraints6 as a double % --- Executes during object creation, after setting all properties. function edit_constraints6_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_constraints6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in popupmenu_constraints6. function popupmenu_constraints6_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_constraints6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(6,1,handles); % Hints: contents = get(hObject,'String') returns popupmenu_constraints6 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_constraints6 % --- Executes during object creation, after setting all properties. function popupmenu_constraints6_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_constraints6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in checkbox_constraints7. function checkbox_constraints7_Callback(hObject, eventdata, handles) % hObject handle to checkbox_constraints7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(7,get(hObject,'Value'),handles); % Hint: get(hObject,'Value') returns toggle state of checkbox_constraints7 function edit_constraints7_Callback(hObject, eventdata, handles) % hObject handle to edit_constraints7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(7,1,handles); % Hints: get(hObject,'String') returns contents of edit_constraints7 as text % str2double(get(hObject,'String')) returns contents of edit_constraints7 as a double % --- Executes during object creation, after setting all properties. function edit_constraints7_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_constraints7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in popupmenu_constraints7. function popupmenu_constraints7_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_constraints7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(7,1,handles); % Hints: contents = get(hObject,'String') returns popupmenu_constraints7 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_constraints7 % --- Executes during object creation, after setting all properties. function popupmenu_constraints7_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_constraints7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in checkbox_constraints8. function checkbox_constraints8_Callback(hObject, eventdata, handles) % hObject handle to checkbox_constraints8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(8,get(hObject,'Value'),handles); % Hint: get(hObject,'Value') returns toggle state of checkbox_constraints8 function edit_constraints8_Callback(hObject, eventdata, handles) % hObject handle to edit_constraints8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(8,1,handles); % Hints: get(hObject,'String') returns contents of edit_constraints8 as text % str2double(get(hObject,'String')) returns contents of edit_constraints8 as a double % --- Executes during object creation, after setting all properties. function edit_constraints8_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_constraints8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in popupmenu_constraints8. function popupmenu_constraints8_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_constraints8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) activate_constraint(8,1,handles); % Hints: contents = get(hObject,'String') returns popupmenu_constraints8 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_constraints8 % --- Executes during object creation, after setting all properties. function popupmenu_constraints8_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_constraints8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end %-------------------------------------------------------------------- % --- Executes on button press in pushbutton_clearAll. function pushbutton_clearAll_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_clearAll (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) for i=1:8, activate_constraint(i,0,handles); edit =eval(['handles.edit_constraints' ,num2str(i)]); set(edit,'String',''); end; % --- Executes on button press in pushbutton_clearActive. function pushbutton_clearActive_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_clearActive (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) for i=1:8, box =eval(['handles.checkbox_constraints' ,num2str(i)]); if get(box,'Value')==1, activate_constraint(i,0,handles); edit =eval(['handles.edit_constraints' ,num2str(i)]); set(edit,'String',''); end; end; % --- Executes on button press in pushbutton_activateAll. function pushbutton_activateAll_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_activateAll (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) for i=1:8, edit =eval(['handles.edit_constraints' ,num2str(i)]); if ~strcmp(get(edit, 'String'),''), activate_constraint(i,1,handles); end; end; % --- Executes on button press in pushbutton_deactivateAll. function pushbutton_deactivateAll_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_deactivateAll (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) for i=1:8, activate_constraint(i,0,handles); end; % --- Executes on slider movement. function slider_sedumiEps_Callback(hObject, eventdata, handles) % hObject handle to slider_sedumiEps (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) val=get(hObject,'Value'); if val>0 & val<1, %val=10^(-round(10*val)/10); val=10^(-(10-round(10*val))); end; set(handles.text_sedumiEps,'String',num2str(val)); % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider % --- Executes during object creation, after setting all properties. function slider_sedumiEps_CreateFcn(hObject, eventdata, handles) % hObject handle to slider_sedumiEps (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end % --- Executes on selection change in popupmenu_task. function popupmenu_task_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_task (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns popupmenu_task contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_task % --- Executes during object creation, after setting all properties. function popupmenu_task_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_task (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in popupmenu_load. function popupmenu_load_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_load (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) example=get(hObject,'Value'); doPlot=0; example_name=get(hObject,'String'); example_name=example_name{example}; is_delimiter = strncmp(example_name, '-----', 5); if example ~=1 & is_delimiter ~=1 toggle_plotVisible(0,handles); set(handles.pushbutton_check,'Enable','off'); set(handles.text_solverStatus,'String',''); set(handles.text_value,'String',''); set(handles.text_noSols,'String',''); set(handles.edit_sedumiRanktol,'String',''); set(handles.text_sedumiEps,'String',''); set(handles.radiobutton_sedumiout_hide,'Value',1); % set(handles.edit_sedumiRadius,'String',''); set(handles.edit_scaling,'String',''); set(handles.text_sedumiEps,'String',0); for i=1:8, edit =eval(['handles.edit_constraints' ,num2str(i)]); set(edit,'String',''); activate_constraint(i,0,handles); pop =eval(['handles.popupmenu_constraints', num2str(i)]); set(pop,'Value',1); end; set(handles.edit_xMin,'String',''); set(handles.edit_xMax,'String',''); set(handles.edit_yMin,'String',''); set(handles.edit_yMax,'String',''); else, set(hObject,'Value',1); return; end; % (MOTZKIN unconst) if example==2, set(handles.edit_poly,'String','1 -3*x^2*y^2 +x^4*y^2 +x^2*y^4'); set(handles.popupmenu_order,'Value',2); set(handles.edit_vars,'String', 'x y'); set(handles.edit_constraints1,'String','2 -x^2 -y^2'); activate_constraint(1,0,handles); set(handles.edit_vars,'String', 'x y'); % plotting doPlot=1; set(handles.radiobutton_3D_1,'Value',1); set(handles.edit_xMin,'String','-1.25'); set(handles.edit_xMax,'String',' 1.25'); set(handles.edit_yMin,'String','-1.25'); set(handles.edit_yMax,'String',' 1.25'); % (MOTZKIN FORM) elseif example==3, set(handles.edit_vars,'String', 'x y z'); set(handles.edit_poly,'String','z^6 -3*x^2*y^2*z^2 +x^4*y^2 +x^2*y^4'); set(handles.popupmenu_order,'Value',2); set(handles.edit_constraints1,'String','2 -x^2 -y^2 -z^2'); doPlot=0; % (MOTZKIN PERT) elseif example==4, set(handles.edit_vars,'String', 'x y'); set(handles.edit_poly,'String','1 +x^2*y^2*(x^2+y^2-3) + 10^(-2)*(x^8+y^8)'); set(handles.popupmenu_order,'Value',3); % set(handles.edit_constraints1,'String','4*x^3*y^2 +2*x*y^4-6*x*y^2 +8*10^(-2)*x^7'); % activate_constraint(1,0,handles); % set(handles.popupmenu_constraints1, 'Value',3); % set(handles.edit_constraints2,'String','4*x^2*y^3 +2*x^4*y-6*x^2*y +8*10^(-2)*y^7'); % activate_constraint(2,0,handles); % set(handles.popupmenu_constraints2, 'Value',3); % plotting doPlot=1; set(handles.radiobutton_3D_1,'Value',1); set(handles.edit_xMin,'String','-1.25'); set(handles.edit_xMax,'String',' 1.25'); set(handles.edit_yMin,'String','-1.25'); set(handles.edit_yMax,'String',' 1.25'); % (MOTZKIN GRAD) elseif example==5, set(handles.edit_vars,'String', 'x y'); set(handles.edit_poly,'String','1 +x^2*y^2*(x^2+y^2-3) '); set(handles.popupmenu_order,'Value',3); set(handles.edit_constraints1,'String','4*x^3*y^2 +2*x*y^4-6*x*y^2 +8*10^(-2)*x^7'); activate_constraint(1,1,handles); set(handles.popupmenu_constraints1, 'Value',3); set(handles.edit_constraints2,'String','4*x^2*y^3 +2*x^4*y-6*x^2*y +8*10^(-2)*y^7'); activate_constraint(2,1,handles); set(handles.popupmenu_constraints2, 'Value',3); % plotting doPlot=1; set(handles.radiobutton_3D_1,'Value',1); set(handles.edit_xMin,'String','-1.25'); set(handles.edit_xMax,'String',' 1.25'); set(handles.edit_yMin,'String','-1.25'); set(handles.edit_yMax,'String',' 1.25'); % (ROBINSON) elseif example==6, set(handles.edit_vars,'String', 'x y'); set(handles.edit_poly,'String',['x^2*(x^2-1)^2 +y^2*(y^2-1)^2 -(x^2-1)*(y^2-1)*(x^2+y^2-1)']); set(handles.popupmenu_order,'Value',2); set(handles.edit_constraints1,'String','1 -x^2-y^2'); activate_constraint(1,1,handles); set(handles.edit_constraints2,'String','2 -x^2-y^2'); % plotting doPlot=1; set(handles.radiobutton_3D_1,'Value',1); set(handles.edit_xMin,'String','-1.15'); set(handles.edit_xMax,'String','1.15'); set(handles.edit_yMin,'String','-1.15'); set(handles.edit_yMax,'String','1.15'); % example 7 =-------------------------------- % DUAL GAP elseif example==8, set(handles.edit_vars,'String', 'x y'); set(handles.edit_poly,'String','x*y'); set(handles.popupmenu_order,'Value',2); set(handles.edit_constraints1,'String','y^2'); set(handles.popupmenu_constraints1,'Value',1); activate_constraint(1,1,handles); set(handles.popupmenu_constraints1,'Value',2); set(handles.edit_constraints2,'String','1+x'); set(handles.popupmenu_constraints2,'Value',1); activate_constraint(2,1,handles); set(handles.edit_constraints3,'String','1-x'); set(handles.popupmenu_constraints3,'Value',1); activate_constraint(3,1,handles); % plotting doPlot=0; % (ex1) elseif example==9, set(handles.edit_vars,'String', 'x y'); set(handles.edit_poly,'String',['-x -y']); set(handles.popupmenu_order,'Value',3); set(handles.edit_constraints1,'String','2*x^4-8*x^3+8*x^2 -y+2'); set(handles.popupmenu_constraints1,'Value',1); activate_constraint(1,1,handles); set(handles.edit_constraints2,'String','4*x^4-32*x^3+88*x^2-96*x-y+36'); set(handles.popupmenu_constraints2,'Value',1); activate_constraint(2,1,handles); set(handles.edit_constraints3,'String','x'); set(handles.popupmenu_constraints3,'Value',1); activate_constraint(3,1,handles); set(handles.edit_constraints4,'String','x-3'); set(handles.popupmenu_constraints4,'Value',2); activate_constraint(4,1,handles); set(handles.edit_constraints5,'String','y'); set(handles.popupmenu_constraints5,'Value',1); activate_constraint(5,1,handles); set(handles.edit_constraints6,'String','y-4'); set(handles.popupmenu_constraints6,'Value',2); activate_constraint(6,1,handles); % plotting doPlot=1; set(handles.radiobutton_3D_1,'Value',1); set(handles.edit_xMin,'String','0'); set(handles.edit_xMax,'String','3'); set(handles.edit_yMin,'String','0'); set(handles.edit_yMax,'String','4'); % (infimum) elseif example==10, set(handles.edit_vars,'String', 'x y'); set(handles.edit_poly,'String',['(x*y-1)^2 + y^2']); set(handles.popupmenu_order,'Value',2); set(handles.edit_scaling,'String','10 1'); set(handles.edit_constraints1,'String','2*x*y^2 - 2*y '); set(handles.popupmenu_constraints1,'Value',3); activate_constraint(1,0,handles); set(handles.edit_constraints2,'String','2*x^2*y - 2*x +2*y '); set(handles.popupmenu_constraints2,'Value',3); activate_constraint(2,0,handles); % plotting doPlot=1; set(handles.radiobutton_3D_2,'Value',1); set(handles.edit_xMin,'String','-10'); set(handles.edit_xMax,'String','24'); set(handles.edit_yMin,'String','-0.25'); set(handles.edit_yMax,'String','1'); set(handles.edit_plotLinesIntervalStart,'String','0'); set(handles.edit_plotLinesIntervalEnd,'String','1'); set(handles.edit_plotLinesNo,'String','5'); uicontrol(handles.edit_scaling); % (infimum pert) elseif example==11, set(handles.edit_vars,'String', 'x y'); set(handles.edit_poly,'String',['(x*y-1)^2 + y^2 ']); set(handles.popupmenu_order,'Value',2); set(handles.edit_scaling,'String','10 1'); set(handles.edit_constraints1,'String','2*x*y^2 - 2*y + 6*10^(-2)*x^5'); set(handles.popupmenu_constraints1,'Value',3); activate_constraint(1,1,handles); set(handles.edit_constraints2,'String','2*x^2*y - 2*x +2*y + 6*10^(-2)*y^5'); set(handles.popupmenu_constraints2,'Value',3); activate_constraint(2,1,handles); % plotting doPlot=1; set(handles.radiobutton_3D_2,'Value',1); set(handles.edit_xMin,'String','-10'); set(handles.edit_xMax,'String','24'); set(handles.edit_yMin,'String','-0.25'); set(handles.edit_yMax,'String','1'); set(handles.edit_plotLinesIntervalStart,'String','0'); set(handles.edit_plotLinesIntervalEnd,'String','1'); set(handles.edit_plotLinesNo,'String','5'); uicontrol(handles.edit_scaling); % example 12 =-------------------------------- % Circle elseif example==13, set(handles.edit_vars,'String', 'x y'); set(handles.edit_poly,'String','(x^2+y^2-1)^2 '); set(handles.popupmenu_order,'Value',2); % plotting doPlot=0; set(handles.radiobutton_3D_1,'Value',1); set(handles.edit_xMin,'String','-1'); set(handles.edit_xMax,'String',' 1'); set(handles.edit_yMin,'String','-1'); set(handles.edit_yMax,'String',' 1'); set(handles.edit_plotLinesIntervalStart,'String','0'); set(handles.edit_plotLinesIntervalEnd,'String','0.2'); set(handles.edit_plotLinesNo,'String','5'); % Circle (pert) elseif example==14, set(handles.edit_vars,'String', 'x y'); set(handles.edit_poly,'String','(x^2+y^2-1)^2 +10^(-1)*(x^6+y^6)'); set(handles.popupmenu_order,'Value',2); % plotting doPlot=1; set(handles.radiobutton_3D_1,'Value',1); set(handles.edit_xMin,'String','-1'); set(handles.edit_xMax,'String',' 1'); set(handles.edit_yMin,'String','-1'); set(handles.edit_yMax,'String',' 1'); set(handles.edit_plotLinesIntervalStart,'String','0'); set(handles.edit_plotLinesIntervalEnd,'String','0.2'); set(handles.edit_plotLinesNo,'String','5'); % example 15 =-------------------------------- % ellipse 2D elseif example==16, set(handles.edit_vars,'String', 'x y'); set(handles.edit_poly,'String','x^2+y^2'); set(handles.popupmenu_order,'Value',1); set(handles.edit_constraints1,'String','1/25*x^2 + y^2 -1'); activate_constraint(1,1,handles); set(handles.popupmenu_constraints1,'Value',3); % plotting doPlot=0; %ellipse 3D elseif example==17, set(handles.edit_vars,'String', 'x y z'); set(handles.edit_poly,'String','x^2+y^2+z^2'); set(handles.popupmenu_order,'Value',1); set(handles.edit_constraints1,'String','1/25*x^2 + y^2 + z^2 -1'); activate_constraint(1,1,handles); set(handles.popupmenu_constraints1,'Value',3); % plotting doPlot=0; %ellipse 6D elseif example==18, % 6 variables set(handles.edit_vars,'String', 'x1 x2 x3 x4 x5 x6'); set(handles.edit_poly,'String','x1^2 +x2^2 +x3^2 +x4^2 +x5^2 +x6^2'); set(handles.popupmenu_order,'Value',1); set(handles.edit_constraints1,'String','1/25*x1^2+0.999*(x2^2+x3^2+x4^2+x5^2)+x6^2-1'); activate_constraint(1,1,handles); set(handles.popupmenu_constraints1,'Value',3); % plotting doPlot=0; %ellipse 10D elseif example==19, % 6 variables set(handles.edit_vars,'String', 'x1 x2 x3 x4 x5 x6 x7 x8 x9 x10'); set(handles.edit_poly,'String','x1^2 +x2^2 +x3^2 +x4^2+x5^2+x6^2+x7^2+x8^2+x9^2 +x10^2'); set(handles.popupmenu_order,'Value',1); set(handles.edit_constraints1,'String','1/25*x1^2+0.999*(x2^2+x3^2+x4^2+x5^2+x6^2+x7^2+x8^2+x9^2)+x10^2-1'); activate_constraint(1,1,handles); set(handles.popupmenu_constraints1,'Value',3); % plotting doPlot=0; % example 20 =-------------------------------- %HL elseif example==21, set(handles.edit_vars,'String', 'x y z '); set(handles.edit_poly,'String','1'); set(handles.popupmenu_order,'Value',1); set(handles.edit_constraints1,'String','(x^2+y^2-1)'); activate_constraint(1,1,handles); set(handles.popupmenu_constraints1,'Value',3); set(handles.edit_constraints2,'String','(x^3 +2*x*y +x*y*z +y^3 -1)'); activate_constraint(2,1,handles); set(handles.popupmenu_constraints2,'Value',3); set(handles.edit_constraints3,'String','(z^2 -2)'); activate_constraint(3,1,handles); set(handles.popupmenu_constraints3,'Value',3); % plotting doPlot=0; %HL1 elseif example==22, set(handles.edit_vars,'String', 'x y z '); set(handles.edit_poly,'String','1'); set(handles.popupmenu_order,'Value',2); set(handles.edit_constraints1,'String','(x^2+y^2-1)'); activate_constraint(1,0,handles); set(handles.popupmenu_constraints1,'Value',3); set(handles.edit_constraints2,'String','(x^3 +2*x*y +x*y*z +y^3 -1)'); activate_constraint(2,0,handles); set(handles.popupmenu_constraints2,'Value',3); set(handles.edit_constraints3,'String','(z^2 -2)'); activate_constraint(3,0,handles); set(handles.popupmenu_constraints3,'Value',3); set(handles.edit_constraints4,'String','(x^2+1) * (x^2+y^2-1)'); activate_constraint(4,1,handles); set(handles.popupmenu_constraints4,'Value',3); set(handles.edit_constraints5,'String','(x^2+1) * (x^3 +2*x*y +x*y*z +y^3 -1)'); activate_constraint(5,1,handles); set(handles.popupmenu_constraints5,'Value',3); set(handles.edit_constraints6,'String','(x^2+1) * (z^2 -2)'); activate_constraint(6,1,handles); set(handles.popupmenu_constraints6,'Value',3); % plotting doPlot=0; %HL2 elseif example==23, set(handles.edit_vars,'String', 'x y z '); set(handles.edit_poly,'String','1'); set(handles.popupmenu_order,'Value',2); set(handles.edit_constraints1,'String','(x^2+y^2-1)'); activate_constraint(1,0,handles); set(handles.popupmenu_constraints1,'Value',3); set(handles.edit_constraints2,'String','(x^3 +2*x*y +x*y*z +y^3 -1)'); activate_constraint(2,0,handles); set(handles.popupmenu_constraints2,'Value',3); set(handles.edit_constraints3,'String','(z^2 -2)'); activate_constraint(3,0,handles); set(handles.popupmenu_constraints3,'Value',3); set(handles.edit_constraints4,'String','(x^2+y^2+z^2+1)^1 * (x^2+y^2-1)'); activate_constraint(4,1,handles); set(handles.popupmenu_constraints4,'Value',3); set(handles.edit_constraints5,'String','(x^2+y^2+z^2+1)^1 * (x^3 +2*x*y +x*y*z +y^3 -1)'); activate_constraint(5,1,handles); set(handles.popupmenu_constraints5,'Value',3); set(handles.edit_constraints6,'String','(x^2+y^2+z^2+1)^1 * (z^2 -2)'); activate_constraint(6,1,handles); set(handles.popupmenu_constraints6,'Value',3); % plotting doPlot=0; % example 24 =-------------------------------- % (NOS 3D) elseif example==25, set(handles.edit_vars,'String', 'x y z'); set(handles.edit_poly,'String',['1 + ((-2*x^2 + y^2 + z^2)^2*(-3 + x^2 + y^2 + z^2))/',... '4 + ((x^2 - 2*y^2 + z^2)^2*(-9 + 2*(x^2 + y^2 + z^2)))/',... '27 + (x^2 + y^2 - 2*z^2)^2*(-3 + 2*(x^2 + y^2 + z^2))']); set(handles.popupmenu_order,'Value',2); set(handles.edit_constraints1,'String','1 -x^2-y^2-z^2'); activate_constraint(1,1,handles); % plotting doPlot=0; end; if doPlot==1 do_plot(handles); else, toggle_plotVisible(0,handles); end; % Hints: contents = get(hObject,'String') returns popupmenu_load contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_load % --- Executes during object creation, after setting all properties. function popupmenu_load_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_load (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in checkbox_rotate. function checkbox_rotate_Callback(hObject, eventdata, handles) % hObject handle to checkbox_rotate (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) i=0; while i<=90 try if (get(hObject,'Value')), camorbit(0.5,0,'data',[0 0 1]); drawnow; pause(0.1); % disp(get(get(gca,'YLabel'),'Position')); else return; end; catch, return; end; end; % Hint: get(hObject,'Value') returns toggle state of checkbox_rotate function edit_xMin_Callback(hObject, eventdata, handles) % hObject handle to edit_xMin (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_xMin as text % str2double(get(hObject,'String')) returns contents of edit_xMin as a double % --- Executes during object creation, after setting all properties. function edit_xMin_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_xMin (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_xMax_Callback(hObject, eventdata, handles) % hObject handle to edit_xMax (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_xMax as text % str2double(get(hObject,'String')) returns contents of edit_xMax as a double % --- Executes during object creation, after setting all properties. function edit_xMax_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_xMax (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_yMin_Callback(hObject, eventdata, handles) % hObject handle to edit_yMin (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_yMin as text % str2double(get(hObject,'String')) returns contents of edit_yMin as a double % --- Executes during object creation, after setting all properties. function edit_yMin_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_yMin (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_yMax_Callback(hObject, eventdata, handles) % hObject handle to edit_yMax (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_yMax as text % str2double(get(hObject,'String')) returns contents of edit_yMax as a double % --- Executes during object creation, after setting all properties. function edit_yMax_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_yMax (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_vars_Callback(hObject, eventdata, handles) % hObject handle to edit_vars (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear lasterror; vars=get(handles.edit_vars,'String'); try %remove trailing whitespaces pat = '[\ ]*$'; vars=regexprep(vars, pat, ''); %remove leading whitespaces pat = '^[\ ]'; vars=regexprep(vars, pat, ''); % make a space separated list of them pat = '[,;\ ]*'; varsList2= regexprep(vars, pat, ' '); catch, warn('string','wrong format in variables field (use space separeted list).','title','parse error'); uicontrol(handles.edit_vars); return; end; try eval(['syms ',varsList2]);, catch, warn('string','wrong format in variables field (use space separeted list).','title','parse error'); uicontrol(handles.edit_vars); return; end; if length(findstr(varsList2, ' '))>1, toggle_plotVisible(0,handles); % warn('string','can not plot a polynomial in more than 2 variables.','title','Plot info'); return end; % Hints: get(hObject,'String') returns contents of edit_vars as text % str2double(get(hObject,'String')) returns contents of edit_vars as a double % --- Executes during object creation, after setting all properties. function edit_vars_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_vars (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_scaling_Callback(hObject, eventdata, handles) % hObject handle to edit_scaling (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_scaling as text % str2double(get(hObject,'String')) returns contents of edit_scaling as a double % --- Executes during object creation, after setting all properties. function edit_scaling_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_scaling (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in radiobutton_3D_1. function radiobutton_3D_1_Callback(hObject, eventdata, handles) % hObject handle to radiobutton_3D_1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.checkbox_rotate,'Enable','on'); set(handles.radiobutton_3D_1,'Enable','inactive'); set(handles.radiobutton_3D_2,'Enable','on'); set(handles.edit_plotLinesIntervalStart,'Enable','off'); set(handles.edit_plotLinesIntervalEnd,'Enable','off'); set(handles.edit_plotLinesNo,'Enable','off'); % Hint: get(hObject,'Value') returns toggle state of radiobutton_3D_1 % --- Executes on button press in radiobutton_3D_1. function radiobutton_3D_2_Callback(hObject, eventdata, handles) % hObject handle to radiobutton_3D_1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.checkbox_rotate,'Value',0); set(handles.checkbox_rotate,'Enable','off'); set(handles.radiobutton_3D_1,'Enable','on'); set(handles.radiobutton_3D_2,'Enable','inactive'); set(handles.edit_plotLinesIntervalStart,'Enable','on'); set(handles.edit_plotLinesIntervalEnd,'Enable','on'); set(handles.edit_plotLinesNo,'Enable','on'); % Hint: get(hObject,'Value') returns toggle state of radiobutton_3D_1 function edit_plotLinesIntervalStart_Callback(hObject, eventdata, handles) % hObject handle to edit_plotLinesIntervalStart (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_plotLinesIntervalStart as text % str2double(get(hObject,'String')) returns contents of edit_plotLinesIntervalStart as a double % --- Executes during object creation, after setting all properties. function edit_plotLinesIntervalStart_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_plotLinesIntervalStart (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_plotLinesIntervalEnd_Callback(hObject, eventdata, handles) % hObject handle to edit_plotLinesIntervalEnd (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_plotLinesIntervalEnd as text % str2double(get(hObject,'String')) returns contents of edit_plotLinesIntervalEnd as a double % --- Executes during object creation, after setting all properties. function edit_plotLinesIntervalEnd_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_plotLinesIntervalEnd (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_plotLinesNo_Callback(hObject, eventdata, handles) % hObject handle to edit_plotLinesNo (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_plotLinesNo as text % str2double(get(hObject,'String')) returns contents of edit_plotLinesNo as a double % --- Executes during object creation, after setting all properties. function edit_plotLinesNo_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_plotLinesNo (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_sedumiRanktol_Callback(hObject, eventdata, handles) % hObject handle to edit_sedumiRanktol (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_sedumiRanktol as text % str2double(get(hObject,'String')) returns contents of edit_sedumiRanktol as a double % --- Executes during object creation, after setting all properties. function edit_sedumiRanktol_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_sedumiRanktol (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_sedumiRadius_Callback(hObject, eventdata, handles) % hObject handle to edit_sedumiRadius (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_sedumiRadius as text % str2double(get(hObject,'String')) returns contents of edit_sedumiRadius as a double % --- Executes during object creation, after setting all properties. function edit_sedumiRadius_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_sedumiRadius (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in pushbutton_default. function pushbutton_default_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_default (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.popupmenu_order,'Value',2); set(handles.edit_sedumiRanktol,'String',''); set(handles.text_sedumiEps,'String',''); set(handles.radiobutton_sedumiout_hide,'Value',1); % set(handles.edit_sedumiRadius,'String',''); set(handles.edit_scaling,'String',''); % --- Executes on button press in pushbutton_check. function pushbutton_check_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_check (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) tmp=get(handles.pushbutton_check,'UserData'); disp(' '); my_testpoly(tmp.P,[tmp.sol{:}]);