当前位置:文档之家 > 0-1整数规划隐枚举法代码 (直接复制及可运行)

0-1整数规划隐枚举法代码 (直接复制及可运行)

华北电力大学

数理系邵森

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace zhengshuguihuayinmeijufa

{

public class Program

{

public static int Min(int[] V)

{

int min = V[0];

for (int i = 0; i < V.Length-1 ; i++)

for (int j = 1; j < V.Length ; j++)

{

if (min > V[j])

min = V[j];

}

return min;

}

public static int Max(int[] V)

{

int max = V[0];

for (int i = 0; i < V.Length - 1; i++)

for (int j = 1; j < V.Length; j++)

{

if (max

max = V[j];

}

return max;

}

public static int PaiDing(int [,] T,int a, int b, int c,int d,int e,int f,int g,int t,in
t L,int H,int U,int []M) {

public static int PaiDing(int [,] T,int a, int b, int c,int d,int e,int f,int g,int t,int L,int H,int U,int []M) {

if (U == 3)

{

int m = 0;

for (int i = 0; i < H; i++)

{

int j = 0;

if ((a * T[i, j] + b * T[i, j + 1] + c * T[i, j + 2] <= T[i, 3]))

m++;

}

if (m == H )

t = a * M[0] + b * M[1] + c * M[2];

}

if (U == 4)

{

int m = 0;

for (int i = 0; i < H; i++)

{

int j = 0;

if ((a * T[i, j] + b * T[i, j + 1] + c * T[i, j + 2] + d * T[i, 3] <= T[i, 4]))

m++;

}

if (m == H )