Implicit Bilevel Optimization: Differentiating through Bilevel Optimization Programming
Francesco Alesiani

TL;DR
This paper introduces BiGrad, a novel method for differentiating through bilevel optimization problems, enabling end-to-end learning in models that incorporate bilevel programming, applicable to both continuous and combinatorial cases.
Contribution
It extends single-level optimization approaches to bilevel programming, providing a general, efficient framework for differentiating through complex bilevel problems in machine learning.
Findings
BiGrad effectively extends single-level methods to bilevel programming.
The approach reduces computational complexity for combinatorial problems.
Experiments demonstrate successful integration of bilevel optimization in learning models.
Abstract
Bilevel Optimization Programming is used to model complex and conflicting interactions between agents, for example in Robust AI or Privacy-preserving AI. Integrating bilevel mathematical programming within deep learning is thus an essential objective for the Machine Learning community. Previously proposed approaches only consider single-level programming. In this paper, we extend existing single-level optimization programming approaches and thus propose Differentiating through Bilevel Optimization Programming (BiGrad) for end-to-end learning of models that use Bilevel Programming as a layer. BiGrad has wide applicability and can be used in modern machine learning frameworks. BiGrad is applicable to both continuous and combinatorial Bilevel optimization problems. We describe a class of gradient estimators for the combinatorial case which reduces the requirements in terms of computation…
| LQR | OptNet | Bilevel | |
|---|---|---|---|
| Adversarial | 2.736 | 0.2722 | 0.2379 |
| (10 steps) | |||
| (30 steps) | - | 0.2511 | 0.2181 |
| DCNN | Bi-DCNN | CNN | CNN* | |
|---|---|---|---|---|
| 0 | 62.9 0.3 | 64.0 0.4 | 63.4 0.7 | 63.6 0.5 |
| 5 | 42.6 1.0 | 44.5 0.2 | 43.8 1.2 | 44.3 1.0 |
| 10 | 23.5 1.5 | 25.3 0.8 | 24.3 1.0 | 24.2 1.0 |
| 15 | 14.4 1.4 | 15.6 0.7 | 14.6 0.7 | 14.3 0.4 |
| 20 | 9.1 1.2 | 10.0 0.6 | 9.2 0.4 | 8.9 0.2 |
| 25 | 6.1 1.0 | 6.8 0.5 | 6.0 0.2 | 5.9 0.2 |
| 30 | 3.9 0.7 | 4.4 0.5 | 3.9 0.2 | 3.9 0.1 |
| gradient | accuracy [12x12 maps] | accuracy [18x18 maps] | accuracy [24x24 maps] | |||
|---|---|---|---|---|---|---|
| type | train | validation | train | validation | train | validation |
| BiGrad (BB) | 95.8 0.2 | 94.5 0.2 | 97.1 0.0 | 96.4 0.2 | 98.0 0.0 | 97.8 0.0 |
| BiGrad (PT) | 91.7 0.1 | 91.6 0.1 | 94.3 0.0 | 94.2 0.1 | 95.7 0.0 | 95.6 0.1 |
| BB-1 | 95.9 0.2 | 91.7 0.1 | 96.7 0.2 | 94.5 0.1 | 97.1 0.1 | 96.3 0.2 |
| PT-1 | 88.3 0.2 | 87.5 0.2 | 90.9 0.4 | 90.6 0.5 | 92.8 0.1 | 92.8 0.2 |
| SL | 100.0 0.0 | 26.2 2.4 | 99.9 0.1 | 20.2 0.5 | 99.1 0.2 | 14.0 1.0 |
| gradient | accuracy | accuracy | accuracy | ||||||
|---|---|---|---|---|---|---|---|---|---|
| type | k | train | validation | k | train | validation | k | train | validation |
| BB | 8 | 89.2 0.1 | 89.4 0.2 | 10 | 91.9 0.1 | 92.0 0.1 | 12 | 93.5 0.1 | 93.5 0.2 |
| PT | 8 | 89.3 0.0 | 89.4 0.1 | 10 | 92.0 0.0 | 91.9 0.1 | 12 | 93.7 0.1 | 93.7 0.1 |
| BB-1 | 8 | 84.0 0.4 | 83.9 0.4 | 10 | 87.4 0.3 | 87.5 0.4 | 12 | 89.3 0.1 | 89.3 0.1 |
| PT-1 | 8 | 84.1 0.4 | 84.1 0.3 | 10 | 87.3 0.3 | 87.0 0.3 | 12 | 89.3 0.0 | 89.5 0.2 |
| SL | 8 | 94.2 5.0 | 10.7 3.9 | 10 | 92.7 5.4 | 9.4 0.4 | 12 | 91.4 2.3 | 9.3 1.2 |
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
Taxonomy
TopicsRisk and Portfolio Optimization · Bayesian Modeling and Causal Inference · Stochastic Gradient Optimization Techniques
Implicit Bilevel Optimization: Differentiating through Bilevel Optimization Programming
Francesco Alesiani
Abstract
Bilevel Optimization Programming is used to model complex and conflicting interactions between agents, for example in Robust AI or Privacy-preserving AI. Integrating bilevel mathematical programming within deep learning is thus an essential objective for the Machine Learning community. Previously proposed approaches only consider single-level programming. In this paper, we extend existing single-level optimization programming approaches and thus propose Differentiating through Bilevel Optimization Programming (BiGrad) for end-to-end learning of models that use Bilevel Programming as a layer. BiGrad has wide applicability and can be used in modern machine learning frameworks. BiGrad is applicable to both continuous and combinatorial Bilevel optimization problems. We describe a class of gradient estimators for the combinatorial case which reduces the requirements in terms of computation complexity; for the case of the continuous variable, the gradient computation takes advantage of the push-back approach (i.e. vector-jacobian product) for an efficient implementation. Experiments show that the BiGrad successfully extends existing single-level approaches to Bilevel Programming.
1 Introduction
Neural networks provide unprecedented improvements in perception tasks, however, deep neural networks do not natively protect against adversarial attacks nor preserve the privacy of the training dataset. In recent years various approaches have been proposed to overcome this limitation (Shafique et al. 2020), for example by integrating adversarial training (Xiao et al. 2020). Some of these approaches require solving some optimization problems during training. Recent approaches propose thus differentiable layers that incorporate either quadratic (Amos and Kolter 2017), convex (Agrawal et al. 2019a), cone (Agrawal et al. 2019b), equilibrium (Bai, Kolter, and Koltun 2019), SAT (Wang et al. 2019) or combinatorial (Pogančić et al. 2019; Mandi and Guns 2020; Berthet et al. 2020) programs. The use of optimization programming as a layer of differentiable systems requires computing the gradients through these layers. With discrete variables, the gradient is zero almost everywhere, while with complex (black box) solvers, the gradient may not be accessible.
Proposed gradient estimates either relax the combinatorial problem (Mandi and Guns 2020), perturb the input variables (Berthet et al. 2020; Domke 2010) or linearly approximate the loss function (Pogančić et al. 2019). These approaches though, do now allow to directly express models with conflicting objectives, for example in structural learning (Elsken, Metzen, and Hutter 2019) or adversarial system (Goodfellow et al. 2014). We thus consider the use of bilevel optimization programming as a layer. Bilevel Optimization Program (Kleinert et al. 2021; Dempe 2018), also known as a generalization of Stackelberg Games, is the extension of a single-level optimization program, where the solution of one optimization problem (i.e. the outer problem) depends on the solution of another optimization problem (i.e. the inner problem). This class of problems can model interactions between two actors, where the action of the first depends on the knowledge of the counter-action of the second. Bilevel Programming finds application in various domains, as in Electricity networks, Economics, Environmental policy, Chemical plants, defense, and planning (Dempe 2018). We introduce at the end of the section example applications of Bilevel Optimization Programming.
In general, Bilevel programs are NP-hard (Dempe 2018), they require specialized solvers and it is not clear how to extend single-level approaches since the standard chain rule is not directly applicable. By modeling the bilevel optimization problem as an implicit layer (Bai, Kolter, and Koltun 2019), we consider the more general case where 1) the solution of the bilevel problem is computed by a bilevel solver; thus leveraging on powerfully solver developed over various decades (Kleinert et al. 2021); and 2) the computation of the gradient is more efficient since we do not have to propagate gradient through the solver.
We thus propose Differentiating through Bilevel Optimization Programming (BiGrad):
- •
BiGrad (section 3) comprises of forwarding pass, where existing solvers (e.g. (Yang, Ji, and Liang 2021)) can be used, and backward pass, where BiGrad estimates gradient for both continuous (subsection 2.1, subsection 3.1) and combinatorial (subsection 2.2,subsection 3.2) problems based on sensitivity analysis;
- •
we show how the proposed gradient estimators relate to the single-level analogous and that the proposed approach is beneficial in both continuous (subsection 5.1) and combinatorial optimization (subsection 5.2,subsection 5.3,subsection 5.4, ) learning tasks.
Adversarial attack in Machine Learning
Bilevel programming is used the represents the interaction between a machine learning model () and a potential attacker () (Goldblum, Fowl, and Goldstein 2019) and is used to increase the resilience to intentional or unintended adversarial attacks.
Min-max problems
Min-max problems are used to model robust optimization problems (Ben-Tal, El Ghaoui, and Nemirovski 2009), where a second variable represents the environment and is constrained to an uncertain set that captures the unknown variability of the environment.
Closed-loop control of physical systems
Bilevel Programming is able to model the interaction of a dynamical system () and its control sub-system (), as, for example, of an industrial plant or a physical process. The control sub-system changes based on the state of the underlying dynamical system, which itself solves a physics constraint optimization problem (de Avila Belbute-Peres et al. 2018).
Interdiction problems
Two actors’ discrete Interdiction problems (Fischetti et al. 2019) arise when one actor () tries to interdict the actions of another actor () under budget constraints. These problems can be found in marketing, protecting critical infrastructure, and preventing drug smuggling to hinder nuclear weapon proliferation.
2 Differentiable Bilevel Optimization Layer
We model the Bilevel Optimization Program as an Implicit Layer (Bai, Kolter, and Koltun 2019), i.e. as the solution of an implicit equation . We thus compute the gradient using the implicit function theorem, where is given and represents the parameters of our system we want to estimate, and are output variables (Fig.1). We also assume we have access to a bilevel solver , e.g. (Yang, Ji, and Liang 2021). The bilevel Optimization Program is then used as layer of a differentiable system, whose input is and output is given by , where is the function composition operator. We want to learn the parameters of the function that minimize the loss function , using the training data . In order to be able to perform the end-to-end training, we need to back-propagate the gradient of the Bilevel Optimization Program Layer, which can not be accomplished only using the chain rule.
2.1 Continuous Bilevel Programming
We now present the definition of the continuous Bilevel Optimization problem, which comprises two non-linear functions , as
[TABLE]
where the left part problem is called outer optimization problem and resolves for the variable , with . The right problem is called the *inner optimization problem * and solves for the variable , with . The variable is the input variable and is a parameter for the bilevel problem. Min-max is a special case of Bilevel optimization problem , where the minimization functions are equal and opposite in sign. In Sec.A.1, we describe how the model of Eq. 1 can be extended in the case of linear and nonlinear constraints.
2.2 Combinatorial Bilevel Programming
When the variables are discrete, we restrict the objective functions to be multi-linear (Greub 1967). Various important combinatorial problems are linear in discrete variables (e.g. VRP, TSP, SAT 111Vehicle Routing Problem, Boolean satisfiability problem.), one example form is the following
[TABLE]
The variables have domains in , where are convex polytopes that are constructed from a set of distinct points as their convex hull. The outer and inner problems are Integer Linear Programs (ILPs). The multi-linear operator is represented by the inner product . We only consider the case where we have separate parameters for the outer and inner problems, and .
3 BiGrad: Gradient estimation
BiGrad provides gradient estimations for both continuous and discrete problems. We can identify the following common basic steps (Alg.1):
In the forward pass, solve the combinatorial or continuous Bilevel Optimisation problem as defined in Eq.1(or Eq.2) using existing solver () e.g. (Yang, Ji, and Liang 2021); 2. 2.
During the backward pass, compute the gradient (and ) using the suggested gradients (Sec.3.1 and Sec.3.2) starting from the gradients on the output variables and .
3.1 Continuous Optimization gradient estimation
To evaluate the gradient of the variables versus the loss function , we need to propagate the gradients of the two output variables through the two optimization problems. We can use the implicit function theorem to approximate locally the function . We have thus the following main results222Proofs are in the Supplementary Material.
Theorem 1**.**
*Considering the bilevel problem of Eq.1, we can build the following set of equations that represent the equivalent problem around a given solution : *
[TABLE]
*where *
[TABLE]
where we used the short notation
Theorem 2**.**
Consider the problem defined in Eq.1, then the total gradient of the parameter w.r.t. the loss function is computed from the partial gradients as
[TABLE]
The implicit layer is thus defined by the two conditions and . We notice that Eq.5 can be solved without explicitly computing the Jacobian matrices and inverting the system, but by adopting the Vector-Jacobian product approach we can proceed from left to right to evaluate . In the following section, we describe how affine equality constraints and nonlinear inequality can be used when modeling . We also notice that the solution of Eq.5 does not require solving the original problem, but only applying matrix-vector products, i.e. linear algebra, and the evaluation of the gradient that can be computed using automatic differentiation. The extension of Theorem.2 to cone programming is presented in Sec.A.2.
3.2 Combinatorial Optimization gradient estimation
When we consider discrete variables, the gradient is zero almost everywhere. We thus need to resort to estimating gradients. For the bilevel problem with discrete variables of Eq.2, when the solution of the bilevel problem exists and its solution is given (Kleinert et al. 2021), Thm.3 gives the gradients of the loss function with respect to the input parameters.
Theorem 3**.**
Given the Eq.2 problem, the partial variation of a cost function on the input parameters has the following form:
[TABLE]
The terms capture the interaction between outer and inner problems. We could estimate the gradients in Thm.3 using the perturbation approach suggested in (Berthet et al. 2020), which estimates the gradient as the expected value of the gradient of the problem after perturbing the input variable, but, similar to REINFORCE (Williams 1992), this introduces large variance. While it is possible to reduce variance in some cases (Grathwohl et al. 2017) with the use of additional trainable functions, we consider alternative approaches as described in the following.
Differentiation of black box combinatorial solvers
(Pogančić et al. 2019) propose a way to propagate the gradient through a single-level combinatorial solver, where when . We thus propose to compute the variation on the input variables from the two separate problems of the Bilevel Problem:
[TABLE]
or alternatively, if we have only access to the Bilevel solver and not to the separate ILP solvers, we can express
[TABLE]
where and represent the solutions of the two problems separately, the complete solution to the Bilevel Problem, is a hyper-parameter and . This form is more convenient than Eq.6 since it does not require computing the cross terms, ignoring thus the interaction of the two levels.
Straight-Through gradient
In estimating the input variables of our model, we may not be interested in the interaction between the two variables . Let us consider, for example, the squared loss function defined over the output variables
[TABLE]
where and is the true value. The loss is non-zero only when the two vectors disagree, and with integer variables, it counts the difference squared, or, in the case of the binary variables, it counts the number of differences. If we compute in the binary case, we have that if , if , and [math] otherwise. This information can be directly used to update the variable in the linear term , thus we can estimate the gradients of the input variables as and , with some weight . The intuition is that the weight associated with the variable is increased when the value of the variable reduces. In the general multilinear case, we have additional multiplicative terms. Following this intuition (see Sec.A.3), we thus use as an estimate of the gradient of the variables
[TABLE]
This is equivalent in Eq.2 where and , thus . This update is also equivalent to Eq.7, without the solution computation. The advantage of this form is that it does not require solving for an additional solution in the backward pass. For the single-level problem, the gradient has the same form as the Straight-Through gradient proposed by (Bengio, Léonard, and Courville 2013), with surrogate gradient .
4 Related Work
Bilevel Programming in machine learning
Various papers model machine learning problems as Bilevel problems, for example in Hyper-parameter Optimization (MacKay et al. 2019; Franceschi et al. 2018), Meta-Feature Learning (Li and Malik 2016), Meta-Initialization Learning (Rajeswaran et al. 2019), Neural Architecture Search (Liu, Simonyan, and Yang 2018), Adversarial Learning (Li et al. 2019) and Multi-Task Learning (Alesiani et al. 2020). In these works, the main focus is to compute the solution to the bilevel optimization problems. In (MacKay et al. 2019; Lorraine and Duvenaud 2018), the best response function is modeled as a neural network and the solution is found using iterative minimization, without attempting to estimate the complete gradient. Many bilevel approaches rely on the use of the implicit function to compute the hyper-gradient (Sec. 3.5 of (Colson, Marcotte, and Savard 2007)) but do not use bilevel as a layer.
Quadratic, Cone and Convex single-level Programming
Various works have addressed the problem of differentiate through quadratic, convex, or cone programming (Amos 2019; Amos and Kolter 2017; Agrawal et al. 2019b, a). In these approaches, the optimization layer is modeled as an implicit layer and for the cone/convex case, the normalized residual map is used to propagate the gradients. Contrary to our approach, this work only addresses single-level problems. These approaches do not consider combinatorial optimization.
Implicit layer Networks
While classical deep neural networks perform a single pass through the network at inference time, a new class of systems performs inference by solving an optimization problem. Examples of this are Deep Equilibrium Network (DEQ) (Bai, Kolter, and Koltun 2019) and NeurolODE (NODE) (Chen et al. 2018). Similar to our approach, the gradient is computed based on a sensitivity analysis of the current solution. These methods only consider continuous optimization.
Combinatorial Optimization (CO)
Various papers estimate gradients of single-level combinatorial problems using relaxation. (Wilder, Dilkina, and Tambe 2019; Elmachtoub and Grigas 2017; Ferber et al. 2020; Mandi and Guns 2020) for example use or log barrier to relax the Integer Linear Programming (ILP) problem. Once relaxed the problem is solved using standard methods for continuous variable optimization. An alternative approach is suggested in other papers. For example, in (Pogančić et al. 2019) the loss function is approximated with a linear function and this leads to an estimate of the gradient of the input variable similar to the implicit differentiation by perturbation form (Domke 2010). (Berthet et al. 2020) is another approach that uses also perturbation and change of variables to estimate the gradient in an ILP problem. SatNet (Wang et al. 2019) solves MAXSAT problems by solving a continuous semidefinite program (SDP) relaxation of the original problem. These works only consider single-level problems.
Discrete latent variables
Discrete random variables provide an effective way to model multi-modal distributions over discrete values, which can be used in various machine learning problems. Gradients of discrete distribution are not mathematically defined, thus, in order to use the gradient-based method, gradient estimations have been proposed. A class of methods is based on the Gumbel-Softmax estimator (Maddison, Mnih, and Teh 2016). Gradient estimation of the exponential family of distributions over discrete variables is estimated using the perturb-and-MAP method in (Niepert, Minervini, and Franceschi 2021).
Predict then optimize
Predict then Optimize (two-stage) (Elmachtoub and Grigas 2017; Ferber et al. 2020) or solving linear programs and submodular maximization from (Wilder, Dilkina, and Tambe 2019) solve optimization problems when the cost variable or the minimization function is directly observable. On the contrary, in our approach we only have access to a loss function on the output of the bilevel problem, thus allowing us to use it as a layer.
Neural Combinatorial Optimization (NCO)
NCO employs deep neural networks to derive efficient CO heuristics. NCO includes supervised learning (Joshi, Laurent, and Bresson 2019) and reinforcement learning (Kool, Van Hoof, and Welling 2019).
5 Experiments
We evaluate BiGrad with continuous and combinatorial problems to show that improves over single-level approaches. In the first experiment, we compare the use of BiGrad versus the use of the implicit layer proposed in (Amos and Kolter 2017) for the design of Optimal Control with adversarial noise. In the second part, after experimenting with an adversarial attack, we explore the performance of BiGrad with two combinatorial problems with Interdiction, where we adapted the experimental setup proposed in (Pogančić et al. 2019). In these latter experiments, we compare the formulation in Eq.8 (denoted by Bigrad(BB)) and the formulation of Eq.9 (denoted by Bigrad(PT)). In addition, we compare with the single level BB-1 from (Pogančić et al. 2019) and single level straight-through (Bengio, Léonard, and Courville 2013; Paulus, Maddison, and Krause 2021), with the surrogate gradient , (PT-1) gradient estimations. We compare against Supervised learning (SL), which ignores the underlying structure of the problem and directly predicts the solution of the bilevel problem.
5.1 Optimal Control with adversarial disturbance
We consider the design of robust stochastic control for a Dynamical System (Agrawal et al. 2019b). The problem is to find a feedback function that minimizes
[TABLE]
where is the state of the system, while is a i.i.d. random disturbance and is given initial state.
To solve this problem we use Approximate Dynamic Programming (ADP) (Wang and Boyd 2010) that solves a proxy quadratic problem
[TABLE]
We can use the optimization layer as shown in Fig.2(a) and update the problem variables (e.g. ) using gradient descent. We use the linear quadratic regulator (LQR) solution as the initial solution (Kalman 1964). The optimization module is replicated for each time step , similarly to the Recursive Neural Network (RNN).
We can build a resilient version of the controller in the hypothesis that an adversarial is able to inject a noise of limited energy, but is arbitrary dependent on the control , by solving the following bilevel optimization problem
[TABLE]
where and we want to learn the parameters , where of Eq.1.
We evaluate the performance to verify the viability of the proposed approach and compare with LQR and OptNet (Amos and Kolter 2017), where the outer problem is substituted with the best response function that computes the adversarial noise based on the computed output; in this case, the adversarial noise is a scaled version of of Eq.11. Tab.1 and Fig.2(b) present the performance using BiGrad, LQR and the adversarial version of OptNet. BiGrad improves over two-step OptNet (Tab.1), because is able to better model the interaction between noise and control dynamic.
5.2 Adversarial ML with discrete latent variables
Machine learning models are heavily affected by the injection of intentional noise (Madry et al. 2017; Goodfellow, Shlens, and Szegedy 2014). An adversarial attack typically requires access to the machine learning model, in this way the attack model can be used during training to include its effect. Instead of training an end-to-end system as in (Goldblum, Fowl, and Goldstein 2019), where the attacker is aware of the model, we consider the case where the attacker can inject a noise at the feature level, as opposed to the input level (as in (Goldblum, Fowl, and Goldstein 2019)), this allows us to model the interaction as a bilevel problem. Thus, to demonstrate the use of a bilevel layer, we design a system that is composed of a feature extraction layer, followed by a discretization layer that operates on the space of , where is the hidden feature size, followed by a classification layer. The network used in the experiments is composed of two convolutional layers with max-pooling and two linear layers, all with relu activation functions, while the classification is a linear layer. We consider a more limited attacker that is not aware of the loss function of the model and does not have access to the full model, but rather only to the input of the discrete layer and is able to switch discrete variables, The interaction of the discrete layer with the attacker is described by the following bilevel problem:
[TABLE]
where represents the sets of all possible attacks, is the budget of the discretization layer and is the output of the layer. For the simulation, we compute the solution by sorting the features by values and considering only the first B values, while the attacker will obscure (i.e. set to zero) the first positions. The output thus will have ones on the to non-zero positions, and zero elsewhere. We train three models, on CIFAR-10 dataset for epochs. For comparison we consider:1) the vanilla CNN network (i.e. without the discrete features); 2) the network with the single-level problem (i.e. the single-level problem without attacker) and; 3) the network with the bilevel problem (i.e. the min-max discretization problem defined in Eq.13). We then test the networks to adversarial attack using the PGD (Madry et al. 2017) attack similar to (Goldblum, Fowl, and Goldstein 2019). Similar results apply for FGSM attack (Fast Gradient Sign Attack) (Goodfellow, Shlens, and Szegedy 2014). We also tested the network trained as a vanilla network, where we added the min-max layer after training. From the results (Tab.2), we notice: 1) The min-max network shows improved resilience to adversarial attack wrt to the vanilla network, but also with respect to the max (single-level) network; 2) The min-max layer applied to the vanilla trained network is beneficial to adversarial attack; 3) The min-max network does not significantly change performance in presence of adversarial attack at the discrete layer (i.e. between Q=0 and Q=10). This example shows how bilevel layers can be successfully integrated into a Machine Learning system as differentiable layers.
5.3 Dynamic Programming: Shortest path with Interdiction
We consider the problem of the Shortest Path with Interdiction, where the set of possible valid paths (see Fig.3(a)) is and the set of all possible interdiction is . The mathematical problem can be written as
[TABLE]
where is the element-wise product. This problem is multi-linear in the discrete variables .
The variables are the output of the neural network whose inputs are the Warcraft II tile images. The aim is to train the parameters of the weight network, such that we can solve the shortest path problem only based on the input image. For the experiments, we followed and adapted the scenario of (Pogančić et al. 2019) and used the Warcraft II tile maps of (Guyomarch 2017). We implemented the interdiction Game using a two-stage min-max-min algorithm (Kämmerling and Kurtz 2020). In Fig.3(b) it is possible to see the effect of interdiction on the final solution. Tab.3 shows the performances of the proposed approaches, where we allow for interdictions and we used tile size of , , . The loss function is the Hamming and loss evaluated on both the shortest path and the intervention . The gradient estimated using Eq.8 (BB) provides more accurate results, at double of computation cost of PT. The single-level BB-1 approach outperforms PT, but shares similar computational complexity, while single-level PT-1 is inferior to PT. As expected, SL outperforms other methods during training, but completely fails during validation. Bigrad improves over single-level approaches because includes the interaction of the two problems.
5.4 Combinatorial Optimization: Travel Salesman Problem (TSP) with Interdiction
Travel Salesman Problem (TSP) with interdiction consists of finding the shortest route that touches all cities, where some connections can be removed. The mathematical problem to solve is given by
[TABLE]
where are cost matrices for the salesman and interceptor. Similar to the dynamic programming experiment, we implemented the interdiction Game using a two-stage min-max-min algorithm (Kämmerling and Kurtz 2020). Fig.4 shows the effect of a single interdiction. The aim is to learn the weight matrices, trained with the interdicted solutions on a subset of the cities. Tab.4 describes the performance in terms of accuracy on both shortest tour and intervention. We use Hamming and loss function. We only allow for intervention but considered and cities from a total of cities. Single and two-level approaches perform similarly in the training and validation. Since the number of interdiction is limited to one, the performance of the single-level approach is not catastrophic, while the supervised learning approach completely fails in the validation set. Bigrad thus improves over single-level and SL approaches. Since Bigrad(PT) has a similar performance of BiGrad (BB), thus PT is preferable in this scenario, since it requires fewer computation resources.
6 Conclusions
BiGrad generalizes existing single-level gradient estimation approaches and is able to incorporate Bilevel Programming as a learnable layer in modern machine learning frameworks, which allows to model of conflicting objectives as in adversarial attack. The proposed novel gradient estimators are also efficient and the proposed framework is widely applicable to both continuous and discrete problems. The impact of BiGrad has a marginal or similar cost with respect to the complexity of computing the solution of the Bilevel Programming problems. We show how BiGrad is able to learn complex logic when the cost functions are multi-linear.
Ethical Statement and Limitations
The present work does not have ethical implications, but share with all other machine learning approaches the potential to be used in a large multitude of applications; we expect our contribution to be used for the benefit and progress of our society. Our approach models bilevel problems with both discrete and continuous variables, but we have not explored the mixed integer programming approach, with mixed variables. We rely on the use of existing solvers to compute the current solution, thus we leave it to the next work to explore the potential to accelerate solving bilevel problems.
Appendix A Supplementary Material;
Implicit Bilevel Optimization: Differentiating through Bilevel Optimization Programming
A.1 Extension for linear equalities and non-linear inequalities
Linear Equality constraints
To extend the model of Eq.1 to include linear equality constraints of the form and on the outer and inner problem variables, we use the following change of variables
[TABLE]
where are the orthogonal space of and , i.e. , and are one solution of the equations, i.e. .
Non-linear Inequality constraints
Similarly, to extend the model of Eq.1 when we have non-linear inequality constraints, we use the barrier method approach (Boyd and Vandenberghe 2004), where the variable is penalized with a logarithmic function to violate the constraints. Specifically, let us consider the case where are inequality constraint functions, i.e. , for the outer and inner problems. We then define new functions
[TABLE]
where is a variable parameter, which depends on the violation of the constraints. The closer the solution is to violate the constraints, the larger the value of is.
A.2 Bilevel Cone programming
We show here how Theorem.2 can be applied to bi-level cone programming extending single-level cone programming results (Agrawal et al. 2019b), where we can use efficient solvers for cone programs to compute a solution of the bilevel problem (Ouattara and Aswani 2018)
[TABLE]
In this bilevel cone programming, the inner and outer problem are both cone programs, where represents a linear transformation, while are new parameters of the problem, while is the conic domain of the variables. In the hypothesis that a local minima of Eq.18 exists, we can use an interior point method to find such point. To compute the bilevel gradient, we then use the residual maps (Busseti, Moursi, and Boyd 2019) of the outer and inner problems. Indeed, we can then apply Theorem 2, where and are the normalized residual maps defined in (Busseti, Moursi, and Boyd 2019; Agrawal et al. 2019a) of the outer and inner problems.
A.3 Proofs
Proof of Linear Equality constraints.
Here we show that
[TABLE]
includes all solution of . First we have that and by definition. This implies that . Thus . The difference belongs to the null space of , indeed . The null space of has size . If , where , then there is only one solution , the pseudo inverse of . If , then is a based of all vectors s.t. , since is the size of the null space of . In fact is the base for the null space of . The same applies for and . ∎
Proof of Theorem 1.
The second equation is derived by imposing the optimally condition on the inner problem. Since we do not have inequality and equality constraints we optimal solution shall equate the gradient w.r.t. to zero, thus . The first equation is also related to the optimality of the variable w.r.t. to the total derivative or hyper-gradient, thus we have that . In order to compute the variation of , i.e. we apply the implicit theorem to the inner problem, i.e. , thus obtaining . ∎
Proof of Theorem 2.
In order to prove the theorem, we use the Discrete Adjoin Method (DAM). Let consider a cost function or functional evaluated at the output of our system. Our system is defined by the two equations from Theorem 1. Let us first consider the total variations: , where the last conditions are true by definition of the bilevel problem. When we expand the total variations, we obtain
[TABLE]
We now consider . We ask the first two terms to be zero to find the two free variables :
[TABLE]
or in matrix form
[TABLE]
We can now compute the with from the previous equation. ∎
Proof of Theorem 3.
The partial derivatives are obtained by using the perturbed discrete minimization problems defined by Eqs.24. We first notice that . This result is obtained by the fact that , where and applying the gradient w.r.t. the continuous variable ; while Eqs. 23 are the expected functions of the perturbed minimization problems. Thus, if we compute the gradient of the perturbed minimizer, we obtain the optimal solution, properly scaled by the inner product matrix. For example , with the inner product matrix. To compute the variation on the two-parameter variables, we have that and that from the dependence diagram of Fig.5 ∎
A.4 Gradient Estimation based on perturbation
We can use the gradient estimator using the perturbation approach proposed in (Berthet et al. 2020). We thus have
[TABLE]
and
[TABLE]
, while
[TABLE]
which are valid under the conditions of (Berthet et al. 2020), while and are hyper-parameters.
A.5 Alternative derivation
Let consider the problem and let us define a penalty term that ensures . We can define the generalized lagragian . One example of or where is the projection into . To solve the Lagragian, we solve the unconstrained problem . At the optimal point . Let us define , then and . If we have and a cost function , we can compute . Now , we can apply the previous result and . If we assume and , then .
A.6 Memory Efficiency
For continuous optimization programming, by separating the computation of the solution and the computation of the gradient around the current solution we 1) compute the gradient more efficiently, in particular, we compute second order gradient taking advantage of the vector-jacobian product (push-back operator) formulation without explicitly inverting and thus building the jacobian or hessian matrices; 2) use more advanced and not differentialble solution techniques to solve the bilevel optimization problem that would be difficult to integrate using automatic differentiable operations. Using VJP we reduce memory use from to . Indeed using an iterative solver, like generalized minimal residual method (GMRES) (Saad and Schultz 1986), we only need to evaluate the gradients of Eq.5 and not invert the matrix neither materialize the large matrix and computing matrix-vector products. Similarly, we use Conjugate Gradient (CG) method to compute Eq.4, which requires to only evaluating the gradient at the current solution and nor inverting neither materializing the Jacobian matrix. An implementation of a bilevel solver would have a memory complexity of , where is the number of iterations of the bilevel algorithm.
A.7 Experimental Setup and Computational Resources
For the Optimal Control with adversarial disturbance, we follow a similar setup of (Agrawal et al. 2019a), where we added the adversarial noise as described in the experiments. For the Combinatorial Optimization, we follow the setup of (Pogančić et al. 2019). The dataset is generated by solving the bilevel problem on the same data of (Pogančić et al. 2019). For section 5.3, we use the warcraft terrain tiles and generate optimal bilevel solution with the correct parameters , where is the terrain transit cost and is the interdiction cost, considered constant to in our experiment. is the set of all feasible interdictions, in our experiment we allow the maximum number of interdictions to be . For section 5.4, on the other hand the represents the true distances among cities and a matrix of the interdiction cost, both unknown to the model. is the set of all possible interdictions. In these experiments, we solved the bilevel problem using the min-max-min algorithm (Kämmerling and Kurtz 2020). For the Adversarial Attack, we used two convolutional layers with max-pooling, relu activation layer, followed by the discrete layer of size , , . A final linear classification layer is used to classify CIFAR10. We run over runs, epochs, learning rate and Adam optimizer. Experiments were conducted using a standard server with 8 CPU, 64Gb of RAM and GeForce RTX 2080 GPU with 6Gb of RAM.
A.8 Jacobian-Vector and Vector-Jacobian Products
The Jacobian-Vector Product (JVP) is the operation that computes the directional derivative , with direction , of the multi-dimensional operator , with respect to , where is the Jacobian of evaluated at . On the other hand, the Vector-Jacobian product (VJP) operation, with direction , computes the adjoint directional derivative . JVP and VJP are the essential ingredient for automatic differentiation (Elliott 2018; Baydin et al. 2018).
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1Agrawal et al. (2019 a) Agrawal, A.; Amos, B.; Barratt, S.; Boyd, S.; Diamond, S.; and Kolter, Z. 2019 a. Differentiable convex optimization layers. ar Xiv:1910.12430 .
- 2Agrawal et al. (2019 b) Agrawal, A.; Barratt, S.; Boyd, S.; Busseti, E.; and Moursi, W. M. 2019 b. Differentiating through a cone program. ar Xiv:1904.09043 .
- 3Alesiani et al. (2020) Alesiani, F.; Yu, S.; Shaker, A.; and Yin, W. 2020. Towards Interpretable Multi-Task Learning Using Bilevel Programming. ar Xiv:2009.05483 .
- 4Amos (2019) Amos, B. 2019. Differentiable optimization-based modeling for machine learning . Ph.D. thesis, Ph D thesis. Carnegie Mellon University.
- 5Amos and Kolter (2017) Amos, B.; and Kolter, J. Z. 2017. Optnet: Differentiable optimization as a layer in neural networks. In International Conference on Machine Learning , 136–145. PMLR.
- 6Bai, Kolter, and Koltun (2019) Bai, S.; Kolter, J. Z.; and Koltun, V. 2019. Deep equilibrium models. ar Xiv:1909.01377 .
- 7Baydin et al. (2018) Baydin, A. G.; Pearlmutter, B. A.; Radul, A. A.; and Siskind, J. M. 2018. Automatic differentiation in machine learning: a survey. Journal of machine learning research , 18.
- 8Ben-Tal, El Ghaoui, and Nemirovski (2009) Ben-Tal, A.; El Ghaoui, L.; and Nemirovski, A. 2009. Robust optimization . Princeton university press.
