CVX求解几何规划样例1:

Section 4.5.4: Design of a cantilever beam: recursive formulation (GP)

% Section 4.5.4: Design of a cantilever beam: recursive formulation (GP)
% Boyd & Vandenberghe "Convex Optimization"
% (a figure is generated)
% Almir Mutapcic 02/08/06
%
% We have a segmented cantilever beam with N segments. Each segment
% has a unit length and variable width and height (rectangular profile).
% The goal is minimize the total volume of the beam, over all segment
% widths w_i and heights h_i, subject to constraints on aspect ratios,
% maximum allowable stress in the material, vertical deflection y, etc.
%
% The problem can be posed as a geometric program (posynomial form)
%     minimize   sum( w_i* h_i)
%         s.t.   w_min <= w_i <= w_max,       for all i = 1,...,N
%                h_min <= h_i <= h_max
%                S_min <= h_i/w_i <= S_max
%                6*i*F/(w_i*h_i^2) <= sigma_max
%                y_1 <= y_max
%
% with variables w_i and h_i (i = 1,...,N).
% For other definitions consult the book.
% (See exercise 4.31 for a non-recursive formulation.)% optimization variables
clear all
clcN = 8;
% constants
wmin = .1;   wmax = 100;
hmin = .1;   hmax = 6;
Smin = 1/5;  Smax = 5;
sigma_max = 1;
ymax = 10;
E = 1; F = 1;cvx_begin gp  % quiet % optimization variablesvariables w(N) h(N)% setting up variables relations% (recursive formulation)v = cvx( zeros(N+1,1) );y = cvx( zeros(N+1,1) );%   v =  zeros(N+1,1) ;
%   y =  zeros(N+1,1) ;for i = N:-1:1fprintf(1,'Building recursive relations for index: %d\n',i);v(i) = 12*(i-1/2)*F/(E*w(i)*h(i)^3) + v(i+1);y(i) = 6*(i-1/3)*F/(E*w(i)*h(i)^3)  + v(i+1) + y(i+1);end% objective is the total volume of the beam% obj = sum of (widths*heights*lengths) over each section% (recall that the length of each segment is set to be 1)minimize( (w.^(-1))'*(h.^6) + (10*w.^(-2))'*(h.^2) )subject to% constraint setwmin <= w    <= wmax;hmin <= h    <= hmax;hmin <= h(1:4)    <= hmax;Smin <= h./w <= Smax;6*F*[1:N]'./(w.*(h.^2)) <= sigma_max;y(1) <= ymax;
cvx_end% display results
disp('The optimal widths and heights are: ');
w, h
fprintf(1,'The optimal minimum volume of the beam is %3.4f.\n', sum(w.*h))% plot the 3D model of the optimal cantilever beam
% figure, clf
% cantilever_beam_plot([h; w])

CVX求解几何规划样例2:

Exercise 4.31: Design of a cantilever beam (GP)

