Whenever an unexpected failure occurs i machine, level of system efficiency decreases and this leads to the current production plan becomes inappropriate. In emergency situations, Changing the production plan, if it's not impossible, can be very costly and make big changes in the amount of production and service level. Therefor, considering maintenance is an important issues in the production planning. Maintenance planning considerd in two approaches: cyclical and non- cyclical. Non-cyclical program is better and near to reality however, because of the simplicity in most of the articles and works in the field of maintenance, they use the cyclical maintenance. Flowshop enviroment is one of the most prevalent enviroment in production area. One of the important constraint In this areas is the limited buffer between two consecutve machines, wich limit the production amount. In this thesis we determine lot size, the sequence of works and maintenances in flowshop enviroment with limited buffer. We introduce two models with different assumptions that can plan production works and non-cyclical maintenance.The objective of first problem is to minimizing the total costs consist of production, setup, inventory and praventive maintenance costs. The objective of second problem is to minimizing total costs consist of setup, inventory, production, preventive maintenace and emergency maintenance costs. Since both of the problems are NP-Hard, so the mathematical models can not solve large size problems. One metaheuristic algorithem, ant colony system, and two heuristics algorithm based on fix and optimizing are developed for each problems for the large scales. These algorithm are evaluated by solving 200 instances. In the first problem,the average time to solve these problems in the ACS algorithemis 122.26 seconds and in the first and second fix and optimize is 351.89 and 410.42 seconds respectively. In terms of solution quality, the average distances the solution obtained by ACS algorithem and first and second fix and optimize from solution obtained by implemention of the proposed mathematical model in the duration 7200 seconds, is 2.45, 1.83 and 1.37 in percentage, respectively. in the second problem , the average time to solve these problems in the ACS algorithemis and in the first and second fix and optimize is 190.95 , 499.49 and 697.15 seconds respectively. In terms of solution quality, the average distances the solution obtained by ACS algorithem and first and second fix and optimize from solution obtained by implemention of the proposed mathematical model in the duration 7200 seconds, is 2.55, 2.15 and 1.86 in percentage,respectively. In both of the problems in terms of solution time, ACS algorithem and in terms of solution quantity, the second algorithem based of fix and optimizing have a better performane.