Sub OPT() j = 1 k = 1 m = 1 n = 1 o = 1 g = 1 h = 1



Similar documents
Schema XML_PGE.xsd. element GrupoInformes. attribute XML_PGE.xsd unqualified qualified

Work Instruction (Instruccion de Trabajo) Wistron InfoComm (Texas) Corp.

Ranking de Universidades de Grupo of Eight (Go8)

PROGRAMA DE GRAFICACIÓN DE VELOCIDADES EN VENTANAS DE MAPINFO

Sales Management Main Features

Práctica 1: PL 1a: Entorno de programación MathWorks: Simulink

EUROCALCULADORA. Option Compare Database. Private Sub Comando4_Click() [pesetas] = [euros] * End Sub

Public Sector Enterprises (Combined Use of IPSAS and IFRS) Marcia Maurer August 2, 2013

Bucle for_in. Sintaxis: Bucles for_in con listas. def assessment(grade_list): """ Computes the average of a list of grades

Versión precedente* Lista productos disponibles** Disponible desde el June 1, 2013

VaughanTown. Newsletter 5:...Last Words. Last Words and Recommendations Last Reminder Meeting point map.

Ecuador Official visa Application

DIFFERENTIATIONS OF OBJECTS IN DIFFUSE DATABASES DIFERENCIACIONES DE OBJETOS EN BASES DE DATOS DIFUSAS

Despliegues en la Plataforma Cloud AWS Antonio Alvarez EMEA Business Developer Manager. SAP Forum Madrid, 12 Marzo 2015

Física Computacional Conceptos de programación.

Resumen de Entrevista: Asociación de Agentes de Aduana del Puerto de Manzanillo

BALANCE DUE 10/25/2007 $ STATEMENT DATE BALANCE DUE $ PLEASE DETACH AND RETURN TOP PORTION WITH YOUR PAYMENT

Problem 1 (1.5 points)

CITY OF LAREDO Application for Certification of Compliance for Utility Connection ($ Application Fee Ordinance No.

Dictionary (catálogo)

Fecha: 04/12/2010. New standard treatment for breast cancer at early stages established

SOLICITUD DE DEVOLUCIÓN, REALIZADA POR UN CONTRIBUYENTE, DE RETENCIONES SOBRE DIVIDENDOS OBTENIDOS A PARTIR DE 1 DE ENERO DE 2011.

Application for Admission School Year

Verbos modales. In this class we look at modal verbs, which can be a tricky feature of English grammar.

INFORMATIONAL NOTICE

Application for Admission School Year

Tema: Encriptación por Transposición

EE 1130 Freshman Eng. Design for Electrical and Computer Eng.

Por qué ExecuTrain? Por qué ExecuTrain? Modalidad de servicio

Propiedades del esquema del Documento XML de envío:

SUBCHAPTER A. AUTOMOBILE INSURANCE DIVISION 3. MISCELLANEOUS INTERPRETATIONS 28 TAC 5.204

Estructura de aplicación en PHP para System i

Plan for: Preliminary Lessons Spanish Señora Franco

PWB Management Corporation 3092 Hull Avenue, Bronx, NY Tel:(718) Fax: (718)

ISC Spain. Enjoy a unique experience.

OFFICE OF COMMON INTEREST COMMUNITY OMBUDSMAN CIC#: DEPARTMENT OF JUSTICE

SUBCHAPTER A. AUTOMOBILE INSURANCE DIVISION 3. MISCELLANEOUS INTERPRETATIONS 28 TAC 5.204

PROCEDIMIENTOPARALAGENERACIÓNDEMODELOS3DPARAMÉTRICOSA PARTIRDEMALLASOBTENIDASPORRELEVAMIENTOCONLÁSERESCÁNER

Benedictine College Financial Aid

ipod 5 owners manual ipod 5 owners manual

DIPLOMADO EN BASE DE DATOS

Water IBITEL CATALOGUE IBITEL WATER

Daytime Telephone Number (Número Telefónico) Date of Application (Fecha) County (Condado)

New words to remember

Enrollment Forms Packet (EFP)

RISC Processor Simulator (SRC) INEL 4215: Computer Architecture and Organization September 22, 2004

Update of the NOTAM Contingency Plan. (Presented by the Secretariat) Summary

Received by NSD/FARA Registration Unit 06/25/2012 3:30:37 PM

ATTENTION TRAINERS AND BOOKKEEPERS

Modificación de los Gastos operativos y de administración en JPMorgan Investment Funds y JPMorgan Funds

MEDICATION RETRIEVAL FROM SCHOOLS

Apéndice C: Código Fuente del Programa DBConnection.java

Special Programs. Extended Day/Week Tutorial Program Guidelines

En esta guía se encuentran los cursos que se recomiendan los participantes en la implementación de un SGEn en dependencias del Gobierno Federal.

FAMILY INDEPENDENCE ADMINISTRATION Seth W. Diamond, Executive Deputy Commissioner

New words to remember

Stages of Family Recovery

Lista de Condiciones y Reglas

PATIENT'S INFORMATION REGISTRATION SHEET / INFORMACION DEL PACIENTE

FORMULARIO DE INSCRIPCIÓN

Control of a variety of structures and idioms; occasional errors may occur, but

Tax Court of New Jersey

Visión general de la integración con asanetwork

APPLICATION CHECKLIST. If making a copy of the application, please print out each paper in the corresponding color

PA (Process. Areas) Ex - KPAs

LOS ANGELES UNIFIED SCHOOL DISTRICT REFERENCE GUIDE

Commercial Invoice. Terms and Conditions of Delivery and Payment (incoterms)

Contents. Introduction Chapter 1 Articles Chapter 2 Nouns Chapter 3 Adjectives Chapter 4 Prepositions and Conjunctions...

ECCAIRS 5 Instalación

0530 SPANISH (FOREIGN LANGUAGE)

LOS ANGELES UNIFIED SCHOOL DISTRICT REFERENCE GUIDE

David Peña, EMSD Specialist Systems Engineer, EMC. #EMCTour. Copyright 2015 EMC Corporation. All rights reserved.

Owatonna - BCBSF Library Initiative Evaluation Plan Template March Data to be collected

Leave house 1st class starts. Listen and draw the hands of the clocks. What time is it now? Write the time now in two different ways.

New Server Installation. Revisión: 13/10/2014

THE FOUR AMBASSADORS ASSOCIATION, INC.

A. Before you read the text, answer the following question: What should a family do before starting to look for a new home?

Polyurea Marking Material Project/ Proyecto de Materiales para Señalización de Poliurea

OMEGA SOFT WF RISKEVAL

Information Regarding / Información acerca de Unlicensed Money Transmitter / Your Personal Information /

Project AGUA Survey Results

How To Know If An Ipod Is Compatible With An Ipo Or Ipo (Sanyo)

Curso SQL Server 2012 para Desarrolladores

How To Apply For A Job At American Works, Inc.

TIDEHAVEN INDEPENDENT SCHOOL DISTRICT ENGLISH AS A SECOND LANGUAGE PROGRAM. LARGO VIVE ESPAÑOL CONVERSACION mucho

Instituto Cervantes - London

LOS ANGELES UNIFIED SCHOOL DISTRICT POLICY BULLETIN

LINIO COLOMBIA. Starting-Up & Leading E-Commerce. Luca Ranaldi, CEO. Pedro Freire, VP Marketing and Business Development

General Certificate of Education Advanced Level Examination June 2014

Transcription:

Module1-1 j = 1 k = 1 m = 1 n = 1 o = 1 g = 1 h = 1 Sub OPT() Dim minpc As Integer Dim max(100) As Double Dim row_max, fday, lday As Integer Dim aux, aux2 As String Dim frow(1000) As Double Dim lrow(1000) As Double Dim max_it(1000) As Double Dim sumpc(1000) As Double Dim day_row As Double Dim fecha, date_ini, date_fin As Date Dim inicio, final, fin As Integer Dim pc_ini, pc_opt As Integer Dim sum_ini, falso As Double Dim sum_opt, starts_ini, starts_opt As Double Dim pc1(1000), pcfin(1000) As Double Dim vacio As String 'Almaceno la condición de horas PC Sheets("eficiencias").Select minpc = ActiveSheet.Cells(32, 8).Value Sheets("opt").Select 'Fechas de inicio y fin date_ini = Cells(3, 24).Value date_fin = Cells(3, 25).Value '####Almacenar el rango a optimizar#### 'vector para buscar las fechas Range("C4").Select Selection.End(xlDown).Select fin = ActiveCell.Row For t = 3 To fin Cells(t, 3).Select If (Cells(t, 3) = date_ini - 1) Then inicio = Cells(t + 1, 3).Row If (Cells(t, 3) = date_fin + 1) Then final = Cells(t - 1, 3).Row Next t 'Borro las optimizaciones anteriores Range(Cells(4, 19), Cells(fin, 22)).Select Selection.ClearContents 'Almaceno el rango de funcionamiento Range("M4").Select Cells(i, 13).Activate aux = Cells(i, 13).Value aux2 = Cells(i + 1, 13).Value If ((aux = "STOP") * (aux2 = "PC")) Then frow(j) = Cells(i + 1, 13).Row j = j + 1 If ((aux = "PC") * (aux2 = "STOP")) Then lrow(k) = Cells(i, 13).Row k = k + 1

Module1-2 'Copio el régimen inicial para compararlo con los resultados Range(Cells(inicio, 15), Cells(final + 1, 15)).Select Cells(inicio, 19).Select Range(Cells(inicio, 17), Cells(final + 1, 17)).Select Cells(inicio, 21).Select '###Almaceno las filas de los tramos correspondientes al funcionamiento For f = inicio To final + 1 Cells(f, 19).Select aux3 = Cells(f - 1, 19).Value aux4 = Cells(f, 19).Value If ((aux3 = "START2") * (aux4 = "PC")) Then pc1(g) = Cells(f, 19).Row g = g + 1 If ((aux3 = "PC") * (aux4 = "DS")) Then pcfin(h) = Cells(f - 1, 19).Row h = h + 1 Next f h = 1 Cells(inicio, 21) = 0 'Busco el máximo de cada tramo k = 1 For j = 1 To 1000 If (frow(j) = 0) Then h = j 'Almacenamiento del máximo del primer caso For l = (frow(j) - 2) To (lrow(k) + 1) max(m) = max(m) + Cells(l, 17) sumpc(n) = sumpc(n) + Cells(l, 18) Next l m = m + 1 k = k + 1 'Almacenamiento de la fila del primer máximo row_max = frow(j) '###Condición si sumpc(n) es menor que minpc para la planta parar y copiar el régimen If (sumpc(n) < minpc) Then falso = 1 Range(Cells(row_max, 13), Cells(pcfin(h), 13)) = "STOP" Cells(row_max, 3).Select day_row = ActiveCell.Row fecha = ActiveCell.Value For p = 1 To 20 If (Cells(day_row - p, 3) = fecha) Then fday = Cells(day_row - p, 3).Row If (Cells(day_row + p, 3) = fecha) Then lday = Cells(day_row + p, 3).Row

Module1-3 'Selecciona las celdas del régimen y las pega Range(Cells(fday, 15), Cells(lday + 1, 15)).Select Cells(fday, 20).Select 'Selecciona el margen recibido optimizado y lo pega Range(Cells(fday, 17), Cells(lday + 1, 17)).Select Cells(fday, 22).Select Cells(inicio, 20) = "STOP" 'Iteración para buscar el máximo n = 1 Do While (sumpc(n) > minpc) If (falso = 1) Then Exit Do Cells(frow(j) + n - 1, 13) = "STOP" For o = (frow(j) - 2) + n To (lrow(k - 1) + 1) max_it(n) = max_it(n) + Cells(o, 17) sumpc(n) = sumpc(n) + Cells(o, 18) Next o If (max_it(n) > max(m - 1)) Then max(m - 1) = max_it(n) falso = 2 'Búsqueda del máximo coincidente con pc If (Cells(frow(j) + n, 13) = "PC") Then row_max = frow(j) + n If (Cells(frow(j) + n, 13) = "STOP") Then For p = 1 To 6 Cells(frow(j) + n + p, 13).Select If (Cells(frow(j) + n + p, 13) = "PC") Then row_max = frow(j) + n + p n = n + 1 If (sumpc(n - 1) = sumpc(n - 2)) Then Exit Do sumpc(n) = sumpc(n - 1) Loop m = 1 '#####Modifico el régimen en función del máximo If (falso > 1) Then Cells(row_max, 13) = "PC" Range(Cells(row_max, 13), Cells(pcfin(h), 13)) = "PC" 'Copia del régimen de funcionamiento óptimo en una nueva columna, así como los resultados econó micos del cambio 'durante el día entero 'Busca las celdas correspondientes al día optimizado

Module1-4 Cells(row_max, 3).Select day_row = ActiveCell.Row fecha = ActiveCell.Value For p = 1 To 20 If (Cells(day_row - p, 3) = fecha) Then fday = Cells(day_row - p, 3).Row If (Cells(day_row + p, 3) = fecha) Then lday = Cells(day_row + p, 3).Row 'Selecciona las celdas del régimen y las pega Range(Cells(fday, 15), Cells(lday + 1, 15)).Select Cells(fday, 20).Select 'Selecciona el margen recibido optimizado y lo pega Range(Cells(fday, 17), Cells(lday + 1, 17)).Select Cells(fday, 22).Select Cells(inicio, 20) = "STOP" falso = 0 Next j 'Rellenar filas vacías con Stop Cells(i, 20).Select vacio = Cells(i, 20) If (vacio = "") Then Cells(i, 20).Select Selection.FormulaR1C1 = "STOP" Cells(i, 22).Select Selection.FormulaR1C1 = 0 Range(Cells(final + 2, 19), Cells(final + 2, 22)).Select Selection.ClearContents 'Devolver las fórmulas cambiadas a su estado original Range("M4").Select Selection.AutoFill Destination:=Range("M4:M" & final) '#####Presentación de los resultados##### sum_ini = 0 sum_opt = 0 pc_ini = 0 pc_opt = 0 starts_ini = 0 starts_opt = 0 sum_ini = sum_ini + Cells(i, 21) sum_opt = sum_opt + Cells(i, 22) If (Cells(i, 19) = "PC") Then pc_ini = pc_ini + 1 If (Cells(i, 20) = "PC") Then pc_opt = pc_opt + 1 If (Cells(i, 19) = "START1") Then

Module1-5 starts_ini = starts_ini + 1 If (Cells(i, 20) = "START1") Then starts_opt = starts_opt + 1 'Presentación de las diferencias Sheets("resultados").Select Range("B9") = sum_ini Range("D9") = sum_opt Range("B12") = pc_ini Range("D12") = pc_opt Range("B18") = starts_ini Range("D18") = starts_opt If (Range("D15") <= 0) Then vbanswer = MsgBox("El beneficio neto es nulo o negativo" & Chr(13) & "La planta debe parar su p roducción", vbok) Range("A1").Select vbanswer = MsgBox("Optimización realizada", vbok) End Sub