⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 floor_plan_graphs.m

📁 斯坦福大学Grant和Boyd教授等开发的凸优化matlab工具箱
💻 M
字号:
% Solve a floor planning problem given graphs H & V% Section 8.8.1/2, Example 8.7, Boyd & Vandenberghe "Convex Optimization"% Joelle Skaf - 11/13/05% (a figure is generated)%% Rectangles aligned with the axes need to be place in the smallest% possible bounding box. No overlap is allowed. Each rectangle to be placed% can be reconfigured, within some limits.% In the current problem, 5 rectangles are to be place. We are given 2% acyclic graphs H and V (for horizontal and vertical) that specify the% relative positioning constraints of those rectangles.% We are also given minimal areas for the rectangles.cvx_quiet(1);% Input datan = 5;% for each entry i, X_tree(i) = parent(i)H_tree = [0 0 1 0 0;...          0 0 1 0 0;...          0 0 0 0 1;...          0 0 0 0 1;...          0 0 0 0 0];V_tree = [0 0 0 1 0;...          1 0 0 0 0;...          0 0 0 1 0;...          0 0 0 0 0;...          0 0 0 0 0];Amin = [100 100 100 100 100; ...         20  50  80 150 200; ...        180  80  80  80  80; ...         20 150  20 200 110];rho = 1;          % minimum spacing constraints% solving the problem by calling the general FLOORPLAN routinefor iter = 1:4    A = Amin(iter,:);    [W, H, w, h, x, y] = floorplan(H_tree, V_tree, rho, A, 1/5*ones(n,1), 5*ones(n,1));    % Plotting    subplot(2,2,iter)    for i=1:n        fill([x(i); x(i)+w(i); x(i)+w(i); x(i)],[y(i);y(i);y(i)+h(i);y(i)+h(i)],0.90*[1 1 1]);        hold on;        text(x(i)+w(i)/2, y(i)+h(i)/2,['B',int2str(i)]);    end    axis([0 W 0 H]);    axis equal; axis off;end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -