Constraints (.core.constraints)

Contents

Constraints (.core.constraints)#

Constraint Language (.core.constraints.constraint_language)#

constants#

class infinigen.core.constraints.constraint_language.constants.RoomConstants(
n_stories=('cat', 0.0, 0.5, 0.4, 0.1),
room_type=None,
aspect_ratio_range=(0.7, 1.0),
fixed_contour=('bool', 0.5),
)[source]#

Bases: object

global_params(...)[source]#
Parameters:
  • unit -- (default: 0.5)

  • segment_margin -- (default: 1.4)

  • wall_thickness -- (default: ('uniform', 0.2, 0.3))

  • wall_height -- (default: ('uniform', 2.8, 3.2))

door_params(
door_width_ratio=('uniform', 0.7, 0.8),
door_size=('uniform', 2.0, 2.4),
)[source]#
Parameters:
  • door_width_ratio -- (default: ('uniform', 0.7, 0.8))

  • door_size -- (default: ('uniform', 2.0, 2.4))

window_params(...)[source]#
Parameters:
  • max_window_length -- (default: ('uniform', 6, 8))

  • window_height -- (default: ('uniform', 0.8, 1.2))

  • window_margin -- (default: ('uniform', 0.2, 0.25))

  • window_size -- (default: ('uniform', 1.0, 1.5))

staircase_params()[source]#
unit_cast(x)[source]#
Parameters:

x

canonicalize(p)[source]#
Parameters:

p

filter(ses, margin=None)[source]#
Parameters:
  • ses

  • margin -- (default: None)

property home_room_types#
property floors#

expression#

class infinigen.core.constraints.constraint_language.expression.Expression[source]#

Bases: Node

classmethod register_postfix_func(expr_cls)[source]#
Parameters:

expr_cls

debugprint(
val: Expression,
msg: str,
)[source]#
Parameters:
class infinigen.core.constraints.constraint_language.expression.ArithmethicExpression[source]#

Bases: Expression

class infinigen.core.constraints.constraint_language.expression.ScalarExpression[source]#

Bases: ArithmethicExpression

minimize(*, weight)[source]#
Parameters:

weight (float)

maximize(*, weight)[source]#
Parameters:

weight (float)

multiply(other)[source]#
Parameters:

other

abs()[source]#
add(other)[source]#
Parameters:

other

sub(other)[source]#
Parameters:

other

div(other)[source]#
Parameters:

other

safediv(other)[source]#
Parameters:

other

pow(other)[source]#
Parameters:

other

equals(other)[source]#
Parameters:

other

clamp_min(other)[source]#
Parameters:

other

clamp_max(other)[source]#
Parameters:

other

clip(a_min=-inf, a_max=inf)[source]#
Parameters:
  • a_min -- (default: -inf)

  • a_max -- (default: inf)

log()[source]#
hinge(
val: ScalarExpression,
low: float,
high: float,
)[source]#
Parameters:
in_range(...)[source]#
Parameters:
rand(type, args)[source]#

Computes the NLL of an integer sample given the distribution type and arguments type can be of ‘bool’(‘bern’) / ‘categorical’(‘cat’)

Parameters:
infinigen.core.constraints.constraint_language.expression.max_expr(*args)[source]#
infinigen.core.constraints.constraint_language.expression.min_expr(*args)[source]#
class infinigen.core.constraints.constraint_language.expression.BoolExpression[source]#

Bases: ArithmethicExpression

class infinigen.core.constraints.constraint_language.expression.constant(value: int)[source]#

Bases: ScalarExpression

Parameters:

value (int)

class infinigen.core.constraints.constraint_language.expression.BoolOperatorExpression(
func: Callable,
operands: list[Expression],
)[source]#

Bases: BoolExpression

Parameters:
children()[source]#
class infinigen.core.constraints.constraint_language.expression.ScalarOperatorExpression(
func: Callable,
operands: list[Expression],
)[source]#

Bases: ScalarExpression

Parameters:
children()[source]#
class infinigen.core.constraints.constraint_language.expression.hinge(
val: ScalarExpression,
low: float,
high: float,
)[source]#

Bases: ScalarExpression

Parameters:
class infinigen.core.constraints.constraint_language.expression.debugprint(
val: Expression,
msg: str,
)[source]#

Bases: ScalarExpression, BoolExpression

Parameters:

gather#

class infinigen.core.constraints.constraint_language.gather.item(
name: str,
member_of: ObjectSetExpression,
)[source]#

Bases: ObjectSetExpression

Parameters:
children()[source]#
class infinigen.core.constraints.constraint_language.gather.ForAll(
objs: ObjectSetExpression,
var: str,
pred: BoolExpression,
)[source]#

Bases: BoolExpression

Parameters:
infinigen.core.constraints.constraint_language.gather.all(
objs,
pred,
) BoolExpression[source]#
Parameters:
class infinigen.core.constraints.constraint_language.gather.SumOver(
objs: ObjectSetExpression,
var: str,
pred: ScalarExpression,
)[source]#

Bases: ScalarExpression

Parameters:
infinigen.core.constraints.constraint_language.gather.sum(objs, pred)[source]#
Parameters:
class infinigen.core.constraints.constraint_language.gather.MeanOver(
objs: ObjectSetExpression,
var: str,
pred: ScalarExpression,
)[source]#

Bases: ScalarExpression

Parameters:
infinigen.core.constraints.constraint_language.gather.mean(objs, pred)[source]#
Parameters:

geometry#

class infinigen.core.constraints.constraint_language.geometry.center_stable_surface_dist(
objs: ObjectSetExpression,
)[source]#

Bases: ScalarExpression

Parameters:

objs (ObjectSetExpression)

class infinigen.core.constraints.constraint_language.geometry.accessibility_cost(
objs: ObjectSetExpression,
others: ObjectSetExpression,
normal: <built-in function array> = <factory>,
dist: float = 1.0,
)[source]#

Bases: ScalarExpression

Parameters:
dist: float = 1.0#
class infinigen.core.constraints.constraint_language.geometry.distance(
objs: ObjectSetExpression,
others: ObjectSetExpression,
others_tags: set = <factory>,
)[source]#

Bases: ScalarExpression

Parameters:
class infinigen.core.constraints.constraint_language.geometry.min_distance_internal(
objs: ObjectSetExpression,
)[source]#

Bases: ScalarExpression

Parameters:

objs (ObjectSetExpression)

class infinigen.core.constraints.constraint_language.geometry.focus_score(
objs: ObjectSetExpression,
others: ObjectSetExpression,
)[source]#

Bases: ScalarExpression

Parameters:
class infinigen.core.constraints.constraint_language.geometry.angle_alignment_cost(
objs: ObjectSetExpression,
others: ObjectSetExpression,
others_tags: set = None,
)[source]#

Bases: ScalarExpression

Parameters:
others_tags: set = None#
class infinigen.core.constraints.constraint_language.geometry.freespace_2d(
objs: ObjectSetExpression,
others: ObjectSetExpression,
)[source]#

Bases: ScalarExpression

Parameters:
class infinigen.core.constraints.constraint_language.geometry.min_dist_2d(
objs: ObjectSetExpression,
others: ObjectSetExpression,
)[source]#

Bases: ScalarExpression

Parameters:
class infinigen.core.constraints.constraint_language.geometry.rotational_asymmetry(
objs: ObjectSetExpression,
)[source]#

Bases: ScalarExpression

Parameters:

objs (ObjectSetExpression)

class infinigen.core.constraints.constraint_language.geometry.reflectional_asymmetry(
objs: ObjectSetExpression,
others: ObjectSetExpression,
use_long_plane: bool = True,
)[source]#

Bases: ScalarExpression

Parameters:
use_long_plane: bool = True#
class infinigen.core.constraints.constraint_language.geometry.volume(
objs: ObjectSetExpression,
dims: int | tuple = 3,
)[source]#

Bases: ScalarExpression

Parameters:
dims: int | tuple = 3#
class infinigen.core.constraints.constraint_language.geometry.coplanarity_cost(
objs: ObjectSetExpression,
)[source]#

Bases: ScalarExpression

Parameters:

objs (ObjectSetExpression)

relations#

class infinigen.core.constraints.constraint_language.relations.Relation[source]#

Bases: ABC

abstractmethod implies(other) bool[source]#

self must imply all parts of other, both positive and negative.

Parameters:

other

abstractmethod satisfies(other) bool[source]#

self must imply all positive parts of other, and not contradict any negative parts

Parameters:

other (Relation)

abstractmethod intersects(other, strict=False) bool[source]#
Parameters:
  • other

  • strict -- (default: False)

abstractmethod intersection(other) Relation[source]#
Parameters:

other (Relation)

abstractmethod difference(other) Relation[source]#
Parameters:

other (Relation)

class infinigen.core.constraints.constraint_language.relations.AnyRelation[source]#

Bases: Relation

implies(other) bool[source]#

self must imply all parts of other, both positive and negative.

Parameters:

other

satisfies(other) bool[source]#

self must imply all positive parts of other, and not contradict any negative parts

Parameters:

other (Relation)

intersects(_other, strict=False) bool[source]#
Parameters:
  • _other (Relation)

  • strict -- (default: False)

intersection(other) Relation[source]#
Parameters:

other (Relation)

difference(other)[source]#
Parameters:

other (Relation)

class infinigen.core.constraints.constraint_language.relations.NegatedRelation(rel: 'Relation')[source]#

Bases: Relation

Parameters:

rel (Relation)

implies(other) bool[source]#

self must imply all parts of other, both positive and negative.

Parameters:

other (Relation)

satisfies(other) bool[source]#

self must imply all positive parts of other, and not contradict any negative parts

Parameters:

other (Relation)

intersects(other, strict=False) bool[source]#
Parameters:
  • other (Relation)

  • strict -- (default: False)

intersection(other) Relation[source]#
Parameters:

other (Relation)

difference(other) Relation[source]#
Parameters:

other (Relation)

class infinigen.core.constraints.constraint_language.relations.ConnectorType(value)[source]#

Bases: Enum

Door = 'door'#
Open = 'open'#
Wall = 'wall'#
class infinigen.core.constraints.constraint_language.relations.RoomNeighbour(connector_types: 'frozenset[ConnectorType]' = <factory>)[source]#

Bases: Relation

Parameters:

connector_types (frozenset[ConnectorType])

implies(other) bool[source]#

self must imply all parts of other, both positive and negative.

Parameters:

other (Relation)

satisfies(other) bool[source]#

self must imply all positive parts of other, and not contradict any negative parts

Parameters:

other (Relation)

intersects(other, strict=False) bool[source]#
Parameters:
  • other (Relation)

  • strict -- (default: False)

intersection(other) Relation[source]#
Parameters:

other (Relation)

