01 · Endogenous responseAn action evaluated through another agent’s optimization
When an action induces another decision maker's response, its value depends on that response. Let \(u\in\mathcal B\) be an action from the agent’s admissible set, \(\xi\) the exogenous context the agent does not control, and, without loss of generality, suppose that a second decision maker or mechanism completes the action by solving its own problem,
with multipliers \(\boldsymbol\lambda^\star(u,\xi)\), signed as sensitivities of the optimal value to the right-hand side. The action is chosen against the completed response,
Here \(\ell\) is the acting agent’s criterion, \(\ell^\star\) its value after the selected response, and \(\rho_\xi\) a risk-adjusted value of that criterion over the context, such as its expectation or its lower-tail mean (equivalently, the negative of a risk functional of \(-\ell\)). The inner objective \(f\) belongs to the other decision maker. The pair is a bilevel program, a Stackelberg game whose follower is an optimization. Multipliers enter because outer criteria often read the prices or marginal values of the inner problem. When the inner problem has several optimal solutions, \(\mathbf y^\star\) denotes the solution the mechanism selects.
The object is the counterfactual response: the solution the inner problem would select after each candidate action. Replacing \(\mathbf y^\star(u,\xi)\) by an outcome observed before acting gives a price-taking, or open-loop, approximation. It is adequate when one agent’s action barely moves the inner solution. When the action does move it, a model of the response must generalize to actions absent from the data, and fitting that model as a generic function of \(u\) ignores the objective and constraints that determine \(\mathbf y^\star\), which can make such generalization very hard. Uncertainty and Ambiguity treats the estimated law; the response map is the object here.
The structure recurs wherever independently chosen actions meet a shared constrained process. An offer changes the allocation and the marginal values at which a market settles it; an order changes the book through which it executes; a planned trajectory changes the feasible continuation left to other agents. The mechanisms differ, and so do the representations a decision maker can hold of them: the optimization itself, a simulator, a learned surrogate, or a statistical model of outcomes. Each commits differently to feasibility, to local response, and to behavior across changes of the active constraints.
02 · ComputationExact, evaluation-only, and local access to the response
Writing the response map makes the decision model faithful, but it does not make repeated search over \(u\) tractable. Three families of methods reach the inner problem in different ways, and they answer different computational questions.
An exact reformulation replaces the inner problem by its optimality conditions. When the inner problem is convex and satisfies a constraint qualification, its KKT conditions characterize \(\mathbf y^\star\), and imposing primal feasibility, dual feasibility, stationarity, and complementarity as constraints gives a single-level mathematical program with equilibrium constraints (MPEC) (Hobbs et al., 2000; Ruiz and Conejo, 2009). Complementarity carries the difficulty. Written with binary variables (Fortuny-Amat and McCarl, 1981) or special ordered sets (Siddiqui and Gabriel, 2013), it certifies global optima at a cost that grows combinatorially; written as a nonlinear program (Fletcher and Leyffer, 2004), it solves quickly to degenerate local solutions. For a nonconvex inner problem the KKT conditions are necessary but no longer sufficient, so the single-level problem can admit points that are not the follower’s optimum.
Evaluation-only search keeps the inner problem as a solver and treats \(J\) as a black box. Derivative-free methods, from model-based trust regions such as BOBYQA (Powell, 2009) to simplex and evolutionary search, need nothing beyond repeated solves and remain meaningful across nonsmooth changes of the active set. Their cost is the number of solves, which becomes the binding limit as the dimension of \(u\) grows.
First-order search keeps the solver’s mathematical model and differentiates its solution. At a selected solution that satisfies the linear independence constraint qualification, second-order sufficiency, and strict complementarity, the implicit function theorem applied to the KKT residual \(F(\mathbf z;u,\xi)=\mathbf 0\), with \(\mathbf z=(\mathbf y,\boldsymbol\lambda,\boldsymbol\nu)\) and \(\boldsymbol\nu\) the multipliers of the inequality constraints, gives a differentiable primal–dual branch (Fiacco, 1976), and the derivative of the outer criterion is
Here \(F_{\mathbf z}=\partial F/\partial\mathbf z\) and \(F_u=\partial F/\partial u\) are evaluated at the selected solution, \(\mathbf v\) is the adjoint vector, and one solve with the transposed KKT matrix returns this gradient using the factorization the solver already holds (Pirnay et al., 2012). The envelope theorem would give this derivative from the multipliers alone only if the outer criterion coincided with the inner objective. Here the two belong to different agents, so the response of the solution itself is required. Gradient-based bidding methods compute such responses from the clearing problem, for instance as transmission-constrained residual-demand derivatives (Xu et al., 2011). Differentiating Optimization Models develops the calculus for existing models; at nonregular points, directional derivatives take the place of the derivative (Ralph and Dempe, 1995).
What a local response can carry
A gradient is computable wherever the selected branch is regular. It is informative only if the inner model transmits the part of the response that the outer criterion reads. Linear inner problems make the failure exact. For \(\min\{\mathbf c^\top\mathbf y:\ A\mathbf y=\mathbf b,\ \mathbf y\ge\mathbf 0\}\) with a nondegenerate optimal basis \(B\) and multipliers signed as prices, \(\boldsymbol\lambda^\star=\nabla_{\mathbf b}\) of the optimal value,
Here \(N\) indexes the nonbasic variables: The primal solution responds to the right-hand side and not to the costs, while the multipliers respond to the basic costs and not to the right-hand side. Over the right-hand side the solution is piecewise affine and the multipliers are piecewise constant (Borrelli et al., 2003). An action that enters through \(\mathbf b\) therefore has \(D_u\boldsymbol\lambda^\star=\mathbf 0\) wherever the derivative exists, and every change of \(\boldsymbol\lambda^\star\) arrives as a jump at a change of basis that the derivative at the current basis cannot anticipate. The term is exactly zero, so no step size or solver tolerance repairs it.
Curvature removes this decoupling. With a nonzero Hessian of the Lagrangian, the primal and dual blocks of the KKT matrix are coupled, and within an active set the multipliers move continuously with the right-hand side; for a quadratic inner problem, \(\boldsymbol\lambda^\star\) is affine in \(\mathbf b\). Changes of the active set, however, still produce kinks and jumps, and local search can still stop at a poor stationary point. Whether the transmitted response repays its computation is therefore a question about the inner model, and the market study below answers it for one representative class.
03 · Market instanceOffers completed by sequential market clearing
Electricity markets make every element of the composition explicit. A producer or trader submits, for each node and hour of the next day, a price and a quantity, \(u=(\mathbf c,\mathbf Q)\). The operator clears day-ahead offers by an optimization that sets an allocation \(\mathbf q\) and nodal prices \(\boldsymbol\pi\), the multipliers of power balance, which give the marginal value of energy delivered at each node. On the operating day a second clearing sets dispatch \(\mathbf g\) and real-time prices \(\boldsymbol\lambda\), starting from a state \(\mathbf x\) set by the day-ahead clearing. Competing offers, demand, and the operator’s forecasts are not observed at bidding time and enter through \(\xi\). A strategic participant solves a problem with one equilibrium constraint for each clearing,
Here \(\mathcal B\) collects the participant’s offer limits, \(\mathcal M^{\mathrm{DA}}\) and \(\mathcal M^{\mathrm{RT}}\) return the selected clearing responses, \(\mathcal N\) and \(\mathcal H\) index the participant’s nodes and settlement hours, and \(R\) is \(R_{\mathrm{phys}}\) for a physical position or \(R_{\mathrm{virt}}\) for a virtual position, which settles the price difference without delivery, as in virtual bidding (Macedo et al., 2022). A physical participant may also offer into the real-time clearing, so \(\mathcal M^{\mathrm{RT}}\) depends on \(u\) as well as on the state \(\mathbf x\) set by the day-ahead clearing. A virtual bid enters only the day-ahead clearing and reaches real-time prices through that state alone. Uncertain inputs enter both.
How the clearing is represented decides how much of its own influence a bidding model can capture. A statistical, or data-analytics, approach models day-ahead and real-time prices as a stochastic process and chooses offers against it, so the offer decides only whether it clears against prices that do not respond. It is a price-taking approximation, and its difficulties are those of an estimated law: finite samples, heavy tails, nonstationarity. Uncertainty and Ambiguity addresses these difficulties at the statistical level, for instance by calibrating ambiguity sets on the day-ahead minus real-time price spreads of PJM virtual bids.
A price–quota, or surrogate, approach fits prices as functions of the offer, \(\boldsymbol\pi(\mathbf c,\mathbf Q)\) and \(\boldsymbol\lambda(\mathbf c,\mathbf Q)\), for instance as a neural network embedded in the bidding problem (Dolányi et al., 2024). It retains influence but must remain credible for offers unlike those it was fitted on. Finally, an endogenous approach keeps the clearing problems and evaluates each candidate offer through the operator’s selected solution; only it computes price responses from the clearing model itself, but its exact reformulation grows combinatorially with the complementarity conditions, as we have pointed out before.
The completed study follows the endogenous approach and solves it iteratively: Each candidate offer is cleared, and a search method proposes the next offer from the outcome. To compare search methods on a controlled response, it isolates one clearing and one strategic producer (Rosemberg et al., 2025d). Other participants’ offers and the load are fixed to one scenario, and commitment decisions are taken as given, as in a real-time market. For each of its generators the producer offers a price \(\mathbf c_a\ge\mathbf c_o\), at least its operating cost, and a quantity \(\mathbf 0\le\mathbf Q_a\le\mathbf Q^{\max}\), so \(u=(\mathbf c_a,\mathbf Q_a)\). Clearing returns dispatch \(\mathbf g_a^\star\) and nodal prices \(\boldsymbol\lambda_a^\star\), and the profit and its gradient are
The first term is the dispatch path, the second the price path. The clearing is modeled in its AC form, with the nonlinear power-flow equations, voltage limits, and losses. Market operators often clear on a linear approximation for tractability and then correct the dispatch toward AC physics; this study uses the AC model directly, which also isolates the search from the differentiability issues that linear problems pose for the Lagrange multipliers, as stated before.
04 · ComparisonGradients find better offers with fewer clearings
Gradient-based search found better offers with fewer clearings. On the two PEGASE systems, with 1,354 and 2,869 buses, the best gradient-based method reached about twice the profit of the best derivative-free method, with gains of 102% and 110%; gradient-based methods converged in about 50 clearings, while derivative-free methods reached the 100-clearing limit in nearly all runs.
Five PGLib benchmark systems, from 300 to 2,869 buses, were cleared by AC optimal power flow. In each of several randomized variations per system, 10% of the nodes were made bidding nodes with sampled initial offers. Four gradient-based and four derivative-free methods from the NLopt library each received at most 100 clearings, with gradients through the AC clearing computed by the nonlinear extension of DiffOpt.jl (Rosemberg et al., 2025a). Counting clearings is a uniform measure of cost, because the sensitivity solve reuses the factorized KKT system and is cheap beside the clearing itself.
On the smallest system the simpler landscape leaves derivative-free search competitive; on the larger ones the paper attributes its shortfall to the dimension of the offer, which grows with the number of bidding nodes.
05 · Beyond local searchWhere the local branch is uninformative, a prior or an average over contexts replaces it
Global surrogate search
Where the local branch does not describe the change in response that matters, a global method replaces the derivative by a prior. Bayesian optimization models the objective as a Gaussian process and chooses each new clearing by an acquisition function \(\alpha_n\) computed from the posterior after \(n\) clearings,
Here \(m\) is the prior mean and \(k\) the covariance kernel, \(\mathcal D_n\) the \(n\) offers cleared so far with their evaluated profits \(\hat J_i\), \(\mathbf k_n(u)\) and \(K_n\) the kernel evaluated between \(u\) and those offers and among them, \(\mathbf m_n\) the prior mean at those offers, \(\sigma_\varepsilon^2\) the evaluation noise, and \(\beta_n\) the weight on exploration. Every term of the acquisition is computed from \(k\): The posterior mean interpolates the cleared offers through it, and the exploration term measures how far an offer lies from them in the geometry it defines. The kernel therefore decides both where the surrogate expects profit and where it expects to learn, and the surrogate can leave the current basin and find another response regime only if \(k\) describes the objective it explores.
Strategic-offer profit is piecewise and upper semicontinuous, with jumps where the active set of the clearing changes. A stationary kernel assigns one correlation length to the whole offer space, so it either smooths over the jumps or, fitted to them, treats every gap between clearings as uncertain. Some kernels, among them the squared-exponential and Matérn families, are universal: Their reproducing kernel Hilbert spaces are dense in the continuous functions on a compact set, so with enough clearings the posterior can approximate the profit arbitrarily well away from its jumps. Universality concerns what the surrogate can eventually represent, however, not how many clearings the search needs to find a good offer: Regret bounds for this acquisition grow with the kernel’s maximal information gain, which is larger for rougher kernels and grows with the dimension of the offer (Srinivas et al., 2010).
Fitted by maximum likelihood to the same ten clearings along one offer direction, three out-of-the-box kernels place their uncertainty differently, and none of them includes the profit peak, which lies between the first two cleared offers, inside its posterior band.

