  A breakthrough result of B\'ar\'any, Hochman and Rapaport published in 2019
established that every self-affine measure on $\mathbb{R}^2$ satisfying certain
mild non-degeneracy conditions has Hausdorff dimension equal to its Lyapunov
dimension. In combination with a variational principle established earlier by
Morris and Shmerkin this result implied as a corollary that the attractor of a
planar affine iterated function system satisfying the same conditions
necessarily has Hausdorff dimension equal to a value proposed by Falconer in
1988. In this article we extend the variational principle of Morris and
Shmerkin from the planar context to the case of affine iterated function
systems acting on $\mathbb{R}^d$. This allows a recent theorem of Rapaport on
the dimensions of self-affine measures in $\mathbb{R}^3$ to be extended into a
characterisation of the dimensions of the corresponding self-affine subsets of
$\mathbb{R}^3$. At the core of the present work is an algebraic result
concerned with finding large Zariski-dense Schottky semigroups inside a given
finitely generated completely reducible semigroup of linear transformations.