difference(other) Relation[source]#
Parameters:

other (Relation)

infinigen.core.constraints.constraint_language.relations.no_frozenset_repr(self)[source]#
Parameters:

self (GeometryRelation)

class infinigen.core.constraints.constraint_language.relations.GeometryRelation(
child_tags: 'frozenset[t.Subpart]' = <factory>,
parent_tags: 'frozenset[t.Subpart]' = <factory>,
)[source]#

Bases: Relation

Parameters:
implies(other) bool[source]#

self must imply all parts of other, both positive and negative.

Parameters:

other (Relation)

satisfies(other) bool[source]#

self must imply all positive parts of other, and not contradict any negative parts

Parameters:

other (Relation)

intersects(other, strict=False) bool[source]#
Parameters:
  • other (Relation)

  • strict -- (default: False)

intersection(other) Relation[source]#

TODO: There are potentially many intersections of relations with negations.

Parameters:
difference(other) Relation[source]#
Parameters:
class infinigen.core.constraints.constraint_language.relations.Touching(
child_tags: 'frozenset[t.Subpart]' = <factory>,
parent_tags: 'frozenset[t.Subpart]' = <factory>,
)[source]#

Bases: GeometryRelation

Parameters:
class infinigen.core.constraints.constraint_language.relations.SupportedBy(
child_tags: 'frozenset[t.Subpart]' = <factory>,
parent_tags: 'frozenset[t.Subpart]' = <factory>,
)[source]#

Bases: Touching

Parameters:
class infinigen.core.constraints.constraint_language.relations.CoPlanar(
child_tags: 'frozenset[t.Subpart]' = <factory>,
parent_tags: 'frozenset[t.Subpart]' = <factory>,
margin: 'float' = 0,
rev_normal: 'bool' = False,
)[source]#

Bases: GeometryRelation

Parameters:
margin: float = 0#
rev_normal: bool = False#
class infinigen.core.constraints.constraint_language.relations.StableAgainst(
child_tags: 'frozenset[t.Subpart]' = <factory>,
parent_tags: 'frozenset[t.Subpart]' = <factory>,
margin: 'float' = 0,
check_z: 'bool' = True,
rev_normal: 'bool' = False,
)[source]#

Bases: GeometryRelation

Parameters:
margin: float = 0#
check_z: bool = True#
rev_normal: bool = False#
class infinigen.core.constraints.constraint_language.relations.IdentityCompareRelation[source]#

Bases: Relation

implies(other) bool[source]#

self must imply all parts of other, both positive and negative.

Parameters:

other (Relation)

satisfies(other) bool[source]#

self must imply all positive parts of other, and not contradict any negative parts

Parameters:

other (Relation)

intersects(other, strict=False) bool[source]#
Parameters:
  • other (Relation)

  • strict -- (default: False)

intersection(other) Relation[source]#
Parameters:

other (Relation)

difference(other) Relation[source]#
Parameters:

other (Relation)

class infinigen.core.constraints.constraint_language.relations.CutFrom[source]#

Bases: IdentityCompareRelation

class infinigen.core.constraints.constraint_language.relations.SharedEdge[source]#

Bases: IdentityCompareRelation

class infinigen.core.constraints.constraint_language.relations.Traverse[source]#

Bases: IdentityCompareRelation

result#

class infinigen.core.constraints.constraint_language.result.Problem(constraints: dict[str, infinigen.core.constraints.constraint_language.expression.BoolExpression], score_terms: dict[str, infinigen.core.constraints.constraint_language.expression.ScalarExpression], constants: infinigen.core.constraints.constraint_language.constants.RoomConstants = <factory>)[source]#

Bases: Node

Parameters:
children()[source]#
filter(name)[source]#
Parameters:

name

rooms#

class infinigen.core.constraints.constraint_language.rooms.access_angle(objs)[source]#

Bases: ScalarExpression

Computes the angle between the vector from the root to the room and the vector from the room’s neighbour to the room

Parameters:

objs (ObjectSetExpression)

class infinigen.core.constraints.constraint_language.rooms.aspect_ratio(objs)[source]#

Bases: ScalarExpression

Computes the aspect ratio of a room contour, always >1

Parameters:

objs (ObjectSetExpression)

class infinigen.core.constraints.constraint_language.rooms.convexity(objs)[source]#

Bases: ScalarExpression

Computes the ratio of the area of bounding box of the room contour to the room

Parameters:

objs (ObjectSetExpression)

class infinigen.core.constraints.constraint_language.rooms.n_verts(objs)[source]#

Bases: ScalarExpression

Computes the number of vertices of the room contour

Parameters:

objs (ObjectSetExpression)

class infinigen.core.constraints.constraint_language.rooms.grid_line_count(objs, constants, direction=None)[source]#

Bases: ScalarExpression

Computes the number of unique x/y grid lines objs occupies

Parameters:
direction: str = None#
class infinigen.core.constraints.constraint_language.rooms.narrowness(objs, constants, thresh)[source]#

Bases: ScalarExpression

Computes the circumference difference after the room contour is eroded and buffered by thresh. Would be non-zero if the countour has a narrow end

Parameters:
class infinigen.core.constraints.constraint_language.rooms.intersection(objs, objs_)[source]#

Bases: ScalarExpression

Computes the intersection area between two sets of room contours

Parameters:
class infinigen.core.constraints.constraint_language.rooms.graph_coherent(constants)[source]#

Bases: BoolExpression

Computes if the state is coherent with the room graph in terms of adjacency

Parameters:

constants (RoomConstants)

class infinigen.core.constraints.constraint_language.rooms.same_level(objs)[source]#

Bases: ObjectSetExpression

Computes the set of room contours on the same level/floor

Parameters:

objs (ObjectSetExpression)

class infinigen.core.constraints.constraint_language.rooms.area(objs)[source]#

Bases: ScalarExpression

Computes the area of the room contour

Parameters:

objs (ObjectSetExpression)

class infinigen.core.constraints.constraint_language.rooms.shared_length(objs, objs_)[source]#

Bases: ScalarExpression

Computes the shared length between two sets of room contours

Parameters:
class infinigen.core.constraints.constraint_language.rooms.shared_n_verts(objs, objs_)[source]#

Bases: ScalarExpression

Computes the number of shared vertices of two sets of room contours

Parameters:
class infinigen.core.constraints.constraint_language.rooms.length(objs)[source]#

Bases: ScalarExpression

Computes the circumference of a room contour

Parameters:

objs (ObjectSetExpression)

class infinigen.core.constraints.constraint_language.rooms.rand(count, type, args)[source]#

Bases: ScalarExpression

Computes the NLL of an integer sample given the distribution type and arguments type can be of ‘bool’(‘bern’) / ‘categorical’(‘cat’)

Parameters:

set_reasoning#

class infinigen.core.constraints.constraint_language.set_reasoning.ObjectSetExpression[source]#

Bases: Expression

access_angle()[source]#

Computes the angle between the vector from the root to the room and the vector from the room’s neighbour to the room

Parameters:

objs (ObjectSetExpression)

all(
pred,
) BoolExpression[source]#
Parameters:
area()[source]#

Computes the area of the room contour

Parameters:

objs (ObjectSetExpression)

aspect_ratio()[source]#

Computes the aspect ratio of a room contour, always >1

Parameters:

objs (ObjectSetExpression)

convexity()[source]#

Computes the ratio of the area of bounding box of the room contour to the room

Parameters:

objs (ObjectSetExpression)

count(
objs: ObjectSetExpression,
)[source]#
Parameters:

objs (ObjectSetExpression)

distance(
objs: ObjectSetExpression,
others: ObjectSetExpression,
others_tags: set = <factory>,
)[source]#
Parameters:
excludes(tags)[source]#
Parameters:
  • objs

  • tags

grid_line_count(constants, direction=None)[source]#

Computes the number of unique x/y grid lines objs occupies

Parameters:
intersection(objs_)[source]#

Computes the intersection area between two sets of room contours

Parameters:
length()[source]#

Computes the circumference of a room contour

Parameters:

objs (ObjectSetExpression)

mean(pred)[source]#
Parameters:
n_verts()[source]#

Computes the number of vertices of the room contour

Parameters:

objs (ObjectSetExpression)

narrowness(constants, thresh)[source]#

Computes the circumference difference after the room contour is eroded and buffered by thresh. Would be non-zero if the countour has a narrow end

Parameters:
related_to(
child: ObjectSetExpression,
parent: ObjectSetExpression,
relation: Relation = <factory>,
)[source]#
Parameters:
same_level()[source]#

Computes the set of room contours on the same level/floor

Parameters:

objs (ObjectSetExpression)

shared_length(objs_)[source]#

Computes the shared length between two sets of room contours

Parameters:
shared_n_verts(objs_)[source]#

Computes the number of shared vertices of two sets of room contours

Parameters:
sum(pred)[source]#
Parameters:
tagged(
objs: ObjectSetExpression,
tags: set[Tag] = <factory>,
)[source]#
Parameters:
union(
objs: ObjectSetExpression,
tags: set[Tag] = <factory>,
)[source]#
Parameters:
volume(
objs: ObjectSetExpression,
dims: int | tuple = 3,
)[source]#
Parameters:
class infinigen.core.constraints.constraint_language.set_reasoning.scene[source]#

Bases: ObjectSetExpression

class infinigen.core.constraints.constraint_language.set_reasoning.tagged(
objs: ObjectSetExpression,
tags: set[Tag] = <factory>,
)[source]#

Bases: ObjectSetExpression

Parameters:
class infinigen.core.constraints.constraint_language.set_reasoning.union(
objs: ObjectSetExpression,
tags: set[Tag] = <factory>,
)[source]#

Bases: ObjectSetExpression

Parameters:
infinigen.core.constraints.constraint_language.set_reasoning.excludes(objs, tags)[source]#
Parameters:
  • objs

  • tags

class infinigen.core.constraints.constraint_language.set_reasoning.related_to(
child: ObjectSetExpression,
parent: ObjectSetExpression,
relation: Relation = <factory>,
)[source]#

Bases: ObjectSetExpression

Parameters:
class infinigen.core.constraints.constraint_language.set_reasoning.count(
objs: ObjectSetExpression,
)[source]#

Bases: ScalarExpression

Parameters:

objs (ObjectSetExpression)

class infinigen.core.constraints.constraint_language.set_reasoning.in_range(
val: ScalarExpression,
low: float,
high: float,
mean: float = 0,
)[source]#

Bases: BoolExpression

Parameters:
mean: float = 0#

types#

infinigen.core.constraints.constraint_language.types.nodedataclass(frozen=False)[source]#
Parameters:

frozen -- (default: False)

class infinigen.core.constraints.constraint_language.types.Node[source]#

Bases: object

children()[source]#
traverse(inorder=True)[source]#
Parameters:

