24小时热门版块排行榜    

查看: 3910  |  回复: 0

freesea

铁虫 (初入文坛)

[求助] 【请教】matlab求解含等式约束线性规划的对偶问题

The problem:
              min x1+3*x2+0.5*x3
               s.t. x1<=2;
                  x1+x2-x3=3;
                 x1,x2,x3>=0
                     
Correct solution is x1=2; x2=1; x3=0; dual solution is  y=(-2; 3)
I have made the following code, but the result of dual solution obtained from “lambda” is not correct.

clear
% Parameters
N=3;f=[1; 3; 0.5];lb=zeros(N,1);
% Define Matrices
A=[1 0 0];b=[2];
Aeq=[1 1 -1];beq=[3];
[x,fval,exitflag,output,lambda]=linprog(f,A,b,Aeq,beq,lb,[])

When the quality is transformed into inequality, the corresponding code is shown as follows:
clear
% Parameters
N=3;f=[1; 3; 0.5];lb=zeros(N,1);
% Define Matrices
A=[1 0 0;1 1 -1;-1 -1 1];b=[2;3;-3];
[x,fval,exitflag,output,lambda]=linprog(f,A,b,[],[],lb,[])

These two paragraphs of codes can only get the correct answer to the primal problem, but they cannot get the right solution of dual problem. Could you tell me how to get to correct dual solution? Thanks a lot.
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

找到一些相关的精华帖子,希望有用哦~

科研从小木虫开始,人人为我,我为人人
相关版块跳转 我要订阅楼主 freesea 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 人气不行了 +11 fansofjerry 2026-08-21 11/550 2026-08-25 11:04 by 孤独的英雄6
[基金申请] 2026国自然函评费到账 +19 羊腰板 2026-08-21 22/1100 2026-08-25 10:38 by popular289
[教师之家] 导师吐槽:我怎么摊上了这么个极品研究生! +3 苏东坡二世 2026-08-23 3/150 2026-08-25 10:35 by shisan1313
[基金申请] 2026年的国家社科基金项目通讯评审的新规则与新动向、新挑战 +5 process2012 2026-08-23 7/350 2026-08-25 09:42 by huixian257
[基金申请] 今天基金会出结果吗?20260819 +17 kkkl_v 2026-08-19 18/900 2026-08-25 09:41 by windflowerwy
[基金申请] 我面上完蛋了 +13 且听虎啸 2026-08-20 14/700 2026-08-25 09:10 by mrkang
[基金申请] 范进中举一文的中心思想 +7 炎黄贵胄 2026-08-22 8/400 2026-08-25 08:48 by ZJTJZ
[基金申请] 明天应该可查了!? +5 chengyan1220 2026-08-23 5/250 2026-08-24 23:28 by 我4大白菜
[基金申请] 如果此刻你正在为国基感到焦虑,不妨来听听这首《基金之外》 +7 scalable 2026-08-24 7/350 2026-08-24 23:01 by anata1209
[基金申请] filecode,4个jtjc了 +14 ziyangfang 2026-08-19 17/850 2026-08-24 18:37 by 哈哈蛤?
[基金申请] 今日不放榜?网传国自然预计 8 月 27 日可查结果 +17 医学老男孩 2026-08-20 21/1050 2026-08-24 14:21 by refreshing11
[基金申请] 朋友圈看到的 +7 wangzilk 2026-08-18 9/450 2026-08-24 10:50 by cmrandy
[基金申请] 让我中一个面上吧! +13 大萍1987 2026-08-20 16/800 2026-08-24 10:23 by 太傻了
[基金申请] 放榜前的不淡定 20+4 snowwithsea 2026-08-19 17/850 2026-08-24 10:20 by echo8914667
[基金申请] 今天放榜吗? +15 布布和一二 2026-08-19 16/800 2026-08-23 09:55 by 张春生
[基金申请] 时间戳今天,20号变了 +5 archvillain 2026-08-20 5/250 2026-08-22 06:12 by hui_daxiao
[基金申请] 看来今天不会放榜了? +8 chengyan1220 2026-08-21 11/550 2026-08-21 17:52 by dcqxinyang
[基金申请] 应该是下周三26日公布了吧? +4 哈哈蛤? 2026-08-21 4/200 2026-08-21 10:58 by Vivilian
[基金申请] 重要消息,中午系统在维护 +11 yuleib84 2026-08-18 12/600 2026-08-20 11:09 by xskun
[基金申请] 明天放榜? +5 Shxjjxjkx 2026-08-18 5/250 2026-08-18 18:14 by -大大大大大-
信息提示
请填处理意见