Amortized Synthesis of Constrained Configurations Using a Differentiable Surrogate

1 Introduction . One of the ambitions of artificial intelligence is to automate problems in design , fabrication , and control that demand efficient and accurate interfaces between machine learning algorithms and physical systems . Whether it is optimizing the topology of a mechanical structure or identifying the feasible paths for a manufacturing robot , we can often view these problems through the lens of synthesis . In a synthesis task , we seek configurations of a physical system that achieve certain desiderata while satisfying given constraints ; i.e. , we must optimize a physically-realizable design . In this work , design refers to the parametric space over which we have control and in which , e.g. , we optimize . A realization is the object that arises when the design is instantiated , while goal refers to its desired properties . For example , in fabrication , the design might be a set of assembly steps , the realization would be the resulting object , while the goal could be to match target dimensions while maximizing strength . Synthesis , then , refers to finding a design whose realization achieves the goal . Synthesis problems are challenging for several reasons . The physical realization process may be costly and time-consuming , making evaluation of many designs difficult . Moreover , the realization process—or even a simulation of it—is generally not differentiable , rendering efficient gradient-based methods inapplicable . Finally , there may be a many-to-one map from the parametric space of feasible and equally-desirable designs to realizations ; i.e. , there may be multiple ways to achieve the goal . Surrogate modeling is widely used to address the first two challenges , though it can still be expensive because of the need for optimization , sampling , or search algorithms to find a feasible design . More seriously , the third challenge—lack of uniqueness—creates difficulties for naïve supervised learning 35th Conference on Neural Information Processing Systems ( NeurIPS 2021 ) . approaches to synthesis . Specifically , consider generating many design/realization pairs , evaluating the constraints and objectives on the realizations , and attempting to learn a supervised map from goal back to design . When multiple designs lead to the same realization , or multiple realizations achieve the same goal , the supervised learner is penalized for producing designs that are valid but happen to not be the ones used to generate the data . Moreover , this approach may learn to produce an “ average ” design that is actually incorrect . Figure 1a shows a cartoon example : if the goal is to throw a ball to reach some target distance , there are two possible launch angles ( designs ) resulting in landing points ( realizations ) at the correct spot . Performing least-squares regression from distance to angle on the full set of distance/angle pairs , however , learns an average angle that does not satisfy the goal . To address these challenges , we propose to use a two-stage neural network architecture that resembles an autoencoder . One stage ( the decoder ) acts as a differentiable surrogate capturing the many-to-one physical realization process . The other stage ( the encoder ) maps from a goal back to a design but , critically , it is trained end-to-end with a loss in the space of realizations that flows back through the decoder . Thus the encoder—our central object of interest for synthesis—is not constrained to match a specific design in a training dataset , but instead is tasked with finding any design that meets the desiderata of the realized output . The result is a neural network that performs amortized synthesis : it is trained once , and at run time produces a design that is approximately optimal , using only a feed-forward architecture . Note that our method is not an autoencoder , as the design is not a lower-dimensional representation of the goal , and the encoder and the decoder are trained in separate stages . Our method places a number of requirements on the synthesis problem . First , to train the surrogate , we need data pairs of designs and realizations . Commonly , this would require us to generate designs , in which a substantial amount of designs are viable , and simulate them on a simulator . Second , given our current setting , the physical realization process needs to be deterministic . Third , to train the encoder , the synthesis problem should have a clear objective function , or at least we can quantify the objective . Finally , given our current feed-forward setting , we consider synthesis problems that need only one valid design , although we may further extend our method by using a generative encoder . In this work , we demonstrate this two-stage approach on a pair of specific design tasks . The first case study is extruder path planning for a class of 3D printers ( the Markforged Mark Two ) that can reinforce polymer layers with discrete fibers ( Figure 1b ) . Since the fibers are stiff , their shape is deformed after extrusion ( Figure 1c , top row ) , and our task is to find an extruder path that results in a given fiber shape . As shown in Figure 1c , this problem has the many-to-one nature described above : for a small error tolerance on fiber path , there exist infinitely many extruder paths , which may even look very different . The second case study is constrained soft robot inverse kinematics . In this work , we use a simulation of a snake-like soft robot as in Xue et al . [ 97 ] , in which we can control the stretch ratios of each individual segment on both sides of the robot . The robot has to reach a target while avoiding an obstacle , and the locations of both are input goals . As before , there may be multiple solutions for a given goal ( i.e. , locations of target and obstacle ) , as shown in Figure 1d . For both case studies , we compare to two baseline algorithms . In direct-learning , a neural network for the synthesis problem ( i.e. , from goal to design ) is trained in a supervised manner on a set of designs . Since this effectively averages designs in the training dataset , as argued above , our method outperforms it significantly . The second baseline is direct-optimization , which uses a gradient-based method ( BFGS ) to optimize for each new design separately , given access to the trained differentiable surrogate for the realization process ( decoder ) . Our method is competitive with this rough “ performance upper bound ” while using dramatically lower computational resources . 2 Related work . Machine learning applications in synthesis problems . In synthesis tasks , the aim is to find a design solution such that its realization achieves one or more given goals . Usually , the solution is nonunique , and only one is needed . In molecule discovery , one would like to find a molecule which has some desired properties ( e.g. , minimal side effects , efficacy , metabolic stability , growth inhibition ) [ 20 , 46 , 71 , 41 , 83 ] . See Vamathevan et al . [ 90 ] , Chen et al . [ 16 ] for surveys on machine/deep learning in drug discovery . Challenges of molecule discovery include discrete design space [ 32 , 76 ] and limited data [ 47 ] due to difficulty in simulation . In materials synthesis , researchers seek materials with specific properties . See Bhuvaneswari et al . [ 7 ] for a review . Similarly , to obtain enough training data , researchers have put efforts into parsing and learning from scientific literature in natural language [ 52 , 45 ] . In 3D shape generation , one wants to find a 3D shape that has some desired properties : properties like 2.5D sketches [ 95 ] that can be easily calculated and properties like functionality [ 34 ] that need to be human-labeled . In topology optimization , researchers aim to maximize the system ’ s performance by optimizing the material layout given boundary conditions , constraints , external loads , etc [ 80 , 5 , 93 ] . Machine learning has been used to infer properties [ 75 ] , find representations of designs [ 48 , 99 ] , and directly generate designs [ 55 ] . In program synthesis , the goal is to find programs that realize given intentions ( e.g. , generating 3D shapes , answering visual questions ) [ 35 , 88 , 98 ] , where machine learning has been used to generate programs and execute programs . In this work , we propose an approach to learn a feed-forward neural network that can directly and efficiently produce a feasible solution to a synthesis problem that satisfies the requirements mentioned above . Surrogate/oracle-based synthesis . Surrogate/oracle-based synthesis uses an auxiliary model— a surrogate ( or sometimes called oracle ) —that can evaluate qualities of a design without timeconsuming laboratory experiments , while still being reasonably accurate [ 58 , 9 ] . Surrogate models can be physics-based or approximation-based [ 57 ] ( i.e. , empirical ) , and there are different modeling techniques for approximation-based surrogates , including polynomial regression , radial basis functions , Gaussian processes , and neural networks [ 58 , 39 ] . Bhosekar and Ierapetritou [ 6 ] provide a review of surrogate-based methods , and see Koziel and Leifsson [ 56 ] for a general review of surrogate models in engineering . There are two major approaches : optimization and sampling . The most common approach is surrogate-based optimization ; see Forrester and Keane [ 29 ] for a survey . Some application examples include : optimizing the parameters of a CPU simulator [ 72 ] ; solving partial differential equations in service of PDE-constrained optimization [ 97 ] ; and optimizing stochastic non-differentiable simulators [ 79 ] . Researchers have also developed methods to deal with the challenge that inputs can be out-of-distribution for the oracle [ 27 , 30 , 89 ] . On the other hand , sampling-based methods have several advantages : the design space can be discrete and can generate multiple designs [ 9 , 10 , 24 ] . Researchers have successfully applied sampling methods to problems in chemistry [ 32 ] and biology [ 36 , 51 , 73 ] . In this work , we use surrogate-based optimization as one of our baseline algorithms , and our proposed method uses a surrogate during training to optimize for a feed-forward network for the design problem . Differentiable surrogate of losses in machine learning . Since some loss functions in machine learning are not differentiable ( e.g. , IoU for rotated bounding boxes , 0-1 loss in classification ) , researchers have proposed to learn surrogates for them . Grabocka et al . [ 33 ] provided a formulation of surrogate loss learning and compared several learning mechanisms on some commonly used non-differentiable loss functions . Liu et al . [ 62 ] proposed a general pipeline to learn surrogate losses . Bao et al . [ 2 ] , Hanneke et al . [ 40 ] provided theoretical analyses of surrogates for 0-1 loss in classification . Patel et al . [ 70 ] , Nagendar et al . [ 64 ] , Yuan et al . [ 100 ] explored the use of surrogate losses in various real-world tasks , including medical image classification , semantic segmentation , and text detection and recognition . In this work , due to the non-uniqueness of design solutions , we further extend this idea from loss functions to more complex , physical realization processes . Robot motion planning . Robot motion planning [ 59 ] can also be viewed as a form of synthesis , and there are different types of approaches to it . One popular strategy is optimization . For example , researchers have used evolutionary algorithms ( EA ) [ 60 , 12 , 42 ] , including variants of genetic algorithms ( GA ) [ 18 , 17 , 87 , 11 , 50 , 53 , 28 ] and covariance matrix adaptation evolution strategy ( CMA-ES ) [ 37 ] . Another example is constrained optimization [ 94 , 85 , 21 , 23 ] , which includes extensions like sequential quadratic programming ( SQP ) [ 15 , 37 ] and the DIRECT algorithm [ 91 ] . Other examples of optimization applied to robot motion planning include reinforcement learning [ 81 , 25 ] and teaching-learning-based optimization [ 82 ] . Another popular class of methods is sampling , including simulated annealing ( SA ) [ 4 , 69 , 101 ] , probabilistic roadmaps ( PRM ) [ 49 ] , rapidly exploring random trees ( RRT ) [ 14 , 4 , 13 ] , etc . Finally , search methods , e.g. , A * search [ 38 ] , have been used to solve motion planning problems . These works usually model the robot ’ s physics directly without using a surrogate model and solve the design using methods including optimization , sampling , and search , which can be time-consuming . Our method amortizes the cost of inference , and can be used to solve planning problems with more complex physics that can not be directly modeled . In our first case study , we plan for a trajectory of the extruder , and our design space is not the speeds of the motors but rather the coordinates of points along the trajectory . In the second case study , rather than solving a dynamic planning problem , we solve a static planning task on a soft robot , with the stretch ratios of all the controllable segments of the robot as the design space . Path planning in 3D printing . Path planning is one of the most important problems in 3D printing , and people plan for different objectives : minimizing printing time , avoiding collision , faster planning , etc . Shembekar et al . [ 78 ] proposed a planning algorithm to build complex shapes with multiple curvatures and can avoid collisions . Ganganath et al . [ 31 ] minimized the printing time by modeling the task as a traveling salesman problem . Xiao et al . [ 96 ] speeded up path planning algorithms by introducing efficient topology reconstruction algorithms . Stragiotti [ 84 ] provided an optimizationbased algorithm that minimizes compliance of a printed part . Asif [ 1 ] introduced a planning algorithm for continuous fiber and can generate a continuous deposition path . See Huang et al . [ 43 ] for a review of existing work in 3D printing path design . In this work , instead of the aforementioned objectives , we plan an extruder path to compensate for the deformation caused by the printing process . We demonstrate increased run-time efficiency by amortizing the cost of physical simulation of the printing process , learning a feed-forward network to output the extruder path .

Summary: The core concern of this paper is the synthesis problem of choosing design parameters in a complex engineering design process mapping a high level goal to a high dim description of how the process achieves it. This is studied using the examples of 3D printing path planning and trajectory generation for a soft robotic arm.   The core contribution is to set up this problem in terms of two stages - mapping goals to a space of designs, and then an evaluation of designs in terms of a cost function. This breaks down one of the difficulties identified - the ill-posedness of the problem due to multi-valued maps. So, the authors set up an autoencoder architecture with an encoder that conjectures designs based on goals, and a surrogate model to evaluate the designs.