inorder -- (default: True)

size()[source]#

util#

infinigen.core.constraints.constraint_language.util.bvh_caching_config(enabled=True)[source]#
Parameters:

enabled -- (default: True)

infinigen.core.constraints.constraint_language.util.group(scene, x)[source]#
Parameters:
  • scene

  • x

infinigen.core.constraints.constraint_language.util.meshes_from_names(scene, names)[source]#
Parameters:
  • scene

  • names

infinigen.core.constraints.constraint_language.util.blender_objs_from_names(names)[source]#
Parameters:

names

infinigen.core.constraints.constraint_language.util.name_from_mesh(scene, mesh)[source]#
Parameters:
  • scene

  • mesh

infinigen.core.constraints.constraint_language.util.project_to_xy_path2d(mesh) trimesh.path.path.Path2D[source]#
Parameters:

mesh (Trimesh)

infinigen.core.constraints.constraint_language.util.project_to_xy_poly(mesh)[source]#
Parameters:

mesh (Trimesh)

infinigen.core.constraints.constraint_language.util.closest_edge_to_point_poly(polygon, point)[source]#
Parameters:
  • polygon

  • point

infinigen.core.constraints.constraint_language.util.closest_edge_to_point_edge_list(edge_list, point)[source]#
Parameters:
  • edge_list (list[LineString])

  • point

infinigen.core.constraints.constraint_language.util.compute_outward_normal(line, polygon)[source]#
Parameters:
  • line

  • polygon

infinigen.core.constraints.constraint_language.util.get_transformed_axis(scene, obj_name)[source]#
Parameters:
  • scene

  • obj_name

infinigen.core.constraints.constraint_language.util.set_axis(scene, objs, canonical_axis)[source]#
Parameters:
infinigen.core.constraints.constraint_language.util.get_plane_from_3dmatrix(matrix)[source]#

Extract the plane_normal and plane_origin from a transformation matrix.

Parameters:

matrix

infinigen.core.constraints.constraint_language.util.project_points_onto_plane(points, plane_origin, plane_normal)[source]#

Project 3D points onto a plane.

Parameters:
  • points

  • plane_origin

  • plane_normal

infinigen.core.constraints.constraint_language.util.to_2d_coordinates(points, plane_normal)[source]#

Convert 3D points to 2D using the plane defined by its normal.

Parameters:
  • points

  • plane_normal

infinigen.core.constraints.constraint_language.util.ensure_correct_order(points)[source]#

Ensures the points are in counter-clockwise order. If not, it reverses them.

Parameters:

points

infinigen.core.constraints.constraint_language.util.sample_random_point(polygon)[source]#

Sample a random point from inside the given Shapely polygon.

Parameters:

polygon

infinigen.core.constraints.constraint_language.util.delete_obj(scene, a, delete_blender=True)[source]#
Parameters:
  • scene

  • a

  • delete_blender -- (default: True)

infinigen.core.constraints.constraint_language.util.is_planar(obj, tolerance=1e-06)[source]#
Parameters:
  • obj

  • tolerance -- (default: 1e-06)

infinigen.core.constraints.constraint_language.util.planes_parallel(plane_obj_a, plane_obj_b, tolerance=1e-06)[source]#
Parameters:
  • plane_obj_a

  • plane_obj_b

  • tolerance -- (default: 1e-06)

infinigen.core.constraints.constraint_language.util.distance_to_plane(point, plane_point, plane_normal)[source]#

Compute the distance from a point to a plane defined by a point and a normal.

Parameters:
  • point

  • plane_point

  • plane_normal

infinigen.core.constraints.constraint_language.util.subset(scene, incl)[source]#
Parameters:
  • scene (Scene)

  • incl

infinigen.core.constraints.constraint_language.util.add_object_cached(...)[source]#
Parameters:
  • col

  • name

  • col_obj

  • fcl_obj

infinigen.core.constraints.constraint_language.util.col_from_subset(...)[source]#
Parameters:
  • scene

  • names

  • tags -- (default: None)

  • bvh_cache -- (default: None)

infinigen.core.constraints.constraint_language.util.plot_geometry(ax, geom, color='blue')[source]#
Parameters:
  • ax

  • geom

  • color -- (default: 'blue')

infinigen.core.constraints.constraint_language.util.sync_trimesh(scene, obj_name)[source]#
Parameters:
  • scene (Scene)

  • obj_name (str)

infinigen.core.constraints.constraint_language.util.translate(scene, a, translation)[source]#
Parameters:
  • scene (Scene)

  • a (str)

  • translation

infinigen.core.constraints.constraint_language.util.rotate(...)[source]#
Parameters:
  • scene (Scene)

  • a (str)

  • axis

  • angle

infinigen.core.constraints.constraint_language.util.set_location(scene, obj_name, location)[source]#
Parameters:
  • scene (Scene)

  • obj_name (str)

  • location

infinigen.core.constraints.constraint_language.util.set_rotation(scene, obj_name, rotation)[source]#
Parameters:
  • scene (Scene)

  • obj_name (str)

  • rotation

infinigen.core.constraints.constraint_language.util.blender_centroid(a)[source]#
Parameters:

a

infinigen.core.constraints.constraint_language.util.order_objects_by_principal_axis(objects)[source]#
Parameters:

objects (list[Object])

Module contents#

Evaluator (.core.constraints.evaluator)#

Node Impl (.core.constraints.evaluator.node_impl)#

impl_bindings#

infinigen.core.constraints.evaluator.node_impl.impl_bindings.statenames_to_blnames(state, names)[source]#
Parameters:
  • state

  • names

infinigen.core.constraints.evaluator.node_impl.impl_bindings.register_node_impl(node_cls)[source]#
Parameters:

node_cls

