lpsolve is a toolkit for linear programming. One of the compelling features of lpsolve is mulit-language support. Certainly, .net is one among them.
here, i would like to demonstrate how to use lpsolve for a simple problem:
max: 143*x1+60*x2
subject to:
120*x1+210*x2 <= 13000.23
110*x1+30*x2 <= 4000
x1+x2 <= 75
x1 >= 0
x2 >= 0
x1 is an integer
Due to x1 is an integer, so it is a mips program (mixed integer linear programming)
let's see how lpsolve to solve this problem.
int lp;
lp = lpsolve.make_lp(0, 2);
lpsolve.set_maxim(lp);
lpsolve.set_obj(lp, 1, 143);
lpsolve.set_obj(lp, 2, 60);
lpsolve.add_constraint(lp, new double[] {0, 120, 210 }, lpsolve.lpsolve_constr_types.LE, 13000.23);
lpsolve.add_constraint(lp, new double[] { 0,110, 30 }, lpsolve.lpsolve_constr_types.LE, 4000);
lpsolve.add_constraint(lp, new double[] { 0, 1, 1 }, lpsolve.lpsolve_constr_types.LE, 75);
lpsolve.add_constraint(lp, new double[] { 0, 0, 1 }, lpsolve.lpsolve_constr_types.GE, 0);
lpsolve.set_int(lp, 1, true);
lpsolve.solve(lp);
lpsolve.print_lp(lp);
lpsolve.print_solution(lp, 1);
lpsolve.print_solution(lp, 2);
lpsolve.delete_lp(lp);
the codes are quite straightforward. we first initiliaze a lp object represented by lp... and then we set object function, add constraints in turn, finally, we get the solution.
caveats:
remember delete lp after use.
column is an off one array. so column[0] is a placeholder only, calculate position starts from one.
don't forget to copy .dll to the current dir..
分享到:
相关推荐
标题提到的"A basic example on how to transfer files across the network"是一个简单示例,演示了如何利用WinSock控件进行网络间的文件传输。WinSock控件是Windows Socket接口的一个封装,允许程序员在Visual ...
Differential Equations are somewhat pervasive in the description of natural phenomena and the theory of Ordinary Differential Equations is a basic framework where concepts, tools and results allow a ...
Anderson P.W. Basic notions of condensed matter physics (1984).djvu
标题中的"A simple example of exchanging data across a network using t"似乎是指使用特定技术(可能是WinSock)在网络间交换数据的一个简单示例。这个示例可能是针对初学者或开发者,旨在教授如何利用网络通信类...
A_basic_configuration_of_A_project_for_the_MSPM0L1_MSPM0L1106-basic-MSPM0L1106-basic-RUST-CONFIG_A_basic_configuration_of_a_project_for_the_MSPM0L1_MSPM0L1306-BASIC-RUST-CONFIG.zipRUST-CONFIG_A_basic_...
Basic notions of independence and conditional expectation are introduced relatively early on in the text, while conditional expectation is illustrated in detail in the context of martingales, Markov ...
《Visual Basic 6.0应用编程150例》是一本深入浅出的编程教程,旨在帮助学习者掌握使用Visual Basic 6.0进行应用程序开发的技术。在这个教程中,两个特定的例子——《Example095-媒体文件浏览器》和《Example096-...
have provided basic insights into the structure and bulk properties of condensed phases of matter, including low-temperature states (e.g., molecular and colloidal liquids, crystals, and glasses), ...
**B4A (Basic For Android) 5.50 全功能版本** B4A(Basic For Android)是一款强大的编程工具,它允许开发者使用简单的BASIC语言来创建Android应用程序。这款软件将经典的BASIC语法与现代移动应用开发相结合,极大...
Anirudh-Munnangi-Forex-Forecasting--A-basic-example-using-neural-networks-archive-refs-heads-master.zip
《现代雷达原理》是一本深入介绍雷达技术基础的专著,由Mark A. Richards、James A. Scheer 和 William A. Holm 联合撰写,出版于2010年。本书全面覆盖了雷达的基本原理、关键技术和应用案例等内容,旨在为读者提供...
《Visual Basic监控文件夹实战教程》 在编程领域,Visual Basic是一种广泛使用的编程语言,尤其在Windows应用程序开发中。本文将深入探讨一个优秀的Visual Basic示例,它涉及到如何监控文件夹的变化,这对于系统...
A Basic Tutorial of SPSS
In a way, earlier versions of Visual Basic were ‘sandboxed’ to protect developers from scary details. Microsoft had to redesign Visual Basic. The old language just didn’t belong in the .NET pic- ...
### Visual Basic.NET By Example #### 一、简介与概述 《Visual Basic.NET By Example》是一本专注于教授初学者如何使用Visual Basic.NET进行编程的书籍。本书由Gabriel Oancea和Bob Donald共同编写,旨在通过...
First Project - Creating a Basic To-Do List App Advanced Functionality and Styling the To-Do List App Our Second Project - The Budgeting App Advanced Functionality with the Expenses App Third Project ...
描述中的"straight forward example"暗示这可能是一个简单的步骤指南,教用户如何通过编程或系统设置来实现目标。在Windows 95和98时代,这样的操作通常需要对系统注册表、控制面板设置或使用特定的API函数有一定...
By Rutherford Aris. 虽然是很早以前出版的书,但对于学习向量张量是很好的教材
Basic4android 是一个简单但功能强大的 Android 应用开发环境。Basic4android 语言跟 Visual Basic 予以类似,支持更多的对象。Basic4android 将代码编译成 Android 原生应用,无需其他运行环境的支持。这个就是2020...