matlab fmincon 精度,fmincon与quadprog误差

matlab fmincon 精度,fmincon与quadprog误差该楼层疑似违规已被系统折叠隐藏此楼查看此楼有没有人能帮我看看这两个程序的运行结果为什么会不一样啊??困扰了好久……程序一:%text1.mclearall;clc;a=[0.058,0.075,0.092,0.111,0.136,0.092]’;b=[0.062,0.085,0.128,0.149,0.164,0.148]’;alpha=[0.054,0.075,0.096,0.1…

大家好,又见面了,我是你们的朋友全栈君。

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

有没有人能帮我看看这两个程序的运行结果为什么会不一样啊??困扰了好久……

程序一:

%text1.m

clear all;clc;

a = [0.058,0.075,0.092,0.111,0.136,0.092]’;

b = [0.062,0.085,0.128,0.149,0.164,0.148]’;

alpha = [0.054,0.075,0.096,0.123,0.148,0.081]’;

beta = [0.058,0.085,0.112,0.138,0.168,0.101]’;

pk = [0.005,0.005,0.005,0.005]’;

pn = [0,0,0,0,0.005,0.005]’;

qb = [0.008,0.008,0.008,0.008]’;

n = 16;

m = 24;

q = 5;

c0 = -((a’ + b’) / 2 + (beta’ – alpha’) / 4) + pn’;

t = 0.15;

c = t * [c0,-0.01,0.03,pk’,qb’]’

eta1 = beta + b – a;

eta2 = beta + alpha + 2 * (b – a);

bigc0 = (beta * beta’ + alpha * alpha’ + 3 * eta1 * eta2′)/24;

bigc0( : ,7:n) = 0;

bigc0( 7:n , : ) = 0;

bigc = 0.5 * (bigc0 + bigc0′)

A = [-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0;

0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0;

0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0;

1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0;

0,0,1,0,0,0,0,0,0,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0,0,0]’;

[x,fval] = fmincon(@myfun,x0,A,B,Aeq,Beq)

%myfun.m

function f = myfun(x)

a = [0.058,0.075,0.092,0.111,0.136,0.092]’;

b = [0.062,0.085,0.128,0.149,0.164,0.148]’;

alpha = [0.054,0.075,0.096,0.123,0.148,0.081]’;

beta = [0.058,0.085,0.112,0.138,0.168,0.101]’;

pk = [0.005,0.005,0.005,0.005]’;

pn = [0,0,0,0,0.005,0.005]’;

qb = [0.008,0.008,0.008,0.008]’;

n = 16;

m = 24;

q = 5;

c0 = -((a’ + b’) / 2 + (beta’ – alpha’) / 4) + pn’;

t = 0.15;

c = t * [c0,-0.01,0.03,pk’,qb’]’

eta1 = beta + b – a;

eta2 = beta + alpha + 2 * (b – a);

bigc0 = (beta * beta’ + alpha * alpha’ + 3 * eta1 * eta2′)/24;

bigc0( : ,7:n) = 0;

bigc0( 7:n , : ) = 0

bigc = 0.5 * (bigc0 + bigc0′)

f = c’ * [x(1),x(2),x(3),x(4),x(5),x(6),x(7),x(8),x(9),x(10),x(11),x(12),x(13),x(14),x(15),x(16)]’ + 0.5 * [x(1),x(2),x(3),x(4),x(5),x(6),x(7),x(8),x(9),x(10),x(11),x(12),x(13),x(14),x(15),x(16)] * bigc * [x(1),x(2),x(3),x(4),x(5),x(6),x(7),x(8),x(9),x(10),x(11),x(12),x(13),x(14),x(15),x(16)]’;

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/132331.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • obs录制黑屏怎么解决_obs窗口捕获黑屏

    obs录制黑屏怎么解决_obs窗口捕获黑屏00.目录文章目录00.目录01.问题描述02.问题分析03.问题解决04.成功测试01.问题描述打开OBS后,新建场景、新建显示器捕获后,黑屏没有显示,即使点击开始录制,然后结束录制后,录制的视频仍然是黑屏。02.问题分析安装包是从官网下载的,安装过程没有报错,启动过程也没有报错,但是却捕捉不到显示器中的图像。首先考虑的是软件兼容性的问题,但是在我将兼容性设置成”W…

  • Mysql性能优化一:SQL语句性能优化

    Mysql性能优化一:SQL语句性能优化

  • jquery 判断array中是否包含指定字符串

    jquery 判断array中是否包含指定字符串

  • mysql之通用二进制格式程序包安装

    mysql之通用二进制格式程序包安装

  • Activiti工作流使用之项目实例

    Activiti工作流使用之项目实例Activiti工作流使用之项目实例文章目录Activiti工作流使用之项目实例一、配置文件1.1pom依赖引入1.2application.properties文件二、BPMN文件三、控制层Controller四、实现类Service4.1流程启动(不进入下一环节)4.2流程启动(直接进入下一环节)4.3审批任务4.4查询我发起的流程4.5流程下任务详情4.6删除流程4.7我待审核的任务五、监听器六、流程示意一、配置文件1.1pom依赖引入<dependency>

  • 支持向量机的基本思想和原理_人民战争思想的基本理论内容

    支持向量机的基本思想和原理_人民战争思想的基本理论内容一、支持向量机:SVM即支持向量机(SupportVectorMachine),是有监督学习算法的一种,用于解决数据挖掘或模式识别领域中数据分类问题。二、基本原理:SVM算法即寻找一个分类器使得超平面和最近的数据点之间的分类边缘(超平面和最近的数据点之间的间隔被称为分类边缘)最大,对于SVM算法通常认为分类边缘越大,平面越优,通常定义具有“最大间隔”的决策面就是S…

    2022年10月20日

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号