def plot_single()

in automl21/enr.py [0:0]


    def plot_single(self, n_iter, tag='t'):
        inst = self.sample_single_inst(seed=0)

        x_cvxpy = self.solve_cvxpy(inst)
        cvxpy_obj = self.obj(inst, x_cvxpy).cpu()
        print(f'=== CVXPY, objective value: {cvxpy_obj:.2e}')
        print(to_np(x_cvxpy)[:10])

        d_ISTA = self.solve_ISTA(inst, n_iter=n_iter, track_iterates=True)
        x = d_ISTA["solution"]
        final_obj = d_ISTA["objs"][-1]
        print(f'\n=== ISTA, final objective value: {final_obj:.2e}')
        print(to_np(x)[:10])

        # d_ISTA_AA = self.solve_ISTA_AA_old(inst, n_iter=n_iter, track_iterates=True)
        d_ISTA_AA = self.solve_ISTA_AA(inst, n_iter=n_iter, track_iterates=True)
        x = d_ISTA_AA["solution"]
        final_obj = d_ISTA_AA["objs"][-1]
        print(f'\n=== ISTA+AA, final objective value: {final_obj:.2e}')
        print(to_np(x)[:10])

        d_ISTA_neural = self.solve_ISTA_neural(
            inst, n_iter=n_iter, track_iterates=True)
        x = d_ISTA_neural["solution"]
        final_obj = d_ISTA_neural["objs"][-1]
        print(f'\n=== ISTA+neural, final objective value: {final_obj:.2e}')
        print(to_np(x)[:10])

        nrow, ncol = 1, 2
        fig, axs = plt.subplots(nrow, ncol, figsize=(6*ncol, 4*nrow))

        ax = axs[0]
        ax.plot(d_ISTA['rel_residual_norms'], label='ISTA')
        ax.plot(d_ISTA_AA['rel_residual_norms'], label='ISTA_AA')
        ax.plot(d_ISTA_neural['rel_residual_norms'], label='ISTA_neural')
        ax.set_yscale('log')
        ax.set_xlabel('Fixed-Point Iteration')
        ax.set_ylabel('Fixed-Point Residual')
        # ax.legend()

        ax = axs[1]
        # ax.plot(d_ISTA['objs'], label='ISTA')
        # ax.plot(d_ISTA_AA['objs'], label='ISTA_AA')
        # ax.plot(d_ISTA_neural['objs'], label='ISTA_neural')
        ax.plot((cvxpy_obj-d_ISTA['objs'].cpu())**2, label='ISTA')
        ax.plot((cvxpy_obj-d_ISTA_AA['objs'].cpu())**2, label='ISTA_AA')
        ax.plot((cvxpy_obj-d_ISTA_neural['objs'].cpu())**2, label='ISTA_neural')
        ax.set_yscale('log')
        ax.set_xlabel('Fixed-Point Iteration')
        ax.set_ylabel('Objective Distance')
        # ax.legend()

        fname = tag + '.png'
        fig.tight_layout()
        fig.savefig(fname, transparent=True)
        plt.close(fig)