% Boyd & Vandenberghe "Convex Optimization"
% Almir Mutapcic - 01/30/06
% Updated to use GP mode 02/08/06
% (a figure is generated)
%
% We have a segmented cantilever beam with N segments. Each segment
% has a unit length and variable width and height (rectangular profile).
% The goal is minimize the total volume of the beam, over all segment
% widths w_i and heights h_i, subject to constraints on aspect ratios,
% maximum allowable stress in the material, vertical deflection y, etc.
%
% The problem can be posed as a geometric program (posynomial form)
%     minimize    sum( w_i* h_i)
%         s.t.    w_min <= w_i <= w_max,       for all i = 1,...,N
%                 h_min <= h_i <= h_max
%                 S_min <= h_i/w_i <= S_max
%                 6*i*F/(w_i*h_i^2) <= sigma_max
%                 6*F/(E*w_i*h_i^3) == d_i
%                 (2*i - 1)*d_i + v_(i+1) <= v_i
%                 (i - 1/3)*d_i + v_(i+1) + y_(i+1) <= y_i
%                 y_1 <= y_max
%
% with variables w_i, h_i, d_i, (i = 1,...,N) and v_i, y_i (i = 1,...,N+1).
% (Consult the book for other definitions and a recursive formulation of
% this problem.)% optimization variablesclear all
clcN = 8;
% constants
wmin = .1; wmax = 100;
hmin = .1; hmax = 6;
Smin = 1/5; Smax = 5;
sigma_max = 1;
ymax = 10;
E = 1; F = 1;cvx_begin gp% optimization variablesvariables w(N) h(N) v(N+1) y(N+1);% objective is the total volume of the beam% obj = sum of (widths*heights*lengths) over each section% (recall that the length of each segment is set to be 1)minimize( w'*h )subject to% non-recursive formulationd = 6*F*ones(N,1)./(E*ones(N,1).*w.*h.^3);for i = 1:N(2*i-1)*d(i) + v(i+1) <= v(i);(i-1/3)*d(i) + v(i+1) + y(i+1) <= y(i);end% constraint setwmin <= w    <= wmax;hmin <= h    <= hmax;Smin <= h./w <= Smax;6*F*[1:N]'./(w.*(h.^2)) <= sigma_max;y(1) <= ymax;
cvx_end% display results
disp('The optimal widths and heights are: ');
w, h
fprintf(1,'The optimal minimum volume of the beam is %3.4f.\n', sum(w.*h))% % plot the 3D model of the optimal cantilever beam
% figure, clf
% cantilever_beam_plot([h; w])

网址链接: CVX Example library

CVX 几何规划 两个官网样例相关推荐

  1. AntD 官网样例 InputRef报错原因

    在官网可编辑表格typescript样例里 const inputRef = useRef<InputRef>(null); InputRef项目报错原因是ant design的版本问题! ...

  2. cvx实数变量_cvx 官网教程

    官网有一个13分钟的视频教程 例一: cvx_begin variables x y    %定义几个变量,变量之间是空格 minimize ((x+y+3)^2)  %目标函数 y>=0    ...

  3. Python爬虫——简易模拟登录【以科文学院教务官网为例】

    实战:对科文教务系统进行拦截 科文学院教务系统内网地址:http://10.110.240.221/jsxsd/ 进入官网后再打开拦截. 输入一个错误的账号密码进行试探. 点击登陆按钮,进行拦截,可以 ...

  4. Axure知识点:如何制作轮播图效果(以泉州师范学院官网为例)

    摘要:微信搜索[三桥君] 使用软件:Axure RP 9软件 说明:实现方式不唯一,这里给出三桥君制作的一种方式. 一.问题 本篇文章三桥君主要解决关于轮播图交互效果的设置,以泉师新闻轮播图为例. 该 ...

  5. Axure知识点:如何制作弹出效果的搜索框(以泉州师范学院官网为例)

    摘要:微信搜索[三桥君] 使用软件:Axure RP 9软件 说明:实现方式不唯一,这里给出三桥君制作的一种方式. 一.问题 三桥君在制作泉州师范学院官网带有弹出效果的搜索框时,属实让我犯难了.[泉州 ...

  6. 数据藏在json文件中,如何爬取---以王者荣耀官网为例

    此前写了一个爬虫基础案例---爬取王者荣耀英雄与技能介绍 python爬虫------王者荣耀英雄及技能爬取并保存信息到excelhttps://blog.csdn.net/knighthood200 ...

  7. B端产品经理-官网设计总结

    官网,代表着一个企业的门户形象,或者称之为企业的另一张名片,记载企业的概况和发展历程.好的官网,能够充分展现其内涵,给人以美的感受:而糟糕的官网,不仅不能有效表达企业的愿景,更有可能将合作和发展机会拒 ...

  8. python的界面文字翻译_一个把网站全英文转成中文的方法,让你轻松看懂python官网...

    近日,在看python官网(英文网站)时,使用了有道翻译工具查看了几个专有名词.无意间,有了是不是可以输入网站地址进行翻译的想法,翻译后的网站地址点击进去后,又是一个什么情况呢?小编发现,经过有道翻译 ...

  9. 《快学Scala》第14章——模式匹配和样例类 学习笔记

    Scala有一个十分强大的模式匹配机制,可以应用在很多场合:switch语句.类型查询,以及"析构"(获取复杂表达式中的不同部分).除此之外,Scala还提供了样例类,对模式匹配进 ...

最新文章

  1. 谷歌母公司神秘的「X部门」,最近都在搞哪些黑科技?
  2. springboot-springmvc响应json与xml原理-详解数据响应与内容协商(长文预警,收藏慢啃)
  3. eclipse插件安装方法
  4. leetcoed123. 买卖股票的最佳时机 III
  5. Vue路由开启keep-alive缓存页面
  6. php 网页解析错误,php-解析错误:语法错误,文件意外结束
  7. Ble扫描导致wifi信号弱/断开解决
  8. 梯度下降-单变量线性回归-理论+代码+解释
  9. 需求管理系统分析与设计
  10. html5 dat.gui,Dat.gui 使用教程
  11. 未来10年互联网的十大发展趋势
  12. gopl 底层编程(unsafe包)
  13. js多线程编程web worker
  14. 2018级《程序设计基础(B)I》期末上机考试 重现(第二场)
  15. 如何在Mac上为 Apple ID 设置双重认证?
  16. 2019手机CPU芯片性能天梯图
  17. codeforces 133A(HQ9+) Java
  18. steam网络游戏加速技术,针对任何联网进程或者游戏代理加速都行。
  19. 数据质量管理平台 Qualitis 安装部署
  20. css 长度单位的理解

热门文章

  1. 安卓案例:初试谷歌图表
  2. Flex布局演示01
  3. Go程序:演示复数类型的用法
  4. android开发UI界面布局教学,android UI学习 -- 设置界面的布局(包括style的使用,selector的使用,Checkbox自定义样式,菜单项的样式)...
  5. bzoj1228 [SDOI2009]ED 找规律
  6. 2017.2.18 loli测试
  7. 【英语学习】【Level 08】U02 Movie Time L2 In black and white
  8. 【英语学习】【Daily English】U14 Transportation L03 Sorry for keeping you waiting
  9. neu坐标系和xyz坐标系转换_ArcGIS投影坐标系下坐标转换成地理坐标系经纬度
  10. PVS-Studio C/C++/C++11 静态代码分析工具