精华内容
下载资源
问答
  • CPLEX

    2019-09-27 08:06:48
    http://blog.sina.com.cn/s/blog_50c154510100gmnb.html (貌似对cplex很熟悉) ... ...用cplex跑了一个960*640*3个变量的线性优化,跑了一个月没出结果。。。。有点忧伤 转载于:https://www.cnblo...

    http://blog.sina.com.cn/s/blog_50c154510100gmnb.html (貌似对cplex很熟悉)

    http://blog.csdn.net/rrerre/article/details/9171627

     

     

    用cplex跑了一个960*640*3个变量的线性优化,跑了一个月没出结果。。。。有点忧伤

    转载于:https://www.cnblogs.com/zhanxiage1994/p/6116470.html

    展开全文
  • cplex

    2011-05-17 08:57:00
    using ILOG.Concert;using ILOG.CPLEX;using System;public class Rand { public int[] iResult = new int[1000]; public void random_int(int iDown, int iUp , int number) { Random ro ...
    using ILOG.Concert;
    using ILOG.CPLEX;
    using System;

    public class Rand {
        public int[] iResult = new int[1000];


        public void random_int(int iDown, int iUp , int number)
        {    
           Random ro = new Random();
               
            for (int i = 0; i < number; i++)
            {
               iResult[i] = ro.Next(iDown, iUp);         
            }  

        }
    }

    public class CLSP
    {
        internal static double M = 10000;
        internal static int Up = 10;
        internal static int Down = 1;
        internal static int Period = 50;
        internal static int Product = 20;
        internal static int[][] Demand =new int[Product][];
        internal static double[] Process_time = new double[Product];


        internal static double[] Cost_production =new double[Product];
        internal static double[] Cost_inventory = new double[Product];
        internal static double[] Cost_setup = new double[Product];
        internal static double Cost_PM = 1000;
        internal static int Capacity = 500;
        internal static int PM_length = 1000;

        public static void Main(string[] args)
        {



            for (int i = 0; i < Product; i++)
            {
                Rand rand = new Rand();
                 rand.random_int(1, 5, Product);
                 Process_time[i] = rand.iResult[i];
                 Console.WriteLine(" {0}/ ", Process_time[i]);
                Cost_production[i]=5 ;
                Cost_inventory[i] = 2;
                Cost_setup[i] = 20;
                Demand[i] = new int[Period];
            }

          //  Console.Read();

        


              for (int i= 0; i < Product; i++)
                 {          
                     for (int j = 0; j < Period; j++)                       
                     {
                         Rand rand = new Rand();
                         rand.random_int(Down, Up, Period);
                      
                          Demand[i][j] = rand.iResult[j];
                         Console.Write(" {0}/ ",Demand[i][j]);
                     }
                     Console.WriteLine("  ");
                 }
         
                
        //  Console.Read();

             

           
                try
                {
                    Cplex cplex = new Cplex();
                    INumVar[][] x = new INumVar[Product][];
                    INumVar[] w = new INumVar[Period];
                    INumVar[] u = new INumVar[Period];
                    for (int i = 0; i < Product; i++)
                    {
                        x[i] = cplex.IntVarArray(Period, 0, 1000);  //production is above or equal to zero
                    }
                    for (int i = 0; i < Period; i++)
                    {
                        w[i] = cplex.NumVar(0, M);
                        u[i] = cplex.BoolVar(); 
                    }
                    INumVar[][] y = new INumVar[Product][];
                    for (int i = 0; i < Product; i++)
                    {
                        y[i] = cplex.BoolVarArray(Period);              //yit either 0 or 1
                    }


                    INumVar[][] I = new INumVar[Product][];
                    for (int i = 0; i < Product; i++)
                    {
                        I[i] = cplex.IntVarArray(Period, 0, 1000);      //inventory is above or equal to zero 
                    }



                    // Objective Function: Minimize Cost
                    ILinearNumExpr ProdCost = cplex.LinearNumExpr();
                    ILinearNumExpr SetCost = cplex.LinearNumExpr();
                    ILinearNumExpr InvCost = cplex.LinearNumExpr();
                    ILinearNumExpr PMCost = cplex.LinearNumExpr();

                    for (int i = 0; i < Product; i++)
                    {
                        for (int t = 0; t < Period; t++)
                        {
                            ProdCost.AddTerm(Cost_production[i], x[i][t]);
                            SetCost.AddTerm(Cost_setup[i], y[i][t]);
                            InvCost.AddTerm(Cost_inventory[i], I[i][t]);
                           
                        }
                    }
                    for (int t = 0; t < Period; t++)
                    {
                        PMCost.AddTerm(Cost_PM, u[t]);
                    }
                    cplex.AddMinimize(cplex.Sum(ProdCost, SetCost, InvCost, PMCost));

                    //the capacity constraint
                    for (int t = 0; t < Period; t++)
                    {
                        ILinearNumExpr time_sum= cplex.LinearNumExpr();
                        for (int i = 0; i < Product; i++)
                        {
                            time_sum.AddTerm(Process_time[i], x[i][t]);
                        }
                        cplex.AddEq(u[0], 1);
                      if (t == 0)
                        {
                            cplex.AddEq(w[0], time_sum);
                          
                        }
                       if(t>0) cplex.AddGe(cplex.Diff(w[t], time_sum), cplex.Diff(w[t-1], cplex.Prod(u[t],M)));
       
                            cplex.AddGe(w[t], time_sum);
                            cplex.AddLe(w[t],PM_length);
                 
                            cplex.AddLe(time_sum, Capacity);
                      
                  
                     
                    }

                    //constraint between Xit and Yit
                    for (int i = 0; i < Product; i++)
                    {
                        for (int t = 0; t < Period; t++)
                        {
                            cplex.AddLe(x[i][t], cplex.Prod(M, y[i][t]));
                        }
                    }

                    //equation of the production and inventory

                    for (int i = 0; i < Product; i++)
                    {

                        cplex.AddGe(x[i][0], Demand[i][0]);
                        cplex.AddEq(cplex.Sum(I[i][0], Demand[i][0]), x[i][0]);

                        for (int t = 1; t < Period; t++)
                        {
                            cplex.AddEq(cplex.Sum(x[i][t], I[i][t - 1]), cplex.Sum(Demand[i][t], I[i][t]));
                        }
                    }
                    for (int i = 0; i < Product; i++)
                    {

                        cplex.AddLe(w[i], PM_length);
                        cplex.AddEq(cplex.Sum(I[i][0], Demand[i][0]), x[i][0]);

                        for (int t = 1; t < Period; t++)
                        {
                            cplex.AddEq(cplex.Sum(x[i][t], I[i][t - 1]), cplex.Sum(Demand[i][t], I[i][t]));
                        }
                    }

                    if (cplex.Solve())
                    {



                        System.Console.WriteLine();
                        System.Console.WriteLine("Total cost = " + cplex.ObjValue);

                        System.Console.WriteLine();
                      System.Console.WriteLine("\tp\tt\tx\ty\tInventory");

                      for (int i = 0; i < Product; i++)
                      {
                          for (int t = 0; t < Period; t++)
                          {
                              double x_s = cplex.GetValue(x[i][t]);
                              double y_s = cplex.GetValue(y[i][t]);
                              double I_s = cplex.GetValue(I[i][t]);
                              System.Console.WriteLine("\t" + i + "\t" + (t + 1) + "\t" + cplex.GetValue(x[i][t])+ "  "+x_s +
                                                       "\t" + cplex.GetValue(y[i][t]) + "  "+y_s + "\t" + cplex.GetValue(I[i][t]));
                          }
                      }



                        System.Console.WriteLine("Total cost = " + cplex.ObjValue);         
                          
                               for (int t = 0; t < Period; t++)
                               {
                                   System.Console.WriteLine("\t" + cplex.GetValue(u[t]) +"\t"+ cplex.GetValue(w[t]));
                               }
                          
                        cplex.End();
                    }
                }
                catch (ILOG.Concert.Exception exc)
                {
                    System.Console.WriteLine("Concert exception '" + exc + "' caught");
                }
            Console.Read();

        }



    }

    转载于:https://www.cnblogs.com/elitez/archive/2011/05/17/2048451.html

    展开全文
  • cplex12 CPLEX权威教程

    2021-04-21 08:36:49
    本资源包含8章:(1)Introduction (2)How to Run a Model with Cplex (3) Overview of Cplex(3.1 Linear Programming 3.2 Quadratically Constrained Programming 3.3 Mixed-Integer Programming 3.4 Feasible...
  • 所以打算学习一下cplex这个商业求解器。 当然也有其他更多的选择,这里暂时以比较容易上手和性能比较好的cplex开始吧。其实,小编也早就想学习使用这个cplex了,毕竟是个好东西。 所以打算出一系列教程推出,大家...

    前言

    最近学习列生成算法,需要用到优化求解器。所以打算学习一下cplex这个商业求解器。

    当然也有其他更多的选择,这里暂时以比较容易上手和性能比较好的cplex开始吧。其实,小编也早就想学习使用这个cplex了,毕竟是个好东西。

    所以打算出一系列教程推出,大家可以关注我们获取后续教程的更新哦。

    关注我们的公众号哦!获取更多精彩消息!

    Cplex是什么?

    Cplex是IBM公司开发的一款商业版的优化引擎,当然也有免费版,只不过免费版的有规模限制,不能求解规模过大的问题。

    Cplex专门用于求解大规模的线性规划(LP)、二次规划(QP)、带约束的二次规划(QCQP)、二阶锥规划(SOCP)等四类基本问题,以及相应的混合整数规划(MIP)问题。

    优势:

    • 能解决一些非常困难的行业问题;
    • 求解速度非常快;
    • 提供超线性加速功能的优势。

    在Cplex的加持下,使得matlab对于大规模问题,以及线性规划的效率,都得到飞跃的提升。

    Cplex下载和安装

    鉴于官网下载太复杂,这里已经申请了教育认证版,需要的同学可以关注公众号,在菜单栏【资源下载】可以找到相关的下载。

    直接下载下来安装即可,注意这是64位系统版的。

    至于安装,非常简单,一路下一步即可。

    展开全文
  • CPLEX 在matlab中实现的一个例子-RCPSP
  • cplex Example

    2021-04-21 08:43:15
    两个cplex实例文件
  • cplex的实例调用使用例子,可以作参考学习
  • cplex jar

    2014-12-29 08:31:28
    cplex jar
  • CPLEX-master_withoutghp_cplex_CPLEX在matlab上调用实例_源码.zip
  • CPLEX中文教程

    2020-06-27 10:32:34
    完整版的CPLEX教程,共八章。CPLEX入门者必备资料 完整版的CPLEX教程,共八章。CPLEX入门者必备资料
  • CPLEX-master_withoutghp_cplex_CPLEX在matlab上调用实例_源码.rar
  • IBM ILOG CPLEX Optimization Studio CPLEX User’s Manual 12.8
  • Cplex 12.5

    2019-01-27 15:47:43
    Cplex,数学规划优化程序,方便的与Matlab接口,解决线性规划 (Linear Programming)、二次方程规划 (Quadratic Programming)、二次方程约束规划 (Quadratically Constrained Programming) 和混合整型规划 (Mixed ...
  • cplex 教程

    2013-12-17 21:48:03
    cplex 教程
  • cplex 12.4 MATLAB工具箱使用方法
  • cplex说明文档

    2018-01-06 12:54:53
    Cplex说明,IBM ILOG CPLEX Optimization Studio CPLEX User’s Manual
  • cplex 12_northxv5_matlab使用方法_taught3s1_cplex_cplex12.4下载.zip
  • cplex 12.6

    热门讨论 2015-10-23 09:10:36
    cplex 比lingo更加专业化,是一款在国内逐渐火热的数学模型处理软件,能够与python语言及matlab相互配合使用,更加方便
  • cplex manu

    2015-02-10 17:55:12
    CPLEX完整的使用和建模说明以及实例!
  • Cplex Mac版

    2020-12-18 02:04:39
    Cplex Mac版,资源来源于IBM官网。速度下载比较慢,所以搬过来,供大家免费下载。
  • cplex 12_northxv5_matlab使用方法_taught3s1_cplex_cplex12.4下载_源码.rar
  • python 下使用 cplex

    万次阅读 多人点赞 2018-07-07 18:57:19
    最近熟悉 python,也想掌握 python 下面的 cplex 的调用,查阅了相关资料,总结如下: 1. cplex python API 的安装 网上说的比较复杂,若直接寻找 cplex 安装文件中的 install.py 文件,往往其版本跟目前 python...


    最近熟悉 python,也想掌握 python 下面的 cplex 的调用,查阅了相关资料,总结如下:

    1. cplex python API 的安装

    网上说的比较复杂,若直接寻找 cplex 安装文件中的 install.py 文件,往往其版本跟目前 python 运行的版本不一致。

    发现了一个简单的方法,直接使用 Anaconda 安装 cplex 包,因为 cplex 把自己最新的 python 包都发到 Anaconda 云里面了。
    (1)打开 dos 命令行窗口,输入:

    conda install -c IBMDecisionOptimization docplex cplex
    

    或者用 pip 安装:

    pip install cplex
    

    就能直接将 cplex 的库安装好
    (2) 在 ipython 里面输入 import cplex
    若加载成功,则证明 cplex 包已经成功添加了

    2. 简单的使用例子

    # -*- coding: utf-8 -*-
    # The MIP problem solved in this example is:
    #
    #   Maximize  x1 + 2 x2 + 3 x3 + x4
    #   Subject to
    #      - x1 +   x2 + x3 + 10 x4 <= 20
    #        x1 - 3 x2 + x3         <= 30
    #               x2      - 3.5x4  = 0
    #   Bounds
    #        0 <= x1 <= 40
    #        0 <= x2
    #        0 <= x3
    #        2 <= x4 <= 3
    #   Integers
    #       x4
    
    import cplex
    from cplex.exceptions import CplexError
    
    # data common to all populateby functions
    my_obj = [1.0, 2.0, 3.0, 1.0]
    my_ub = [40.0, cplex.infinity, cplex.infinity, 3.0]
    my_lb = [0.0, 0.0, 0.0, 2.0]
    my_ctype = "CCCI"
    my_colnames = ["x1", "x2", "x3", "x4"]
    my_rhs = [20.0, 30.0, 0.0]
    my_rownames = ["r1", "r2", "r3"]
    my_sense = "LLE"
    
    
    def populatebyrow(prob):
        prob.objective.set_sense(prob.objective.sense.maximize)
    
        prob.variables.add(obj=my_obj, lb=my_lb, ub=my_ub, types=my_ctype,
                           names=my_colnames)
    
        rows = [[["x1", "x2", "x3", "x4"], [-1.0, 1.0, 1.0, 10.0]],
                [["x1", "x2", "x3"], [1.0, -3.0, 1.0]],
                [["x2", "x4"], [1.0, -3.5]]]
    
        prob.linear_constraints.add(lin_expr=rows, senses=my_sense,
                                    rhs=my_rhs, names=my_rownames)
    
    try:
        my_prob = cplex.Cplex()
        handle = populatebyrow(my_prob)
        my_prob.solve()
        
    except CplexError as exc:
        print(exc)
    
    print()
    # solution.get_status() returns an integer code
    print("Solution status = ", my_prob.solution.get_status(), ":", end=' ')
    # the following line prints the corresponding string
    print(my_prob.solution.status[my_prob.solution.get_status()])
    print("Solution value  = ", my_prob.solution.get_objective_value())
    
    numcols = my_prob.variables.get_num()
    numrows = my_prob.linear_constraints.get_num()
    
    slack = my_prob.solution.get_linear_slacks()
    x = my_prob.solution.get_values()
    
    print('x: ')
    print(x)      
    

    输出:
    Solution status = 101 : MIP_optimal
    Solution value = 122.5
    x:
    [40.0, 10.5, 19.5, 3.0]

    3. 使用感受

    • 尽管 python 比较火,cplex 对 python 的支持目前还不是太全
    • 相关的学习资料比较少,ibm 自己出的资料对 python 包的介绍也很简略,例子及相关类方法的介绍也不详细,这一点远没有对 java 或 c++ 支持地好。
    • cplex 在 python 中没有重载加减乘除符号吗?目前给的例子都是输入系数矩阵这种形式。使用起来非常不方便的。
    展开全文
  • CPLEX教程.zip

    2021-04-21 08:31:59
    CPLEX教程,PPT形式,包含了CPLEX的实际例子,入门必备资料。
  • java -Djava.library.path=/Applications/CPLEX_Studio128/cplex/bin/x86-64_osx -cp .:/Applications/CPLEX_Studio128/cplex/lib/cplex.jar HelloCplex Press CTRL+C to terminate 输出示例如下: Tried ...
  • cplex使用介绍

    2017-08-23 21:37:33
    ilog-cplex使用介绍
  • CPLEX.jar(CPLEX125)

    2013-04-14 14:43:32
    CPLEX.jar(CPLEX125),可以在java中进行调用
  • getting started with Cplex

    2018-05-24 18:35:53
    getting started with Cplex. Cplex user guide
  • java 调用 cplex

    万次阅读 热门讨论 2017-11-30 17:28:04
    最近使用 java 调用 cplex, 发现 cplex 对 java 的支持比对matlab强大多了,类跟方法有几百个。 但这些类和方法的注释并不是特别详细,还需要结合例子来看懂。 一、 准备工作:导入 cplex 库 到 eclipse ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 2,191
精华内容 876
关键字:

cplex