MicroCity NotesMicroCity Notes
Notes
  • MicroCity Web
  • MicroCity Desktop

    • 1. MicroCity Introduction
    • 2. Getting Started with MicroCity
    • 3. User Interface
    • 4. Script Writing
  • GitHub

    • MicroCity Desktop Repository
    • MicroCity Web Repository
    • MicroCity Web Online Environment
  • 简体中文
  • English
Notes
  • MicroCity Web
  • MicroCity Desktop

    • 1. MicroCity Introduction
    • 2. Getting Started with MicroCity
    • 3. User Interface
    • 4. Script Writing
  • GitHub

    • MicroCity Desktop Repository
    • MicroCity Web Repository
    • MicroCity Web Online Environment
  • 简体中文
  • English
  • MicroCity Documentation

    • Table of Contents
    • 1. MicroCity Introduction

      • 1.1 What MicroCity can Do
    • 2. Getting Started with MicroCity

      • 2.1 Showing a World Map
      • 2.2 Searching for Countries
    • 3. User Interface

      • 3.1 UI Overview
      • 3.2 Vector Shapes
      • 3.3 Raster Grids
      • 3.4 3D Scenes
      • 3.5 Tables
      • 3.6 Maps and Layers
      • 3.7 Modules
    • 4. Script Writing

      • 4.1 SI Overview
      • 4.2 UI Control
      • 4.3 Shapes and Tables
      • 4.4 Grids
      • 4.5 3D Scenes
      • 4.6 Networks
      • 4.7 Discrete Event Simulations
      • 4.8 Mixed Integer Programming

4.8 Mixed Integer Programming

MicroCity employs the lpsolve to takle Mixed Integer Linear Programming problems. Developers can use embedded Lua functions to build and solve models. Sample codes for this chapter can be found in the "optimization_samples" folder of the Project Tab in iconScriptEditor.

Model Creation and Execution

CreateLP ([rows = 0 , columns = 0])

Creates a Mixed Integer Linear Programming model and returns the LPModel object.

SetObjFunction (LPModel, rowTable, "MAX"|"MIN")

Sets the objective function of a LPModel with a Lua Table which stores coefficients of the decision variables.

AddConstraint (LPModel, rowTable, "<="|">="|"==", rhsValue)

Adds a constraint to a LPModel with a Lua Table which stores coefficients of the decision variables.

SetInteger (LPModel, index)

Sets a decision variable specified by the index as an integer variable.

SetBinary (LPModel, index)

Sets a decision variable of a LPModel specified by the index as a binary variable.

SetUnbounded (LPModel, index)

Sets a decision variable of a LPModel to be unbounded(+/- infinity).

SolveLP (LPModel [, timeoutSec = 60])

Solves a LPModel and returns 0 as success, -1 as invalid LP model, -2 as nomemory, 1 as suboptimal, 2 as infeasible, 3 as unbounded, 4 as degenerate, 5 as a numerical failure encountered, 6 as the user abort, 7 as a timeout error, 9 as the model could be solved by presolve, 10 as the B&B routine failed, 11 as the B&B was stopped because of a break-at-first, 12 as a feasible B&B solution was found, 13 as no feasible B&B solution found.

GetObjective (LPModel)

Returns the objective function value of a LPModel.

GetVariable (LPModel, index)

Returns the value of a decision variable specified by the index.

GetVariables (LPModel)

Returns all values of the decision variables of a LPModel.

GetDual (LPModel, index)

Returns the dual value of a decision variable specified by the index.

GetDuals (LPModel)

Returns all dual values of the decision variables of a LPModel.

ReadLP("fileName.mps")

Reads a LPModel from a file (*.lp, *.mps) and returns the LPModel if succeed.

WriteLP (LPModel, "fileName.mps")

Writes a LPModel to a file (*.lp, *.mps) and returns true if succeed.

Last Updated:
Contributors: huuhghhgyg
Prev
4.7 Discrete Event Simulations