infinigen.core.constraints.evaluator.node_impl.impl_bindings.generic_impl_interface(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.constant_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.operator_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.center_stable_surface_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.accessibility_impl(...)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.min_distance_impl(...)[source]#
Parameters:
  • cons (Node)

  • state (State)

  • child_vals (dict)

  • others_tags (set) -- (default: None)

infinigen.core.constraints.evaluator.node_impl.impl_bindings.min_distance_internal_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.min_dist_2d_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.focus_score_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.angle_alignment_impl(...)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.freespace_2d_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.rotational_asymmetry_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.reflectional_asymmetry_impl(...)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.coplanarity_cost_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.tagged_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.count_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.in_range_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.related_children_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.excludes_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (excludes)

  • state (State)

  • child_vals (dict)

infinigen.core.constraints.evaluator.node_impl.impl_bindings.volume_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.hinge_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.union_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.impl_bindings.filter_by_domain_impl(cons, state, child_vals) set[str][source]#
Parameters:

rooms#

infinigen.core.constraints.evaluator.node_impl.rooms.separate_floors(state)[source]#
Parameters:

state

infinigen.core.constraints.evaluator.node_impl.rooms.abs_distance(x, y)[source]#
Parameters:
  • x

  • y

infinigen.core.constraints.evaluator.node_impl.rooms.reduce(x, reduce_fn)[source]#
Parameters:
  • x

  • reduce_fn

infinigen.core.constraints.evaluator.node_impl.rooms.access_angle_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.rooms.aspect_ratio_impl(cons, state, child_vals)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.rooms.convexity_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (convexity)

  • state (<module 'infinigen.core.constraints.example_solver.state_def' from '/n/fs/pvl-renders/ar8564/docs_deploy_v2.0.0a1/src/infinigen/core/constraints/example_solver/state_def.py'>)

  • child_vals (dict)

infinigen.core.constraints.evaluator.node_impl.rooms.area_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (area)

  • state (<module 'infinigen.core.constraints.example_solver.state_def' from '/n/fs/pvl-renders/ar8564/docs_deploy_v2.0.0a1/src/infinigen/core/constraints/example_solver/state_def.py'>)

  • child_vals (dict)

infinigen.core.constraints.evaluator.node_impl.rooms.n_verts_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (n_verts)

  • state (<module 'infinigen.core.constraints.example_solver.state_def' from '/n/fs/pvl-renders/ar8564/docs_deploy_v2.0.0a1/src/infinigen/core/constraints/example_solver/state_def.py'>)

  • child_vals (dict)

infinigen.core.constraints.evaluator.node_impl.rooms.shared_length_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (shared_length)

  • state (<module 'infinigen.core.constraints.example_solver.state_def' from '/n/fs/pvl-renders/ar8564/docs_deploy_v2.0.0a1/src/infinigen/core/constraints/example_solver/state_def.py'>)

  • child_vals (dict)

infinigen.core.constraints.evaluator.node_impl.rooms.shared_n_verts_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (shared_length)

  • state (<module 'infinigen.core.constraints.example_solver.state_def' from '/n/fs/pvl-renders/ar8564/docs_deploy_v2.0.0a1/src/infinigen/core/constraints/example_solver/state_def.py'>)

  • child_vals (dict)

infinigen.core.constraints.evaluator.node_impl.rooms.grid_line_count_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (grid_line_count)

  • state (<module 'infinigen.core.constraints.example_solver.state_def' from '/n/fs/pvl-renders/ar8564/docs_deploy_v2.0.0a1/src/infinigen/core/constraints/example_solver/state_def.py'>)

  • child_vals (dict)

infinigen.core.constraints.evaluator.node_impl.rooms.narrowness_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (narrowness)

  • state (<module 'infinigen.core.constraints.example_solver.state_def' from '/n/fs/pvl-renders/ar8564/docs_deploy_v2.0.0a1/src/infinigen/core/constraints/example_solver/state_def.py'>)

  • child_vals (dict)

infinigen.core.constraints.evaluator.node_impl.rooms.intersection_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (intersection)

  • state (<module 'infinigen.core.constraints.example_solver.state_def' from '/n/fs/pvl-renders/ar8564/docs_deploy_v2.0.0a1/src/infinigen/core/constraints/example_solver/state_def.py'>)

  • child_vals (dict)

infinigen.core.constraints.evaluator.node_impl.rooms.graph_coherent_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (graph_coherent)

  • state (<module 'infinigen.core.constraints.example_solver.state_def' from '/n/fs/pvl-renders/ar8564/docs_deploy_v2.0.0a1/src/infinigen/core/constraints/example_solver/state_def.py'>)

  • child_vals (dict)

infinigen.core.constraints.evaluator.node_impl.rooms.same_level_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (same_level)

  • state (<module 'infinigen.core.constraints.example_solver.state_def' from '/n/fs/pvl-renders/ar8564/docs_deploy_v2.0.0a1/src/infinigen/core/constraints/example_solver/state_def.py'>)

  • child_vals (dict)

infinigen.core.constraints.evaluator.node_impl.rooms.length_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (same_level)

  • state (<module 'infinigen.core.constraints.example_solver.state_def' from '/n/fs/pvl-renders/ar8564/docs_deploy_v2.0.0a1/src/infinigen/core/constraints/example_solver/state_def.py'>)

  • child_vals (dict)

infinigen.core.constraints.evaluator.node_impl.rooms.rand_impl(cons, state, child_vals)[source]#
Parameters:
  • cons (rand)

  • state (<module 'infinigen.core.constraints.example_solver.state_def' from '/n/fs/pvl-renders/ar8564/docs_deploy_v2.0.0a1/src/infinigen/core/constraints/example_solver/state_def.py'>)

  • child_vals (dict)

symmetry#

infinigen.core.constraints.evaluator.node_impl.symmetry.rotate_vector(vector, angle)[source]#

Rotate a 2D vector by a given angle.

Parameters:
  • vector

  • angle

infinigen.core.constraints.evaluator.node_impl.symmetry.compute_centroid(objects)[source]#

Compute the centroid of the provided objects.

Parameters:

objects

infinigen.core.constraints.evaluator.node_impl.symmetry.compute_location_asymmetry(objects, centroid)[source]#

Compute location asymmetry based on the described method.

Parameters:
  • objects

  • centroid

infinigen.core.constraints.evaluator.node_impl.symmetry.compute_orientation_asymmetry(objects, centroid)[source]#

Compute orientation asymmetry of objects.

Parameters:
  • objects

  • centroid

infinigen.core.constraints.evaluator.node_impl.symmetry.sort_objects_clockwise(objects, centroid)[source]#
Parameters:
  • objects

  • centroid

infinigen.core.constraints.evaluator.node_impl.symmetry.compute_total_rotation_asymmetry(a) float[source]#

Compute the total asymmetry.

Parameters:

a (str | list[str])

infinigen.core.constraints.evaluator.node_impl.symmetry.reflect_point(point, plane_point, plane_normal)[source]#
Parameters:
  • point

  • plane_point

  • plane_normal

infinigen.core.constraints.evaluator.node_impl.symmetry.reflect_quaternion(q, n)[source]#
Parameters:
  • q

  • n

infinigen.core.constraints.evaluator.node_impl.symmetry.reflect_axis_angle(axis_angle, n)[source]#
Parameters:
  • axis_angle

  • n

infinigen.core.constraints.evaluator.node_impl.symmetry.reflect(obj, plane_point, plane_normal)[source]#
Parameters:
  • obj

  • plane_point

  • plane_normal

infinigen.core.constraints.evaluator.node_impl.symmetry.distance(pos1, pos2)[source]#
Parameters:
  • pos1

  • pos2

infinigen.core.constraints.evaluator.node_impl.symmetry.angle_difference(orient1, orient2)[source]#
Parameters:
  • orient1

  • orient2

infinigen.core.constraints.evaluator.node_impl.symmetry.weight(obj)[source]#
Parameters:

obj

infinigen.core.constraints.evaluator.node_impl.symmetry.normalization_factor(objs)[source]#
Parameters:

objs

infinigen.core.constraints.evaluator.node_impl.symmetry.bipartite_matching(objs, reflected_objs_data)[source]#
Parameters:
  • objs

  • reflected_objs_data

infinigen.core.constraints.evaluator.node_impl.symmetry.calculate_reflectional_asymmetry(...)[source]#
Parameters:
  • objs

  • plane_point

  • plane_normal

  • visualize -- (default: False)

trimesh_geometry#

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.get_cardinal_planes_bbox(vertices)[source]#

Get the mid dividing planes. Assumes vertices form a box

Parameters:

vertices (ndarray)

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.get_axis(state, obj, tag=Subpart.Front)[source]#
Parameters:
  • state (State)

  • obj (Object)

  • tag -- (default: Subpart.Front)

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.preprocess_collision_query_cases(...)[source]#
Parameters:
  • a

  • b

  • a_tags

  • b_tags

class infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.ContactResult(hit: 'bool', names: 'list[str]', contacts: 'list')[source]#

Bases: object

Parameters:
infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.any_touching(...)[source]#

Computes one-to-one, many-to-one, one-to-many or many-to-many collisions

In all cases, returns True if any one object from a and b touch

Parameters:
  • scene (Scene)

  • a (str | list[str])

  • b (str | list[str]) -- (default: None)

  • a_tags -- (default: None)

  • b_tags -- (default: None)

  • bvh_cache -- (default: None)

class infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.DistanceResult(
dist: 'float',
names: 'list[str]',
data: 'trimesh.collision.DistanceData',
)[source]#

Bases: object

Parameters:
infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.min_dist(...)[source]#

Computes one-to-one, many-to-one, one-to-many or many-to-many distance

In all cases, returns the minimum distance between any object in a and b

Parameters:
  • scene (Scene)

  • a (str | list[str] | None)

  • b (str | list[str] | None) -- (default: None)

  • a_tags (set) -- (default: None)

  • b_tags (set) -- (default: None)

  • bvh_cache (dict) -- (default: None)

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.contains(...) bool[source]#

Check if a contains b

Parameters:
  • scene (Scene)

  • a (str)

  • b (str)

  • tol -- (default: 1e-06)

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.contains_all(scene, a, b) bool[source]#

Check if all objects in list ‘a’ contain all objects in list ‘b’ within the given scene.

Parameters: - scene: The trimesh.Scene instance. - a: Name or list of names of objects to check for containment. - b: Name or list of names of objects that might be contained.

Returns: - True if all objects in list ‘a’ contain all objects in list ‘b’, False otherwise.

Parameters:
infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.contains_any(scene, a, b) bool[source]#

Check if any object in list ‘a’ contains any object in list ‘b’ within the given scene.

Parameters: - scene: The trimesh.Scene instance. - a: Name or list of names of objects to check for containment. - b: Name or list of names of objects that might be contained.

Returns: - True if any object in list ‘a’ contains any object in list ‘b’, False otherwise.

Parameters:
infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.has_line_of_sight(...) bool[source]#

Check if any object in list ‘a’ in the scene has a line of sight to any object in list ‘b’.

Parameters: - scene: The trimesh.Scene instance. - a: Name or list of names of objects from which line of sight is checked. - b: Name or list of names of objects to which line of sight is checked. - num_samples: Number of points to sample from each object for ray casting.

Returns: - True if any object in list ‘a’ has a line of sight to any object in list ‘b’, False otherwise.

Parameters:
infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.freespace_2d(scene, a, b) float[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.rasterize_space_with_obstacles(...)[source]#

Rasterize the union of multiple space polygons while considering obstacle polygons, then find and visualize the shortest path from start to end.

Parameters: - space_polygons: list of shapely.geometry.polygon.Polygon objects representing the main spaces - obstacle_polygons: list of shapely.geometry.polygon.Polygon objects representing obstacles - start_location: tuple (x, y) representing the start location - end_location: tuple (x, y) representing the end location - cell_size: size of each cell in the grid - visualize: boolean, if True, visualize the union of spaces, obstacles, and the shortest path

Returns: - graph: A networkx.Graph object representing the rasterized union of spaces minus the obstacles - path: list of nodes representing the shortest path from start to end

Parameters:
  • scene

  • a (str | list[str])

  • b (str | list[str])

  • start_location

  • end_location

  • cell_size -- (default: 1.0)

  • visualize -- (default: False)

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.angle_alignment_cost_tagged(...)[source]#

Return the dot product between the axes of a and the normal of the closest edge of b

Parameters:
infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.angle_alignment_cost_base(...)[source]#

Return the dot product between the axes of a and the normal of the closest edge of b

Parameters:
infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.angle_alignment_cost(...)[source]#
Parameters:
infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.focus_score(...)[source]#

The how much objects in a focus on b

Parameters:
infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.edge(scene, surface_name)[source]#
Parameters:
  • scene

  • surface_name (str)

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.min_dist_2d(...)[source]#

projects onto b and finds the min distance between a and b

Parameters:
  • scene

  • a (str | list[str])

  • b

  • visualize -- (default: False)

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.min_dist_boundary(scene, a, boundary)[source]#
Parameters:
exception infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.ConstraintViolated[source]#

Bases: Exception

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.constraint_violated(message)[source]#
Parameters:

message

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.constrain_contact(res, should_touch=True, max_depth=0.01)[source]#
Parameters:
  • res (ContactResult)

  • should_touch -- (default: True)

  • max_depth -- (default: 0.01)

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.constrain_dist(res, min=None, max=None)[source]#
Parameters:
  • res (dict)

  • min -- (default: None)

  • max -- (default: None)

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.constrain_dist_soft(res, min=None, max=None)[source]#
Parameters:
  • res (dict)

  • min -- (default: None)

  • max -- (default: None)

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.touching_soft(scene, a, b)[source]#
Parameters:
  • scene

  • a

  • b

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.dist_soft_score(res, min, max)[source]#
Parameters:
  • res (dict)

  • min

  • max

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.accessibility_cost_cuboid_penetration(...)[source]#

Extrude the bbox of a by dist in the direction of normal_dir, and check for collisions with b Return the maximum distance that any part of b penetrates this extrusion

Parameters:
infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.accessibility_cost(...)[source]#

Computes how much objs b block front access to a. b obj blockages are not summed. the closest b obj to a is taken as the representative blockage

Parameters:
  • scene

  • a

  • b

  • normal

  • visualize -- (default: False)

  • fast -- (default: True)

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.center_stable_surface(scene, a, state)[source]#

center a objects on their assigned surfaces.

Parameters:
  • scene

  • a

  • state

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.reflectional_asymmetry_score(...)[source]#

Computes the reflectional asymmetry score between a and b

Parameters:
  • scene

  • a (str | list[str])

  • b (str)

  • use_long_plane -- (default: True)

infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.coplanarity_cost_pair(scene, a, b)[source]#

Computes the coplanarity cost between a and b

Parameters:
infinigen.core.constraints.evaluator.node_impl.trimesh_geometry.coplanarity_cost(scene, a)[source]#

Computes the coplanarity cost between a and b

Parameters:

Module contents#

domain_contains#

infinigen.core.constraints.evaluator.domain_contains.domain_contains(dom, state, obj)[source]#
Parameters:
infinigen.core.constraints.evaluator.domain_contains.objkeys_in_dom(dom, curr)[source]#
Parameters:

eval_memo#

infinigen.core.constraints.evaluator.eval_memo.memo_key(n)[source]#
Parameters:

n (Node)

infinigen.core.constraints.evaluator.eval_memo.evict_memo_for_obj(node, memo, obj)[source]#
Parameters:
infinigen.core.constraints.evaluator.eval_memo.reset_bvh_cache(state, filter_name=None)[source]#

filter_name: if specified, only get rid of things containing this

Parameters:
  • state

  • filter_name -- (default: None)

infinigen.core.constraints.evaluator.eval_memo.evict_memo_for_move(...)[source]#
Parameters:

evaluate#

infinigen.core.constraints.evaluator.evaluate.relevant(node, filter) bool[source]#
Parameters:
infinigen.core.constraints.evaluator.evaluate.viol_count(...)[source]#
Parameters:
class infinigen.core.constraints.evaluator.evaluate.ConstraintsViolated(
constraints: list[Node],
)[source]#

Bases: object

Parameters:

constraints (list[Node])

infinigen.core.constraints.evaluator.evaluate.evaluate_node(node, state, memo=None)[source]#
Parameters:
  • node (Node)

  • state (State)

  • memo -- (default: None)

class infinigen.core.constraints.evaluator.evaluate.EvalResult(loss_vals: dict[str, float], violations: dict[str, bool])[source]#

Bases: object

Parameters:
loss()[source]#
viol_count()[source]#
to_df() pandas.DataFrame[source]#
infinigen.core.constraints.evaluator.evaluate.evaluate_problem(...)[source]#
Parameters:
  • problem (Problem)

  • state (State)

  • filter (Domain) -- (default: None)

  • memo -- (default: None)

  • enable_loss -- (default: True)

  • enable_violated -- (default: True)

indoor_util#

infinigen.core.constraints.evaluator.indoor_util.meshes_from_names(scene, names)[source]#
Parameters:
  • scene

  • names

infinigen.core.constraints.evaluator.indoor_util.blender_objs_from_names(names)[source]#
Parameters:

names

infinigen.core.constraints.evaluator.indoor_util.name_from_mesh(scene, mesh)[source]#
Parameters:
  • scene

  • mesh

infinigen.core.constraints.evaluator.indoor_util.project_to_xy_path2d(mesh) trimesh.path.path.Path2D[source]#
Parameters:

mesh (Trimesh)

infinigen.core.constraints.evaluator.indoor_util.project_to_xy_poly(mesh)[source]#
Parameters:

mesh (Trimesh)

infinigen.core.constraints.evaluator.indoor_util.closest_edge_to_point(polygon, point)[source]#
Parameters:
  • polygon

  • point

infinigen.core.constraints.evaluator.indoor_util.compute_outward_normal(line, polygon)[source]#
Parameters:
  • line

  • polygon

infinigen.core.constraints.evaluator.indoor_util.get_transformed_axis(scene, obj_name)[source]#
Parameters:
  • scene

  • obj_name

infinigen.core.constraints.evaluator.indoor_util.set_axis(scene, objs, canonical_axis)[source]#
Parameters:
infinigen.core.constraints.evaluator.indoor_util.get_plane_from_3dmatrix(matrix)[source]#

Extract the plane_normal and plane_origin from a transformation matrix.

Parameters:

matrix

infinigen.core.constraints.evaluator.indoor_util.project_points_onto_plane(points, plane_origin, plane_normal)[source]#

Project 3D points onto a plane.

Parameters:
  • points

  • plane_origin

  • plane_normal

infinigen.core.constraints.evaluator.indoor_util.to_2d_coordinates(points, plane_normal)[source]#

Convert 3D points to 2D using the plane defined by its normal.

Parameters:
  • points

  • plane_normal

infinigen.core.constraints.evaluator.indoor_util.ensure_correct_order(points)[source]#

Ensures the points are in counter-clockwise order. If not, it reverses them.

Parameters:

points

infinigen.core.constraints.evaluator.indoor_util.sample_random_point(polygon)[source]#

Sample a random point from inside the given Shapely polygon.

Parameters:

polygon

infinigen.core.constraints.evaluator.indoor_util.delete_obj(a, scene=None)[source]#
Parameters:
  • a

  • scene -- (default: None)

infinigen.core.constraints.evaluator.indoor_util.is_planar(obj, tolerance=1e-06)[source]#
Parameters:
  • obj

  • tolerance -- (default: 1e-06)

infinigen.core.constraints.evaluator.indoor_util.planes_parallel(plane_obj_a, plane_obj_b, tolerance=1e-06)[source]#
Parameters:
  • plane_obj_a

  • plane_obj_b

  • tolerance -- (default: 1e-06)

infinigen.core.constraints.evaluator.indoor_util.distance_to_plane(point, plane_point, plane_normal)[source]#

Compute the distance from a point to a plane defined by a point and a normal.

Parameters:
  • point

  • plane_point

  • plane_normal

infinigen.core.constraints.evaluator.indoor_util.is_within_margin_from_plane(...)[source]#

Check if all vertices of an object are within a given margin from a plane.

Parameters:
  • obj

  • obj_b

  • margin

  • tol -- (default: 1e-06)

Module contents#

Example Solver (.core.constraints.example_solver)#

Geometry (.core.constraints.example_solver.geometry)#

dof#

infinigen.core.constraints.example_solver.geometry.dof.stable_against_matrix(point, normal)[source]#

Given a point and normal defining a plane, return a 3x3 matrix that restricts movement perpendicular to the plane.

Parameters:
  • point

  • normal

infinigen.core.constraints.example_solver.geometry.dof.combined_stability_matrix(parent_planes)[source]#

Given a list of relations (each a tuple of point and normal), compute the combined 3x3 matrix M.

Parameters:

parent_planes

infinigen.core.constraints.example_solver.geometry.dof.rotation_constraint(normal)[source]#

Given a normal defining a plane, return the axis of rotation allowed by this constraint.

Parameters:

normal

infinigen.core.constraints.example_solver.geometry.dof.combine_rotation_constraints(parent_planes, eps=0.01)[source]#

Given a list of normals, compute the combined axis of rotation. If there are conflicting constraints, return None.

Parameters:
  • parent_planes

  • eps -- (default: 0.01)

infinigen.core.constraints.example_solver.geometry.dof.rotate_object_around_axis(...)[source]#

Rotate an object around a given axis.

Parameters:
  • obj

  • axis

  • std

  • angle -- (default: None)

infinigen.core.constraints.example_solver.geometry.dof.check_init_valid(...)[source]#

Check that the plane assignments to the object is valid. First checks that the rotations can be satisfied, then checks that the translations can be satisfied. Returns a boolean indicating if the assignments are valid, the number of degrees of freedom remaining, and the translation vector if the assignments are valid.

Parameters:
infinigen.core.constraints.example_solver.geometry.dof.project(points, plane_normal)[source]#
Parameters:
  • points

  • plane_normal

infinigen.core.constraints.example_solver.geometry.dof.apply_relations_surfacesample(state, name)[source]#

Apply the relation constraints to the object. Place it in the scene according to the constraints.

Parameters:
infinigen.core.constraints.example_solver.geometry.dof.validate_relations_feasible(state, name) bool[source]#
Parameters:
infinigen.core.constraints.example_solver.geometry.dof.try_apply_relation_constraints(...)[source]#

name is in objs.name name has been recently reassigned or added or swapped it needs snapping, and dof updates

Result: dof_mat and dof axis for name are updated objstate for name has update location rotaton etc

Parameters:
  • state (State)

  • name (str)

  • n_try_resolve -- (default: 10)

  • visualize -- (default: False)

parse_scene#

infinigen.core.constraints.example_solver.geometry.parse_scene.to_trimesh(obj)[source]#
Parameters:

obj (Object)

infinigen.core.constraints.example_solver.geometry.parse_scene.preprocess_obj(obj)[source]#
Parameters:

obj

infinigen.core.constraints.example_solver.geometry.parse_scene.preprocess_scene(objects)[source]#
Parameters:

objects

infinigen.core.constraints.example_solver.geometry.parse_scene.parse_scene(objects)[source]#
Parameters:

objects

infinigen.core.constraints.example_solver.geometry.parse_scene.add_to_scene(scene, obj, preprocess=True)[source]#
Parameters:
  • scene

  • obj

  • preprocess -- (default: True)

planes#

class infinigen.core.constraints.example_solver.geometry.planes.Planes[source]#

Bases: object

calculate_mesh_hash(obj)[source]#
Parameters:

obj

hash_face_mask(face_mask)[source]#
Parameters:

face_mask

get_all_planes_cached(obj, face_mask, tolerance=0.0001)[source]#
Parameters:
  • obj

  • face_mask

  • tolerance -- (default: 0.0001)

static normalize(v)[source]#
Parameters:

v

static hash_plane(normal, point, tolerance=0.0001)[source]#
Parameters:
  • normal

  • point

  • tolerance -- (default: 0.0001)

compute_all_planes_fast(obj, face_mask, tolerance=0.0001)[source]#
Parameters:
  • obj

  • face_mask

  • tolerance -- (default: 0.0001)

get_all_planes_deprecated(obj, face_mask, tolerance=0.0001) tuple[str, int][source]#

get all unique planes formed by faces in face_mask

Parameters:
  • obj

  • face_mask

  • tolerance -- (default: 0.0001)

get_tagged_planes(obj, tags, fast=True)[source]#

get all unique planes formed by faces tagged with tags

Parameters:
  • obj (Object)

  • tags (set)

  • fast -- (default: True)

get_rel_state_planes(state, name, relation_state)[source]#
Parameters:
  • state

  • name (str)

  • relation_state (tuple)

static planerep_to_poly(planerep)[source]#
Parameters:

planerep

extract_tagged_plane(obj, tags, plane)[source]#

get a single plane formed by faces tagged with tags

Parameters:
  • obj (Object)

  • tags (set)

  • plane (int)

get_tagged_submesh(...)[source]#
Parameters:
  • scene (Scene)

  • name (str)

  • tags (set)

  • plane (int)

tagged_plane_mask(...) np.ndarray[source]#
Parameters:
  • obj (Object)

  • face_mask (ndarray)

  • plane (tuple[str, int])

  • hash_tolerance -- (default: 0.0001)

  • plane_tolerance -- (default: 0.01)

  • fast -- (default: True)

stability#

infinigen.core.constraints.example_solver.geometry.stability.project_and_align_z_with_x(polygons, z_direction)[source]#

Rotate polygons so that the Z-direction is aligned with the X-axis in 2D.

Parameters: polygons (list[Polygon]): List of Shapely Polygons representing the projected 2D polygons. z_direction (np.array): The 2D direction vector where the Z-axis is projected.

Returns: list[Polygon]: Rotated polygons with the Z-direction aligned with the X-axis.

Parameters:
  • polygons

  • z_direction

infinigen.core.constraints.example_solver.geometry.stability.is_vertically_contained(poly_a, poly_b)[source]#

Check if polygon A is vertically contained within polygon B, ignoring X-axis spillover.

Parameters: poly_a (Polygon): Polygon A. poly_b (Polygon): Polygon B.

Returns: bool: True if A is vertically contained within B.

Parameters:
  • poly_a

  • poly_b

infinigen.core.constraints.example_solver.geometry.stability.project_vector(vector, origin, normal)[source]#
Parameters:
  • vector

  • origin

  • normal

infinigen.core.constraints.example_solver.geometry.stability.stable_against(...)[source]#

check paralell, close to, and not overhanging.

Parameters:
  • state (State)

  • obj_name (str)

  • relation_state (RelationState)

  • visualize -- (default: False)

  • allow_overhangs -- (default: False)

infinigen.core.constraints.example_solver.geometry.stability.coplanar(state, obj_name, relation_state)[source]#

check that the object’s tagged surface is coplanar with the target object’s tagged surface translated with margin.

Parameters:
infinigen.core.constraints.example_solver.geometry.stability.snap_against(...)[source]#

snap a against b with some margin.

Parameters:
  • scene

  • a

  • b

  • a_plane

  • b_plane

  • margin -- (default: 0)

  • rev_normal -- (default: False)

infinigen.core.constraints.example_solver.geometry.stability.random_sample_point(...) pf.Vector[source]#

Given a plane, return a random point on the plane.

Parameters:
infinigen.core.constraints.example_solver.geometry.stability.move_obj_random_pt(...)[source]#

move a to a random point on b

Parameters:
infinigen.core.constraints.example_solver.geometry.stability.supported_by(...)[source]#
Parameters:
  • scene

  • a

  • b

  • visualize -- (default: False)

validity#

infinigen.core.constraints.example_solver.geometry.validity.check_pre_move_validity(...)[source]#
Parameters:
  • scene

  • a

  • parent_dict

  • dx

  • dy

infinigen.core.constraints.example_solver.geometry.validity.all_relations_valid(state, name)[source]#
Parameters:
  • state

  • name

infinigen.core.constraints.example_solver.geometry.validity.check_post_move_validity(...)[source]#
Parameters:
  • state (State)

  • name (str)

  • disable_collision_checking -- (default: False)

  • visualize -- (default: False)

Greedy (.core.constraints.example_solver.greedy)#

active_for_stage#

infinigen.core.constraints.example_solver.greedy.active_for_stage.find_ancestors_of_type(...) set[str][source]#

Find objkeys of all ancestors of objkey which match filter_type

Object A is a parent of objkey if there exists a sequence of objects A, B, C, …, objkey where A is in B’s relations, B is in C’s relations, etc, AND only A matches the filter

Returns:

parents -- objkeys of objects of the given type which are parents in the relation graph

Return type:

set(str)

Parameters:
infinigen.core.constraints.example_solver.greedy.active_for_stage.set_active(state, objkey, active)[source]#
Parameters:
  • state

  • objkey

  • active

infinigen.core.constraints.example_solver.greedy.active_for_stage.update_active_flags(state, var_assignments)[source]#
Parameters:

all_substitutions#

infinigen.core.constraints.example_solver.greedy.all_substitutions.substitutions(...) Iterator[r.Domain][source]#

Find all t.Variable in d’s tags or relations, and return one Domain for each possible assignment

limits cuts off enumeration of each varname with some integer count

Parameters:
infinigen.core.constraints.example_solver.greedy.all_substitutions.iterate_assignments(...) Iterator[dict[Variable, str]][source]#

Find all combinations of assignments for the listed vars.

Variables will be considered IN ORDER, IE first variable can affect options for second variable, but not the other way around.

Parameters:
  • dom (r.Domain) -- The domain to substitute variables in

  • state (State) -- The state to substitute variables in

  • vars (list[str]) -- The names of the variables to substitute

  • limits (dict[str, int]) -- Consider only the first N objects for each variable

  • nonempty (bool) -- Raise an error if no substitutions are found

Returns:

Iterator over dicts of variable assignments to domains

Return type:

Iterator[dict[str, r.Domain]]

constraint_partition#

infinigen.core.constraints.example_solver.greedy.constraint_partition.filter_constraints(
...,
) tuple[Node, bool][source]#

Return a constraint graph representing the component of node that is relevant for to a particular greedy filter domain.

Parameters:
  • node (cl.Node) -- The constraint program to partition

  • filter_dom (Domain) -- The domain which determines whether a constraint is relevant

  • var_assignments (Domain) -- Domains to substitute for any t.Variable(name: str) in the constraint program, typically used for recursive calls.

  • check_correctness -- (default: True)

Returns:

  • partitioned (cl.Node) -- The partitioned constraint program

  • relevant (bool) -- Was any part of the constraint program relevant?

Module contents#

Moves (.core.constraints.example_solver.moves)#

addition#

infinigen.core.constraints.example_solver.moves.addition.sample_rand_placeholder(gen_class)[source]#
Parameters:

gen_class (type[AssetFactory])

class infinigen.core.constraints.example_solver.moves.addition.Addition(names, gen_class, relation_assignments, temp_force_tags, _new_obj=None)[source]#

Bases: Move

Move which generates an object and adds it to the scene with certain relations

Parameters:
  • names (List[str])

  • gen_class (Any)

  • relation_assignments (list)

  • temp_force_tags (set)

  • _new_obj (Object)

apply(state)[source]#
Parameters:

state (State)

revert(state)[source]#
Parameters:

state (State)

class infinigen.core.constraints.example_solver.moves.addition.Resample(names, align_corner=None)[source]#

Bases: Move

Move which replaces an existing object with a new one from the same generator

Parameters:
align_corner: int = None#
apply(state)[source]#
Parameters:

state (State)

revert(state)[source]#
Parameters:

state (State)

accept(state)[source]#
Parameters:

state (State)

deletion#

class infinigen.core.constraints.example_solver.moves.deletion.Deletion(
names: List[str],
_backup_state: ObjectState = None,
)[source]#

Bases: Move

Parameters:
apply(state)[source]#
Parameters:

state

accept(state)[source]#
Parameters:

state

revert(state)[source]#
Parameters:

state

moves#

class infinigen.core.constraints.example_solver.moves.moves.Move(names: List[str])[source]#

Bases: object

Parameters:

names (List[str])

apply(state)[source]#
Parameters:

state (State)

revert(state)[source]#
Parameters:

state (State)

accept(state)[source]#
Parameters:

state (State)

pose#

class infinigen.core.constraints.example_solver.moves.pose.TranslateMove(names: List[str], translation: <built-in function array>, _backup_pose: dict = None)[source]#

Bases: Move

Parameters:
  • names (List[str])

  • translation (array)

  • _backup_pose (dict)

apply(state)[source]#
Parameters:

state (State)

revert(state)[source]#
Parameters:

state (State)

class infinigen.core.constraints.example_solver.moves.pose.RotateMove(names: List[str], axis: <built-in function array>, angle: float)[source]#

Bases: Move

Parameters:
apply(state)[source]#
Parameters:

state (State)

revert(state)[source]#
Parameters:

state (State)

class infinigen.core.constraints.example_solver.moves.pose.ReinitPoseMove(names: List[str], _backup_pose: dict = None)[source]#

Bases: Move

Parameters:
apply(state)[source]#
Parameters:

state (State)

revert(state)[source]#
Parameters:

state (State)

reassignment#

infinigen.core.constraints.example_solver.moves.reassignment.pose_backup(os, dof=True)[source]#
Parameters:
infinigen.core.constraints.example_solver.moves.reassignment.restore_pose_backup(state, name, bak)[source]#
Parameters:
  • state

  • name

  • bak

class infinigen.core.constraints.example_solver.moves.reassignment.RelationPlaneChange(names: List[str], relation_idx: int, plane_idx: int)[source]#

Bases: Move

Parameters:
apply(state)[source]#
Parameters:

state (State)

revert(state)[source]#
Parameters:

state (State)

class infinigen.core.constraints.example_solver.moves.reassignment.RelationTargetChange(names: List[str], name: str, relation_idx: int, new_target: str)[source]#

Bases: Move

Parameters:
apply(state)[source]#
Parameters:

state (State)

revert(state)[source]#
Parameters:

state (State)

swap#

class infinigen.core.constraints.example_solver.moves.swap.Swap(names: List[str])[source]#

Bases: Move

Parameters:

names (List[str])

apply(state)[source]#
Parameters:

state (State)

revert(state)[source]#
Parameters:

state (State)

Module contents#

Room (.core.constraints.example_solver.room)#

base#

class infinigen.core.constraints.example_solver.room.base.RoomGraph(children, names, entrance=None)[source]#

Bases: object

Parameters:

children (List[List[int]])

property is_planar#
property to_nx#
property cycle_basis#
property neighbours#
property valid_neighbours#
property valid_ns#
property entrance#
property root#
draw()[source]#
infinigen.core.constraints.example_solver.room.base.room_type(name)[source]#
Parameters:

name

infinigen.core.constraints.example_solver.room.base.room_level(name)[source]#
Parameters:

name

infinigen.core.constraints.example_solver.room.base.room_name(t, level, n=0)[source]#
Parameters:
  • t

  • level

  • n -- (default: 0)

infinigen.core.constraints.example_solver.room.base.valid_rooms(state)[source]#
Parameters:

state

contour#

class infinigen.core.constraints.example_solver.room.contour.ContourFactory(consgraph)[source]#

Bases: object

add_staircase(contour)[source]#
Parameters:

contour

static get_length(polygon, point)[source]#
Parameters:
  • polygon

  • point

decorate(state)[source]#
Parameters:

state

decorate#

infinigen.core.constraints.example_solver.room.decorate.split_rooms(rooms_meshed)[source]#
Parameters:

rooms_meshed (list[Object])

infinigen.core.constraints.example_solver.room.decorate.import_material(factory_name)[source]#
Parameters:

factory_name

infinigen.core.constraints.example_solver.room.decorate.room_walls(walls, constants, n_walls=3)[source]#
Parameters:
infinigen.core.constraints.example_solver.room.decorate.room_ceilings(ceilings)[source]#
Parameters:

ceilings

infinigen.core.constraints.example_solver.room.decorate.room_floors(floors, n_floors=3)[source]#
Parameters:
  • floors

  • n_floors -- (default: 3)

infinigen.core.constraints.example_solver.room.decorate.populate_doors(...)[source]#
Parameters:
  • placeholders (list[Object])

  • constants (RoomConstants)

  • n_doors -- (default: 3)

  • door_chance -- (default: 1)

  • casing_chance -- (default: 0.0)

  • all_open -- (default: False)

infinigen.core.constraints.example_solver.room.decorate.populate_windows(...)[source]#
Parameters:
  • placeholders (list[Object])

  • constants

  • state (State)

  • n_windows -- (default: 2)

infinigen.core.constraints.example_solver.room.decorate.room_stairs(constants, state, rooms_meshed)[source]#
Parameters:
  • constants

  • state

  • rooms_meshed

infinigen.core.constraints.example_solver.room.decorate.room_pillars(walls, constants)[source]#
Parameters:

floor_plan#

class infinigen.core.constraints.example_solver.room.floor_plan.FloorPlanSolver(
factory_seed,
consgraph,
floor_plan='',
n_divide_trials=100,
iters_mult=200,
**kwargs,
)[source]#

Bases: object

build_graphs()[source]#
solve()[source]#
simulated_anneal(state)[source]#
Parameters:

state

graph#

class infinigen.core.constraints.example_solver.room.graph.GraphMaker(factory_seed, consgraph, level)[source]#

Bases: object

property semantics_floor#
inject(node, on=False)[source]#
Parameters:
  • node

  • on -- (default: False)

make_graph(i)[source]#
Parameters:

i

state2graph(state)[source]#
Parameters:

state

merge_exterior(state)[source]#
Parameters:

state

merge_entrance(state)[source]#
Parameters:

state

suggest_dimensions(graph, width=None, height=None)[source]#
Parameters:
  • graph

  • width -- (default: None)

  • height -- (default: None)

draw(state)[source]#
Parameters:

state

get_typical_areas(consgraph)[source]#
Parameters:

consgraph

predefined#

class infinigen.core.constraints.example_solver.room.predefined.PredefinedBlueprintSolidifier(consgraph, config, level)[source]#

Bases: BlueprintSolidifier

make_interior_cutters(...)[source]#
Parameters:
  • neighbours

  • shared_edges

  • segments

  • exterior

make_exterior_cutters(exterior_edges, exterior_shape)[source]#
Parameters:
  • exterior_edges

  • exterior_shape

class infinigen.core.constraints.example_solver.room.predefined.PredefinedFloorPlanSolver(factory_seed, consgraph, floor_plan='', **kwargs)[source]#

Bases: object

solve()[source]#

segment#

class infinigen.core.constraints.example_solver.room.segment.SegmentMaker(factory_seed, constants, consgraph, contour, graph, level)[source]#

Bases: object

Parameters:
build_segments(placeholder=None)[source]#
Parameters:

placeholder -- (default: None)

divide_segments()[source]#
merge_segment(...)[source]#
Parameters:
  • segments

  • shared_edges

  • attached

  • i

  • j

filter_segments()[source]#
plot(segments)[source]#
Parameters:

segments

solidifier#

infinigen.core.constraints.example_solver.room.solidifier.split_mls(mls, min_length=-inf)[source]#
Parameters:
  • mls

  • min_length -- (default: -inf)

infinigen.core.constraints.example_solver.room.solidifier.max_mls(mls)[source]#
Parameters:

mls

class infinigen.core.constraints.example_solver.room.solidifier.BlueprintSolidifier(consgraph, graph, level, enable_open=True)[source]#

Bases: object

Parameters:

graph (RoomGraph)

static unroll(x)[source]#
Parameters:

x

solidify(state)[source]#
Parameters:

state

convert_solver_state(...)[source]#
Parameters:
  • rooms

  • segments

  • shared_edges

  • open_cutters

  • door_cutters

  • window_cutters

  • interior_cutters

  • entrance_cutters

make_room(state, name)[source]#
Parameters:
  • state

  • name

make_interior_cutters(...)[source]#
Parameters:
  • neighbours

  • shared_edges

  • segments

  • exterior

compute_dist2entrance(neighbours)[source]#
Parameters:

neighbours

make_exterior_cutters(exterior_edges, exterior)[source]#
Parameters:
  • exterior_edges

  • exterior

make_staircase_cutters(staircase, names)[source]#
Parameters:
  • staircase

  • names

make_door_cutter(mls, direction)[source]#
Parameters:
  • mls

  • direction

make_entrance_cutter(mls)[source]#
Parameters:

mls

make_window_cutter(mls, is_panoramic)[source]#
Parameters:
  • mls

  • is_panoramic

make_open_cutter(es, exterior=None)[source]#
Parameters:
  • es

  • exterior -- (default: None)

tag(obj, visible=True)[source]#
Parameters:
  • obj

  • visible -- (default: True)

solver#

class infinigen.core.constraints.example_solver.room.solver.FloorPlanMoves(constants)[source]#

Bases: object

Parameters:

constants (RoomConstants)

perturb_state(state)[source]#
Parameters:

state (State)

extrude_room(state, k, out=True)[source]#
Parameters:
  • state

  • k

  • out -- (default: True)

extrude_room_out(state, k)[source]#
Parameters:
  • state

  • k

extrude_room_in(state, k)[source]#
Parameters:
  • state

  • k

swap_room(state, k)[source]#
Parameters:
  • state

  • k

move_staircase(state)[source]#
Parameters:

state

static plot(state)[source]#
Parameters:

state

utils#

infinigen.core.constraints.example_solver.room.utils.update_shared(state, i)[source]#
Parameters:
infinigen.core.constraints.example_solver.room.utils.update_contour(state_, state, indices)[source]#
Parameters:
infinigen.core.constraints.example_solver.room.utils.update_exterior(state, i)[source]#
Parameters:
infinigen.core.constraints.example_solver.room.utils.mls_ccw(mls, state, i)[source]#
Parameters:
  • mls (MultiLineString)

  • state (State)

  • i (str)

infinigen.core.constraints.example_solver.room.utils.update_staircase(state, i)[source]#
Parameters:
infinigen.core.constraints.example_solver.room.utils.shared(s, t)[source]#
Parameters:
  • s

  • t

Module contents#

annealing#

class infinigen.core.constraints.example_solver.annealing.SimulatedAnnealingSolver(
max_invalid_candidates,
initial_temp,
final_temp,
finetune_pct,
checkpoint_best=False,
output_folder=None,
visualize=False,
print_report_freq=1,
print_breakdown_freq=0,
)[source]#

Bases: object

save_stats(path)[source]#
Parameters:

path

reset(max_iters)[source]#
Parameters:

max_iters

checkpoint(state)[source]#
Parameters:

state

validate_lazy_eval(...)[source]#
Parameters:
retry_attempt_proposals(
...,
) Tuple[Move, EvalResult, int][source]#
Parameters:
curr_temp() float[source]#
metrop_hastings_with_viol(prop_result, temp)[source]#
Parameters:
step(...)[source]#
Parameters:
  • consgraph

  • state

  • move_gen_func

  • filter_domain

populate#

infinigen.core.constraints.example_solver.populate.apply_cutter(state, objkey, cutter)[source]#
Parameters:
  • state

  • objkey

  • cutter

infinigen.core.constraints.example_solver.populate.populate_state_placeholders(state, filter=None, final=True)[source]#
Parameters:
  • state (State)

  • filter -- (default: None)

  • final -- (default: True)

propose_continous#

infinigen.core.constraints.example_solver.propose_continous.get_pose_candidates(...)[source]#
Parameters:
  • consgraph (Node)

  • state (State)

  • filter_domain (Domain)

  • require_rot_free (bool) -- (default: False)

infinigen.core.constraints.example_solver.propose_continous.propose_translate(
...,
) Iterator[TranslateMove][source]#
Parameters:
infinigen.core.constraints.example_solver.propose_continous.propose_rotate(
...,
) Iterator[RotateMove][source]#
Parameters:
infinigen.core.constraints.example_solver.propose_continous.propose_reinit_pose(
...,
) Iterator[ReinitPoseMove][source]#
Parameters:
infinigen.core.constraints.example_solver.propose_continous.propose_scale(consgraph, state, temperature)[source]#
Parameters:
  • consgraph

  • state

  • temperature

propose_discrete#

class infinigen.core.constraints.example_solver.propose_discrete.DummyCubeGenerator(seed)[source]#

Bases: AssetFactory

create_asset(*_, **__)[source]#
infinigen.core.constraints.example_solver.propose_discrete.lookup_generator(preds)[source]#
Parameters:

preds (set[Semantics])

infinigen.core.constraints.example_solver.propose_discrete.propose_addition_bound_gen(...)[source]#

Try to propose any addition move involving the specified bound and generator

Parameters:
infinigen.core.constraints.example_solver.propose_discrete.active_for_stage(prop_dom, filter_dom)[source]#
Parameters:
infinigen.core.constraints.example_solver.propose_discrete.preproc_bounds(...)[source]#
Parameters:
  • bounds (list[Bound])

  • state (State)

  • filter (Domain)

  • reverse -- (default: False)

  • shuffle -- (default: True)

  • print_bounds -- (default: False)

infinigen.core.constraints.example_solver.propose_discrete.propose_addition(...)[source]#
Parameters:
infinigen.core.constraints.example_solver.propose_discrete.propose_deletion(...)[source]#
Parameters:
infinigen.core.constraints.example_solver.propose_discrete.propose_relation_plane_change(...)[source]#
Parameters:
infinigen.core.constraints.example_solver.propose_discrete.propose_resample(...)[source]#
Parameters:
infinigen.core.constraints.example_solver.propose_discrete.is_swap_domains_unaffected(state, name1, name2)[source]#
Parameters:
infinigen.core.constraints.example_solver.propose_discrete.propose_swap(...)[source]#
Parameters:

propose_relations#

infinigen.core.constraints.example_solver.propose_relations.minimize_redundant_relations(relations)[source]#

Given a list of relations that must be true, use the first as a constraint to tighten the remaining relations

Parameters:

relations (list[tuple[Relation, Domain]])

infinigen.core.constraints.example_solver.propose_relations.find_assignments(
curr,
relations,
assignments=None,
) Iterator[list[RelationState]][source]#

Iterate over possible assignments that satisfy the given relations. Some assignments may not be feasible geometrically - a naive implementation of this function would just enumerate all possible objects matching the assignments, and let the solver discover that many combinations are impossible. This implementation attemps to never generate guaranteed-invalid combinations in the first place.

Complexity is pretty astronomical: - N^M where N is number of candidates per relation, and M is number of relations - reduced somewhat when relations intersect or imply eachother - luckily, M is typically 1, 2 or 3, as objects arent often related to lots of other objects

TODO: - discover new relations constraints, which can arise from the particular choice of objects - prune early when object choice causes bounds to be violated

This function essentially does a complex form of SAT-solving. It really shouldnt be written in python

Parameters:

solve#

infinigen.core.constraints.example_solver.solve.map_range(...)[source]#
Parameters:
  • x

  • xmin

  • xmax

  • ymin

  • ymax

  • exp -- (default: 1)

class infinigen.core.constraints.example_solver.solve.LinearDecaySchedule(start, end, pct_duration)[source]#

Bases: object

class infinigen.core.constraints.example_solver.solve.Solver(output_folder, floor_plan='')[source]#

Bases: object

Parameters:

output_folder (Path)

choose_move_type(moves, it, max_it)[source]#
Parameters:
solve_rooms(scene_seed, consgraph, filter)[source]#
Parameters:
solve_objects(...)[source]#
Parameters:
  • consgraph (Problem)

  • filter_domain (Domain)

  • var_assignments (dict[str, str])

  • n_steps (int)

  • desc (str)

  • abort_unsatisfied (bool) -- (default: False)

  • print_bounds (bool) -- (default: False)

  • restrict_moves (list[str]) -- (default: None)

  • addition_weight_scalar (float) -- (default: 1.0)

get_bpy_objects(domain) list[bpy_types.Object][source]#
Parameters:

domain (Domain)

state_def#

class infinigen.core.constraints.example_solver.state_def.RelationState(
relation: 'cl.Relation',
target_name: 'str',
child_plane_idx: 'int' = None,
parent_plane_idx: 'int' = None,
value: 'typing.Optional[shapely.MultiLineString]' = None,
)[source]#

Bases: object

Parameters:
  • relation (Relation)

  • target_name (str)

  • child_plane_idx (int)

  • parent_plane_idx (int)

  • value (MultiLineString | None)

child_plane_idx: int = None#
parent_plane_idx: int = None#
value: MultiLineString | None = None#
class infinigen.core.constraints.example_solver.state_def.ObjectState(
obj: 'bpy.types.Object' = None,
polygon: 'shapely.Polygon' = None,
generator: 'typing.Optional[AssetFactory]' = None,
tags: 'set' = <factory>,
relations: 'list[RelationState]' = <factory>,
dof_matrix_translation: 'np.array' = None,
dof_rotation_axis: 'np.array' = None,
active: 'bool' = True,
)[source]#

Bases: object

Parameters:
obj: Object = None#
polygon: Polygon = None#
generator: AssetFactory | None = None#
dof_matrix_translation: array = None#
dof_rotation_axis: array = None#
fcl_obj = None#
col_obj = None#
active: bool = True#
class infinigen.core.constraints.example_solver.state_def.State(
objs: 'OrderedDict[str,
ObjectState]'=<factory>,
trimesh_scene: 'trimesh.Scene' = None,
graphs: 'list[RoomGraph]' = <factory>,
bvh_cache: 'dict' = <factory>,
planes: 'Planes' = None,
)[source]#

Bases: object

Parameters:
trimesh_scene: Scene = None#
planes: Planes = None#
print()[source]#
to_json(path)[source]#
Parameters:

path (Path)

save(filename)[source]#
Parameters:

filename (str)

classmethod load(filename)[source]#
Parameters:

filename (str)

infinigen.core.constraints.example_solver.state_def.state_from_dummy_scene(col) State[source]#
Parameters:

col (pf.Collection)

Module contents#

Reasoning (.core.constraints.reasoning)#

constraint_bounding#

class infinigen.core.constraints.reasoning.constraint_bounding.Bound(
domain: Domain = None,
low: int = None,
high: int = None,
)[source]#

Bases: object

Parameters:
domain: Domain = None#
low: int = None#
high: int = None#
classmethod from_comparison(opfunc, lhs, rhs)[source]#
Parameters:
  • opfunc

  • lhs

  • rhs

map(func, lhs=None, rhs=None)[source]#
Parameters:
  • func

  • lhs -- (default: None)

  • rhs -- (default: None)

infinigen.core.constraints.reasoning.constraint_bounding.evaluate_known_vars(
node,
known_vars,
) constant[source]#
Parameters:
  • node (Node)

  • known_vars

infinigen.core.constraints.reasoning.constraint_bounding.expression_map_bound(
node,
bound,
) list[Bound][source]#
Parameters:
infinigen.core.constraints.reasoning.constraint_bounding.update_var(var, scene_state)[source]#
Parameters:
  • var

  • scene_state

infinigen.core.constraints.reasoning.constraint_bounding.constraint_bounds(
node,
state=None,
) list[Bound][source]#
Parameters:
  • node (Node)

  • state -- (default: None)

constraint_constancy#

infinigen.core.constraints.reasoning.constraint_constancy.is_constant(node)[source]#
Parameters:

node (Node)

constraint_domain#

infinigen.core.constraints.reasoning.constraint_domain.constraint_domain(node, finalize_variables=False) Domain[source]#

Given an expression, find a compact representation of what types of objects it is applying to.

User can compared the resulting Domain against their State and see what objects fit.

Parameters:
class infinigen.core.constraints.reasoning.constraint_domain.FilterByDomain(objs, filter)[source]#

Bases: ObjectSetExpression

Constraint node which says to return all objects matching a domain.

Used as a compacted representation of the filtering performed many cl.tagged and cl.related_to calls. One r.Domain is sufficient to represent the effect of and combination of intersection-style filtering.

Introduced (currently) only by greedy.filter_constraints, since that function needs to work with domains in order to narrow the scope of some constraints.

Parameters:

domain#

infinigen.core.constraints.reasoning.domain.reldom_implies(a, b)[source]#

If relation a is satisfied, is relation guaranteed to be satisfied?

Parameters:
infinigen.core.constraints.reasoning.domain.reldom_compatible(a, b)[source]#

If relation a is satisfied, can relation b be satisfied?

Parameters:
infinigen.core.constraints.reasoning.domain.reldom_satisfies(a, b)[source]#
Parameters:
infinigen.core.constraints.reasoning.domain.reldom_intersects(a, b, **kwargs)[source]#
Parameters:
infinigen.core.constraints.reasoning.domain.reldom_intersection(a, b)[source]#
Parameters:
infinigen.core.constraints.reasoning.domain.domain_finalized(dom, check_anyrel=False, check_variable=True)[source]#
Parameters:
  • dom (Domain)

  • check_anyrel -- (default: False)

  • check_variable -- (default: True)

class infinigen.core.constraints.reasoning.domain.Domain(tags=<factory>, relations=<factory>)[source]#

Bases: object

Describes a class of object in the scene

Objects are in the domain if: - Some part of the object is tagged with each of ‘tags’ - It is related to an object matching each Domain in relations

WARNING: Recurive datastructure, here be dragons

Note: Default-constructed Domain contains Everything

Parameters:
repr(abbrv=False, onelevel=False, oneline=False)[source]#
Parameters:
  • abbrv -- (default: False)

  • onelevel -- (default: False)

  • oneline -- (default: False)

implies(other)[source]#
Parameters:

other (Domain)

add_relation(new_rel, new_dom, optimize_check_implies=True)[source]#

new_rel, new_dom: the relation and domain to be added

optimize_check_implies: if enabled, dont add relations (aka predicates) that are already provably true based on existing predicates. This should not be necessary for correctness: object addition should check if relation constraints are satisfied/implied before adding more. But it may (?) help speed, and the unit tests assume it is enabled for the most part

Parameters:
  • new_rel (Relation)

  • new_dom (Domain)

  • optimize_check_implies -- (default: True)

with_relation(rel, dom)[source]#
Parameters:
with_tags(tags)[source]#
Parameters:

tags (set[Semantics])

satisfies(other)[source]#

Assumes that ‘self’ is fully specified: any predicates that arent listed are false.

Different from ‘implies’ in that if other contains negative predicates, self need not imply these, it just needs to not contradict them.

Different from ‘intersects’ in that

Parameters:

other (Domain)

intersects(other, require_satisfies_left=False, require_satisfies_right=False)[source]#

Return True if self and other could have a non-empty intersection.

Parameters:
  • self (Domain - the domain to check)

  • other (Domain - the domain to check against)

  • require_satisfies_left (bool -) -- If True, assume that self is exhaustively specified (ie, any predicates not listed are false), and therefore other must imply self for the intersection to be non-empty.

  • require_satisfies_right (bool -) -- If True, assume that other is exhaustively specified (ie, any predicates not listed are false), and therefore self must imply other for the intersection to be non-empty.

intersection(other)[source]#

Return a domain representing the intersection of self and other. Result is at least as strict as self and other.

contains(self, x) and contains(other, x) -> contains(intersection, x)

TODO:

- does order relations are checked for intersection matter?
- almost certainly yes, intersection is not transitive.
- so what order is best? fewest remaining relations? does it matter?
Parameters:

other (Domain)

is_recursive(seen=None)[source]#

Check if this domain somehow references itself via its own relations. Domains should ideally never reach this state; this function is used to check that they dont.

Parameters:

seen -- (default: None)

positive_part()[source]#
traverse()[source]#
all_vartags() set[t.Variable][source]#
get_objs_named()[source]#

domain_substitute#

infinigen.core.constraints.reasoning.domain_substitute.domain_tag_substitute(...) Domain[source]#

Return concrete substitution of domain, where subst_domain must be satisfied whenever subst_tag was present in the original.

Parameters:
infinigen.core.constraints.reasoning.domain_substitute.substitute_all(dom, assignments) Domain[source]#
Parameters:

expr_equal#

class infinigen.core.constraints.reasoning.expr_equal.FalseEqualityResult(
n1: Node,
n2: Node,
reason: str,
)[source]#

Bases: object

Parameters:
infinigen.core.constraints.reasoning.expr_equal.expr_equal(
n1,
n2,
name=None,
) bool | FalseEqualityResult[source]#

An equality comparison operator for constraint Node expressions

Using the default Node == Node is unsafe since Nodes override == in order to return another expression

Parameters:

Module contents#

checks#

infinigen.core.constraints.checks.iter_domains(node) Iterator[r.Domain][source]#
Parameters:

node (Node)

infinigen.core.constraints.checks.bound_coverage(b, stages) list[str][source]#
Parameters:
infinigen.core.constraints.checks.check_coverage_errors(b, coverage, stages)[source]#
Parameters:
infinigen.core.constraints.checks.check_problem_greedy_coverage(prob, stages)[source]#
Parameters:
infinigen.core.constraints.checks.check_unfinalized_constraints(prob)[source]#
Parameters:

prob (Problem)

infinigen.core.constraints.checks.check_contradictory_domains(prob)[source]#
Parameters:

prob (Problem)

infinigen.core.constraints.checks.validate_stages(stages)[source]#
Parameters:

stages (dict[str, Domain])

infinigen.core.constraints.checks.check_all(prob, greedy_stages, all_vars)[source]#
Parameters:

usage_lookup#

infinigen.core.constraints.usage_lookup.initialize_from_dict(d)[source]#
Parameters:

d

infinigen.core.constraints.usage_lookup.usages_of_factory(fac) set[Tag][source]#
Parameters:

fac

infinigen.core.constraints.usage_lookup.factories_for_usage(tags)[source]#
Parameters:

tags (set[Tag])

infinigen.core.constraints.usage_lookup.all_usage_tags()[source]#
infinigen.core.constraints.usage_lookup.all_factories()[source]#
infinigen.core.constraints.usage_lookup.has_usage(fac, tag)[source]#
Parameters:
  • fac

  • tag