'Extract the function variables from the vector x of all variables.'

def extract_variables(self, x, var_offsets):

    import cvxopt
    local_x = cvxopt.matrix(0.0, self.x_size)
    offset = 0
    for var in self.variables():
        var_size = (var.size[0] * var.size[1])
        value = x[var_offsets[var.data]:(var_offsets[var.data] + var_size)]
        self.block_add(local_x, value, offset, 0, var_size, 1)
        offset += var_size
    return local_x
