The paper employs Operations Research methods for analysis of electricity and capacity markets. We provide two algorithms that determine the optimal capacity structure with account of fixed and variable costs. The first one relates to the case where there are several capacity types, and for each type the capacity constraint is not binding. The second algorithm is applicable when electricity is produced by standard small generators with the same capacity and different costs. Then we study two typical architectures of the market and examine their Nash equilibria. We consider a uniform price supply function auction in the electricity market. For pay-as-bid and uniform price versions of the capacity market design, we compare the equilibrium outcomes with the optimal capacity structure. The paper shows that the market equilibrium corresponds to the optimal capacity structure under conditions of pure competition, full rationality, and completely informed agents in the market. However, under more realistic assumptions, selection of the optimal structure is unlikely. Finally we provide the auction design that realizes such selection of capacities and does not require any additional information of each producer besides his own production costs. We establish sufficient conditions for perfect competition in the market.