taller gusek U Distrital

download taller gusek U Distrital

of 52

Transcript of taller gusek U Distrital

Programacin Matemtica utilizado GUSEK Modelacin en GMPL

1

Introduction

GNU MathProg is a modeling language intended for describing linear mathematical programming models. The GNU MathProg language is a subset of the AMPL language. Its GLPK implementation is mainly based on the paper: Robert Fourer, David M. Gay, and Brian W. Kernighan, A Modeling Language for Mathematical Programming. Management Science 36 (1990) pp. 519-54.

2

Linear Program

3

Model Objects

In MathProg the model is described in terms of sets, parameters, variables, constraints, and objectives, which are called model objects. The user introduces particular model objects using the language statements. Each model object is provided with a symbolic name that uniquely identies the object and is intended for referencing purposes.4

Model Objects

Model objects, including sets, can be multidimensional arrays built over indexing sets.

5

Structure of Model Description

It is sometimes desirable to write a model which, at various points, may require dierent data for each problem to be solved using that model. For this reason in MathProg the model description consists of two parts: model section and data section. Model section is a main part of the model description that contains declarations of model objects and is common for all problems based on the corresponding model. Data section is an optional part of the model description that contains data specic for a particular problem.6

Symbolic Names

A symbolic name consists of alphabetic and numeric characters, the rst of which must be alphabetic. All symbolic names are distinct (case sensitive). Examples

alpha123 This_is_a_name _P123_abc_321

Symbolic names are used to identify model objects (sets, parameters, variables, constraints, objectives) and dummy indices.7

Numeric literals

Numeric literal has the form xxEsyy, where xx is a real number with optional decimal point, s is the sign + or -, yy is an integer decimal exponent. The letter E is case insensitive and can be coded as e. Examples

123 3.14159 56.E+5 .78 123.456e-78

Reserved Keywords

9

Delimiters

10

Comments

11

Numeric Expressions

12

Numeric Expressions

13

Built-in Functions

14

Built-in functions

15

Iterated Expressions

16

Conditional Expressions

17

Arithmetic Operators

18

Symbolic Expressions

19

Indexing mechanisms

20

Relational Expressions

21

Logical operators

22

Linear Expressions

23

Statements

Declaration statements (set statement, parameter statement, variable statement, constraint statement, and objective statement) are used to declare model objects of certain kinds and dene certain properties of that objects. Functional statements (solve statement, check statement, display statement, printf statement, loop statement) are intended for performing some specic actions. Note that declaration statements may follow in arbitrary order which does not aect the result of translation. However, any model object must be declared before it is referenced in other statements.24

Examples Set statement

25

Examples Parameter statement

26

Examples Variable statement

27

Examples Constraint statement

28

Examples Objective statement

29

Examples For statement

30

Set Data Block

31

Data Records Examples

32

Introduccin a Programacin Entera Mixta (I.P. Integer Programming and Mixed I.P.) E. Puente.

33

Definiciones iniciales

Problema de programacin entera pura: Todas las variables involucradas toman solamente valores enteros. Problema de programacin entera mixta: Algunas de las variables toman solo valores enteros. Problema de programacin entera binaria: Problema de programacin entera en el cual las variables enteras solo toman los valores de 0 y 1.34

Problema de costo fijo

Este problema surge cuando hay un costo fijo en que se incurre por realizar una actividad, independientemente del nivel al que se desarrolle la actividad, pero en el cual no se incurre si la actividad no se lleva a cabo. Adems existe un costo variable asociado con el nivel al cual se desarrolla la actividad. Por ejemplo, la produccin en una mquina conlleva un costo fijo independiente del volumen de produccin, ms un costo variable unitario constante por cada unidad producida.

35

Ejemplo de Costo Fijo

Una empresa desea maximizar sus utilidades al producir prendas de vestir (shorts, camisetas y pantalones). La empresa puede producir cualquiera de los tres tipos de prendas, o dos tipos, o uno solo, pero si decide producir alguno tiene que rentar la mquina que necesita para ese tipo de prenda, aunque produzca solo una unidad. Cules prendas debe fabricar? Cuntas unidades de cada prenda?

36

Ejemplo de costo fijoTipo de Mquina Camiseta Short Pantaln Renta Semanal $200 $150 $100Mano de Obra (horas por unidad) 3 2 6 150 Tela (m2) 4 3 4 160

Camiseta Short Pantaln Disponibilidad semanal

Camiseta Short Pantaln

Precio de Venta $12 $8 $15

Costo Variable Unit. $6 $4 $837

Restricciones para el modelo de Costo Fijo

Para obtener la solucin correcta del problema se deben aadir las siguientes restricciones:

x 1 M 1 y1 x2 M 2 y2 x3 M 3 y3Los valores de M se seleccionan suficientemente grandes, tratando de encontrar el mnimo valor adecuado (cualquier valor de M suficientemente grande es adecuado).

38

Formulacin final

max z = 6x1 +4x 2 +7x 3 200y 1 150y 2 100 y 3 s.t. : 3x 1 +2x 2 +6x 3 150 4x1 +3x 2 +4x 3 160 x 1 40y 1 x 2 53y 2 x 3 25y 3 x 1, x 2, x 3 0 ; y1, y 2, y 3 = 0 1.Los valores de las M's en este ejemplo son 40, 53 y 25, por qu?. Ntese que cualquier valor mayor a estos, por ejemplo los 3 iguales a 10000 funcionaran. Sin embargo, se busca en los posible usar valores de M apenas suficientemente grandes, porque valores muy grandes afectaran la precisin de la solucin numrica del problema, por las diferencias de magnitud de los coeficientes del problema.

39

Formulacin para GUSEK/* Variables*/ var x1 >=0 ; var x2>=0 ; var x3>=0 ; var y1, binary ; var y2, binary; var y3, binary; /*Funcin Objetivo*/ maximize utilidad: 6*x1 + 4*x2 + 7*x3 - 200*y1 - 150*y2 - 100*y3; /*Mano de Obra*/ s.t. M_de_O: 3*x1 + 2*x2 + 6*x3