The burden moves from local fidelity of the clearing model to global fidelity of the surrogate, and the clearings needed to make the surrogate informative become the limiting cost as the dimension of the offer grows. Extensive exploration of out-of-the-box kernels found the rational quadratic the best of them for the studied case, and the search below uses it, although it still describes the jumps of the profit only approximately.

Offer policies trained through the clearing
The comparison searches one offer for one context. The same derivative can train a map from observed context \(w\) to offers, \(u=\phi_\theta(w)\), by stochastic gradient on
Here \(\mathbb P_w\) is the law of observed contexts, \(\mathbb P(\cdot\mid w)\) the conditional law of the unobserved context \(\xi\), and \(\Pi(u;\xi)\) the profit of offer \(u\) under \(\xi\), which is realized after the offer is fixed. Each sample costs one clearing and one adjoint solve. The expectation should also smooth the objective: averaged over load scenarios, the mean profit along an offer is relatively smooth (Rosemberg et al., 2025d, Figs. 4–5), which would favor every iterative method. This is the decision-focused learning developed on Differentiating Optimization Models, with the downstream optimization belonging to another agent: The clearing minimizes the cost of supply, while the map is trained on the producer’s profit. The offered quantities can themselves be set by a state policy, for instance storage discharge prescribed by a policy of Policies for Multistage Decisions; the clearing response then returns through the offer to the policy’s parameters. In the two-settlement problem the derivative passes through both clearings and the state between them, and the expectation over \(\xi\) is taken under an estimated law that an ambiguity set can protect, as developed on Uncertainty and Ambiguity. When the optimization is the decision maker’s own controller rather than another agent’s mechanism, the same derivative path can train the controller’s targets and coefficients, the other setting of decision-focused learning.
Software
OptimalBids.jl turns a market-clearing model into one object on which derivative-free search, gradient search, and exact bilevel reformulations act, and DiffOpt.jl differentiates the clearing.
OptimalBids.jl
Reduces a market to four operations, so derivative-free search, gradient search and exact bilevel reformulations act on one market definition.
DiffOpt.jl
Solution and optimal-value derivatives of JuMP models with respect to named parameters, through the model's reformulations, for convex and smooth nonconvex programs.
References
- F. Borrelli, A. Bemporad, M. Morari. Geometric algorithm for multiparametric linear programming. Journal of Optimization Theory and Applications 118:515–540, 2003.
- M. Dolányi, K. Bruninx, J.-F. Toubeau, E. Delarue. Capturing electricity market dynamics in strategic market participation using neural network constrained optimization. IEEE Transactions on Power Systems 39(1):533–545, 2024.
- A. V. Fiacco. Sensitivity analysis for nonlinear programming using penalty methods. Mathematical Programming 10(1):287–311, 1976.
- R. Fletcher, S. Leyffer. Solving mathematical programs with complementarity constraints as nonlinear programs. Optimization Methods and Software 19(1):15–40, 2004.
- J. Fortuny-Amat, B. McCarl. A representation and economic interpretation of a two-level programming problem. Journal of the Operational Research Society 32(9):783–792, 1981.
- B. F. Hobbs, C. B. Metzler, J.-S. Pang. Strategic gaming analysis for electric power systems: An MPEC approach. IEEE Transactions on Power Systems 15(2):638–645, 2000.
- H. Pirnay, R. López-Negrete, L. T. Biegler. Optimal sensitivity based on IPOPT. Mathematical Programming Computation 4:307–331, 2012.
- M. J. D. Powell. The BOBYQA algorithm for bound constrained optimization without derivatives. Cambridge NA Report NA2009/06, University of Cambridge, 2009.
- D. Ralph, S. Dempe. Directional derivatives of the solution of a parametric nonlinear program. Mathematical Programming 70(1–3):159–172, 1995.
- C. Ruiz, A. J. Conejo. Pool strategy of a producer with endogenous formation of locational marginal prices. IEEE Transactions on Power Systems 24(4):1855–1866, 2009.
- S. Siddiqui, S. A. Gabriel. An SOS1-based approach for solving MPECs with a natural gas market application. Networks and Spatial Economics 13:205–227, 2013.
- N. Srinivas, A. Krause, S. M. Kakade, M. Seeger. Gaussian process optimization in the bandit setting: No regret and experimental design. International Conference on Machine Learning (ICML), 2010.
- L. Xu, R. Baldick, Y. Sutjandra. Bidding into electricity markets: A transmission-constrained residual demand derivative approach. IEEE Transactions on Power Systems 26(3):1380–1388, 2011.
- D. Macedo, R. Ribeiro, B. Fanzeres, A. W. Rosemberg. Virtual transactions in electricity markets: An instrument for a reliable energy transition towards a low-carbon operation. 54th Brazilian Symposium of Operations Research (SBPO), 2022. Paper
- A. W. Rosemberg, J. Dias Garcia, F. Pacaud, R. B. Parker, B. Legat, K. Sundar, R. Bent, P. Van Hentenryck. A general and streamlined differentiable optimization framework. Preprint arXiv:2510.25986, 2025. Preprint
- A. W. Rosemberg, F. Pacaud, J. Dias Garcia, R. B. Parker, K. Sundar, R. Bent, P. Van Hentenryck. Strategic bidding in energy markets with gradient-based iterative methods. Sustainable Energy, Grids and Networks, 101878, 2025. Paper
Publication
Strategic Bidding in Energy Markets with Gradient-Based Iterative Methods
Paper Preprint (SSRN)BibTeX
@article{rosemberg2025strategic, title = {Strategic bidding in energy markets with gradient-based iterative methods}, author = {Rosemberg, Andrew and Pacaud, Fran{\c{c}}ois and Dias Garcia, Joaquim and Parker, Robert B. and Sundar, Kaarthik and Bent, Russell and Van Hentenryck, Pascal}, journal = {Sustainable Energy, Grids and Networks}, volume = {43}, pages = {101878}, year = {2025}, doi = {10.1016/j.segan.2025.101878} }

