An air-conditioning apparatus comprising: room temperature sensors configured to detect room temperatures of respective rooms; target room-temperature setting units configured to set target room temperature of the respective rooms; a variable displacement type compressor configured to cause refrigerant to sequentially circulate through an outdoor heat exchanger, electric expansion valves, and indoor heat exchangers; a required-capacity calculation unit configured to calculate each of required capacities for the respective rooms using a value that is obtained by integrating a deviation of an associated one of the room temperatures from an associated one of the target room temperatures; an electric expansion-valve total opening degree output unit configured to output a total opening degree of the electric expansion valves, each of which is connected to an associated one of the indoor heat exchangers; a temporary electric expansion-valve opening degree calculation unit configured to calculate each of temporary opening degrees of the electric expansion valves for the respective rooms, using an associated one of the required capacities and the total opening degree; an electric expansion-valve opening degree upper/lower limit calculation unit configured to calculate an upper limit and a lower limit of each of the opening degrees; characterized in that it further comprises: an evaluation function derivation unit configured to obtain a distance function with an associated one of the temporary opening degrees of the electric expansion valves, as an evaluation function, using an associated one of opening degrees of the electric expansion valves as a variable, an equality constraint derivation unit configured to obtain equality constraints to equalize the sum of the opening degrees that is a variable to the total opening degree; an inequality constraint derivation unit configured to obtain inequality constraints in which each of the opening degrees meets falls within a range of the upper limit to the lower limit; and an optimization problem calculation unit configured to calculate each of the opening degrees by solving an optimization problem from the evaluation function, the equality constraints, and the inequality constraints. room temperature sensors configured to detect room temperatures of respective rooms; target room-temperature setting units configured to set target room temperature of the respective rooms; a variable displacement type compressor configured to cause refrigerant to sequentially circulate through an outdoor heat exchanger, electric expansion valves, and indoor heat exchangers; a required-capacity calculation unit configured to calculate each of required capacities for the respective rooms using a value that is obtained by integrating a deviation of an associated one of the room temperatures from an associated one of the target room temperatures; an electric expansion-valve total opening degree output unit configured to output a total opening degree of the electric expansion valves, each of which is connected to an associated one of the indoor heat exchangers; a temporary electric expansion-valve opening degree calculation unit configured to calculate each of temporary opening degrees of the electric expansion valves for the respective rooms, using an associated one of the required capacities and the total opening degree; an electric expansion-valve opening degree upper/lower limit calculation unit configured to calculate an upper limit and a lower limit of each of the opening degrees; characterized in that it further comprises: an evaluation function derivation unit configured to obtain a distance function with an associated one of the temporary opening degrees of the electric expansion valves, as an evaluation function, using an associated one of opening degrees of the electric expansion valves as a variable, an equality constraint derivation unit configured to obtain equality constraints to equalize the sum of the opening degrees that is a variable to the total opening degree; an inequality constraint derivation unit configured to obtain inequality constraints in which each of the opening degrees meets falls within a range of the upper limit to the lower limit; and an optimization problem calculation unit configured to calculate each of the opening degrees by solving an optimization problem from the evaluation function, the equality constraints, and the inequality constraints. an evaluation function derivation unit configured to obtain a distance function with an associated one of the temporary opening degrees of the electric expansion valves, as an evaluation function, using an associated one of opening degrees of the electric expansion valves as a variable, an equality constraint derivation unit configured to obtain equality constraints to equalize the sum of the opening degrees that is a variable to the total opening degree; an inequality constraint derivation unit configured to obtain inequality constraints in which each of the opening degrees meets falls within a range of the upper limit to the lower limit; and an optimization problem calculation unit configured to calculate each of the opening degrees by solving an optimization problem from the evaluation function, the equality constraints, and the inequality constraints.