A sand mold digital flexible extrusion near-net forming optimization method based on a search algorithm, the method comprising the following steps: dividing a sand mold Computer Aided Design (CAD) 3D model near-net forming region into mxn sub-regions, each having a size of axb, according to arrangement of mxn flexible extrusion arrays, each having a size of axb, on a sand mold digital flexible extrusion working platform; directly acquiring a curved surface function f x y = f 1,1 x y min ⋯ f 1 , j x y min ⋯ f 1 , n x y min ⋮ ⋱ ⋮ ⋰ ⋮ f i , 1 x y min ⋯ f i , j x y min ⋯ f i , n x y min ⋮ ⋰ ⋮ ⋱ ⋮ f m , 1 x y min ⋯ f m , j x y min ⋯ f m , n x y min of a near-net forming sand mold CAD 3D model cavity under driving of a sand mold CAD 3D model, where i, j ∈ Z, and 1 ≤i ≤ m, 1 ≤ j ≤ n; constructing a flexible extrusion array envelope volume optimization objective function V x y = a × b × ∑ j = 1 n ∑ i = 1 m f i , j x y min in the near-net forming sand mold CAD 3D model cavity; determining a valid optimization interval R = { x ∈ am 2 − a 2 , am 2 + a 2 y ∈ bn 2 − b 2 , bn 2 + b 2 of a position of the near-net forming sand mold CAD 3D model cavity; translating the position of the near-net forming sand mold CAD 3D model cavity to a search initial position A 1,1 , which is equal to am 2 − a 2 , bn 2 − b 2 ; determining a search direction as an x increment direction and a y increment direction; determining search step length parameters Δx and Δy in x and y directions according to error requirements of the x and y directions respectively; performing search in the valid optimization interval R, comparing flexible extrusion array envelope volume values V(x,y) p,q calculated in a search process, saving a larger value as V(x,y) max , saving the corresponding position as (x,y) max , and recording the corresponding value of f i,j (x,y) min ; and completing the search, translating the position of the near-net forming sand mold CAD 3D model cavity to (x,y) max , and executing a flexible extrusion array shape adjusting procedure. dividing a sand mold Computer Aided Design (CAD) 3D model near-net forming region into mxn sub-regions, each having a size of axb, according to arrangement of mxn flexible extrusion arrays, each having a size of axb, on a sand mold digital flexible extrusion working platform; directly acquiring a curved surface function f x y = f 1,1 x y min ⋯ f 1 , j x y min ⋯ f 1 , n x y min ⋮ ⋱ ⋮ ⋰ ⋮ f i , 1 x y min ⋯ f i , j x y min ⋯ f i , n x y min ⋮ ⋰ ⋮ ⋱ ⋮ f m , 1 x y min ⋯ f m , j x y min ⋯ f m , n x y min of a near-net forming sand mold CAD 3D model cavity under driving of a sand mold CAD 3D model, where i, j ∈ Z, and 1 ≤i ≤ m, 1 ≤ j ≤ n; constructing a flexible extrusion array envelope volume optimization objective function V x y = a × b × ∑ j = 1 n ∑ i = 1 m f i , j x y min in the near-net forming sand mold CAD 3D model cavity; determining a valid optimization interval R = { x ∈ am 2 − a 2 , am 2 + a 2 y ∈ bn 2 − b 2 , bn 2 + b 2 of a position of the near-net forming sand mold CAD 3D model cavity; translating the position of the near-net forming sand mold CAD 3D model cavity to a search initial position A 1,1 , which is equal to am 2 − a 2 , bn 2 − b 2 ; determining a search direction as an x increment direction and a y increment direction; determining search step length parameters Δx and Δy in x and y directions according to error requirements of the x and y directions respectively; performing search in the valid optimization interval R, comparing flexible extrusion array envelope volume values V(x,y) p,q calculated in a search process, saving a larger value as V(x,y) max , saving the corresponding position as (x,y) max , and recording the corresponding value of f i,j (x,y) min ; and completing the search, translating the position of the near-net forming sand mold CAD 3D model cavity to (x,y) max , and executing a flexible extrusion array shape adjusting procedure. <EOS>