24小时热门版块排行榜    

查看: 3858  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 环境工程调剂 +6 大可digkids 2026-03-16 6/300 2026-03-16 17:16 by barlinike
[考研] 312求调剂 +3 陌宸希 2026-03-16 4/200 2026-03-16 15:06 by peike
[考研] 材料与化工专硕调剂 +3 heming3743 2026-03-16 3/150 2026-03-16 15:05 by peike
[考研] 326求调剂 +4 上岸的小葡 2026-03-15 5/250 2026-03-16 08:39 by Linda Hu
[考研] 311求调剂 +6 冬十三 2026-03-15 6/300 2026-03-16 08:00 by wang_dand
[考研] 294求调剂 +3 Zys010410@ 2026-03-13 4/200 2026-03-15 10:59 by zhq0425
[考研] 289求调剂 +4 这么名字咋样 2026-03-14 6/300 2026-03-14 18:58 by userper
[基金申请] 有必要更换申报口吗 20+3 fannyamoy 2026-03-11 3/150 2026-03-14 00:52 by zhanghaozhu
[考研] 一志愿华中农业大学071010,总分三百二,求调剂 +3 困困困困坤坤 2026-03-10 3/150 2026-03-14 00:35 by JourneyLucky
[考研] 321求调剂 +3 CUcat 2026-03-10 3/150 2026-03-14 00:25 by JourneyLucky
[考研] 341求调剂 +3 番茄头--- 2026-03-10 3/150 2026-03-13 23:07 by JourneyLucky
[考研] 材料与化工304求B区调剂 +5 邱gl 2026-03-11 6/300 2026-03-13 22:37 by JourneyLucky
[考研] 材料与化工085600调剂求老师收留 +9 jiaanl 2026-03-11 9/450 2026-03-13 20:22 by JourneyLucky
[考研] 求调剂 +7 18880831720 2026-03-11 7/350 2026-03-13 16:10 by JourneyLucky
[考研] 295求调剂 +3 小匕仔汁 2026-03-12 3/150 2026-03-13 15:17 by vgtyfty
[考研] 工科调剂 +4 Jiang191123! 2026-03-11 4/200 2026-03-13 15:15 by Miko19
[考研] 277求调剂 +4 anchor17 2026-03-12 4/200 2026-03-13 11:15 by 白夜悠长
[考研] 08食品或轻工求调剂,本科发表3篇sci一区top论文,一志愿南师大食品科学与工程 +3 我是一个兵, 2026-03-10 3/150 2026-03-13 10:21 by Yuyi.
[考研] 321求调剂(食品/专硕) +3 xc321 2026-03-12 6/300 2026-03-13 08:45 by xc321
[硕博家园] 木虫好像不热闹了,是不是? +4 偏振片 2026-03-10 4/200 2026-03-10 09:51 by longwave
信息提示
请填处理意见