Math 线性规划在lp_求解中的非负比例约束

Math 线性规划在lp_求解中的非负比例约束,math,optimization,linear-programming,lpsolve,Math,Optimization,Linear Programming,Lpsolve,使用lp_solve,我需要约束两个线性函数的比率为非负: min: 13.21 y0 + 27.46 y1 + 35.66 y2 + 89.21 y3 + 60.69 y4; y0 + y1 + y2 + y3 + y4 >= 50000; y0 <= 69148; y1 <= 25460; y2 <= 34020; y3 <= 69873; y4 <= 737299; /* Spezification */ (-0.275 y0 + 0.15 y1

使用lp_solve,我需要约束两个线性函数的比率为非负:

min: 13.21 y0 + 27.46 y1 + 35.66 y2 + 89.21 y3 + 60.69 y4;

y0 + y1 + y2 + y3 + y4 >= 50000;

y0 <= 69148;
y1 <= 25460;
y2 <= 34020;
y3 <= 69873;
y4 <= 737299;

/* Spezification */
(-0.275 y0 + 0.15 y1 + 0.15 y2 + 0.236 y3 + 0.14745 y4) / (-0.175 y0 + 0.05 y1 + 0.05 y2 + 0.136 y3 + 0.04745 y4) >= 0;
min:13.21y0+27.46y1+35.66y2+89.21y3+60.69y4;
y0+y1+y2+y3+y4>=50000;

y0您正试图向线性程序添加以下形式的约束:

(-0.275 y0 + 0.15 y1 + 0.15 y2 + 0.236 y3 + 0.14745 y4) / (-0.175 y0 + 0.05 y1 + 0.05 y2 + 0.136 y3 + 0.04745 y4) >= 0;
为了简单起见,我将定义
A=(-0.275y0+0.15y1+0.15y2+0.236y3+0.14745y4)
B=(-0.175y0+0.05y1+0.05y2+0.136y3+0.04745y4)
。因此,您的约束条件是:

A / B >= 0
这意味着必须满足以下两个条件之一:

  • A>=0
    B>=0

  • A=0
    若要使
    z
    等于0,则
    A您试图向线性程序添加以下形式的约束:

    (-0.275 y0 + 0.15 y1 + 0.15 y2 + 0.236 y3 + 0.14745 y4) / (-0.175 y0 + 0.05 y1 + 0.05 y2 + 0.136 y3 + 0.04745 y4) >= 0;
    
    为了简单起见,我将定义
    A=(-0.275y0+0.15y1+0.15y2+0.236y3+0.14745y4)
    B=(-0.175y0+0.05y1+0.05y2+0.136y3+0.04745y4)
    。因此,您的约束条件是:

    A / B >= 0
    
    这意味着必须满足以下两个条件之一:

  • A>=0
    B>=0

  • A=0
    如果
    A你的解决方案是很好的,并且解决得很好,那么要使
    z
    等于0。但结果可能不是你所期望的。例如,我得到:z=0和x187=0(A=B=0)。 问题是A和B是只依赖于x187的表达式,所以您应该简化除法表达式!选择的大M,应该更小吗

    Model name:  'model build from GLP-Solve' - run #1    
    Objective:   Minimize(R0)
    
    SUBMITTED
    Model size:       12 constraints,      53 variables,          311 non-zeros.
    Sets:                                   0 GUB,                  0 SOS.
    
    Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.
    The primal and dual simplex pricing strategy set to 'Devex'.
    
    
    Relaxed solution       276710632.306 after         23 iter is B&B base.
    
    Feasible solution      276710632.306 after         23 iter,         0 nodes (gap 0.0%)
    
    Optimal solution       276710632.306 after         23 iter,         0 nodes (gap 0.0%).
    
    Excellent numeric accuracy ||*|| = 0
    
     MEMO: lp_solve version 5.5.2.0 for 64 bit OS, with 64 bit REAL variables.
          In the total iteration count 23, 17 (73.9%) were bound flips.
          There were 0 refactorizations, 0 triggered by time and 0 by density.
           ... on average 6.0 major pivots per refactorization.
          The largest [LUSOL v2.2.1.0] fact(B) had 13 NZ entries, 1.0x largest basis.
          The maximum B&B level was 1, 0.5x MIP order, 1 at the optimal solution.
          The constraint matrix inf-norm is 1e+06, with a dynamic range of 6.39386e+08.
          Time to load data was 0.001 seconds, presolve used 0.000 seconds,
           ... 0.000 seconds in simplex solver, in total 0.001 seconds.
    

    如果我们取消A、B和z限制,我们将获得相同的结果:

    Model name:  'model build from GLP-Solve' - run #1    
    Objective:   Minimize(R0)
    
    SUBMITTED
    Model size:        6 constraints,      50 variables,          299 non-zeros.
    Sets:                                   0 GUB,                  0 SOS.
    
    Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.
    The primal and dual simplex pricing strategy set to 'Devex'.
    
    
    Optimal solution       276710632.306 after         22 iter.
    
    Excellent numeric accuracy ||*|| = 0
    
     MEMO: lp_solve version 5.5.2.0 for 64 bit OS, with 64 bit REAL variables.
          In the total iteration count 22, 17 (77.3%) were bound flips.
          There were 0 refactorizations, 0 triggered by time and 0 by density.
           ... on average 5.0 major pivots per refactorization.
          The largest [LUSOL v2.2.1.0] fact(B) had 7 NZ entries, 1.0x largest basis.
          The constraint matrix inf-norm is 1, with a dynamic range of 639.386.
          Time to load data was 0.002 seconds, presolve used 0.001 seconds,
           ... 0.001 seconds in simplex solver, in total 0.004 seconds.
    

    您的解决方案制定得很好,而且解决得很好。但结果可能不是你所期望的。例如,我得到:z=0和x187=0(A=B=0)。 问题是A和B是只依赖于x187的表达式,所以您应该简化除法表达式!选择的大M,应该更小吗

    Model name:  'model build from GLP-Solve' - run #1    
    Objective:   Minimize(R0)
    
    SUBMITTED
    Model size:       12 constraints,      53 variables,          311 non-zeros.
    Sets:                                   0 GUB,                  0 SOS.
    
    Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.
    The primal and dual simplex pricing strategy set to 'Devex'.
    
    
    Relaxed solution       276710632.306 after         23 iter is B&B base.
    
    Feasible solution      276710632.306 after         23 iter,         0 nodes (gap 0.0%)
    
    Optimal solution       276710632.306 after         23 iter,         0 nodes (gap 0.0%).
    
    Excellent numeric accuracy ||*|| = 0
    
     MEMO: lp_solve version 5.5.2.0 for 64 bit OS, with 64 bit REAL variables.
          In the total iteration count 23, 17 (73.9%) were bound flips.
          There were 0 refactorizations, 0 triggered by time and 0 by density.
           ... on average 6.0 major pivots per refactorization.
          The largest [LUSOL v2.2.1.0] fact(B) had 13 NZ entries, 1.0x largest basis.
          The maximum B&B level was 1, 0.5x MIP order, 1 at the optimal solution.
          The constraint matrix inf-norm is 1e+06, with a dynamic range of 6.39386e+08.
          Time to load data was 0.001 seconds, presolve used 0.000 seconds,
           ... 0.000 seconds in simplex solver, in total 0.001 seconds.
    

    如果我们取消A、B和z限制,我们将获得相同的结果:

    Model name:  'model build from GLP-Solve' - run #1    
    Objective:   Minimize(R0)
    
    SUBMITTED
    Model size:        6 constraints,      50 variables,          299 non-zeros.
    Sets:                                   0 GUB,                  0 SOS.
    
    Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.
    The primal and dual simplex pricing strategy set to 'Devex'.
    
    
    Optimal solution       276710632.306 after         22 iter.
    
    Excellent numeric accuracy ||*|| = 0
    
     MEMO: lp_solve version 5.5.2.0 for 64 bit OS, with 64 bit REAL variables.
          In the total iteration count 22, 17 (77.3%) were bound flips.
          There were 0 refactorizations, 0 triggered by time and 0 by density.
           ... on average 5.0 major pivots per refactorization.
          The largest [LUSOL v2.2.1.0] fact(B) had 7 NZ entries, 1.0x largest basis.
          The constraint matrix inf-norm is 1, with a dynamic range of 639.386.
          Time to load data was 0.002 seconds, presolve used 0.001 seconds,
           ... 0.001 seconds in simplex solver, in total 0.004 seconds.
    

    你好,josliber,谢谢你的帮助。我在获取运行示例时遇到问题。我试试这个。[code]A=-0.275y0+0.15y1+0.15y2+0.236y3+0.14745y4;B=-0.175 y0+0.05 y1+0.05 y2+0.136 y3+0.04745 y4;A=M(z-1);z二进制;[/code]但我得到了解析错误。我不了解详细的逻辑…@ABSimon
    M
    应该被替换为一个大数字,比如1000000。你好,josliber,我还需要将括号放在“a>=1000000(z-1)”和“B>=1000000(z-1)”中。我想我会得到“A>=1000000 z-1000000”和“B>=1000000 z-1000000”。总的来说,我的解决方案是“A=1000000 z-1000000;bin z;”,而不是“A/B>=0”?非常感谢。我认为这是一个很大的帮助vor每一个lp_解决初学者:)你好josliber,谢谢你的帮助。我在获取运行示例时遇到问题。我试试这个。[code]A=-0.275y0+0.15y1+0.15y2+0.236y3+0.14745y4;B=-0.175 y0+0.05 y1+0.05 y2+0.136 y3+0.04745 y4;A=M(z-1);z二进制;[/code]但我得到了解析错误。我不了解详细的逻辑…@ABSimon
    M
    应该被替换为一个大数字,比如1000000。你好,josliber,我还需要将括号放在“a>=1000000(z-1)”和“B>=1000000(z-1)”中。我想我会得到“A>=1000000 z-1000000”和“B>=1000000 z-1000000”。总的来说,我的解决方案是“A=1000000 z-1000000;bin z;”,而不是“A/B>=0”?非常感谢。我认为这是一个很大的帮助vor每个lp_解决初学者:)谢谢。使用“A>=-1000;B>=-1000;”将计算A和B。但解决方案仍然没有对结果产生任何影响。从理论上讲,用这样的东西来重新拼凑一个除法,可能吗?A>=-1000;B>=-1000;A=1000z-1000;宾z;谢谢你的帮助。使用“A>=-1000;B>=-1000;”将计算A和B。但解决方案仍然没有对结果产生任何影响。从理论上讲,用这样的东西来重新拼凑一个除法,可能吗?A>=-1000;B>=-1000;A=1000z-1000;宾z;我将感谢任何帮助。