rkruegs123 / geo-model-builder

Apache License 2.0
18 stars 7 forks source link

error when there's multiple polygons #3

Open shenglih opened 7 months ago

shenglih commented 7 months ago

Hi thanks for the very useful tool and general language!

I was trying for examples like the following that includes multiple polygons.

['( param ( A B C D ) polygon )', '( assert ( cong A B B C ) )', '( assert ( cong B
 C C D ) )', '( assert ( cong C D D A ) )', '( assert ( cong A C B D ) )', '( asser
t ( perp ( line A B ) ( line B C ) ) )', '( assert ( perp ( line A D ) ( line D C )
 ) )', '( assert ( perp ( line A C ) ( line B D ) ) )', '( assert ( para ( line A D
 ) ( line B C ) ) )', '( assert ( para ( line A B ) ( line C D ) ) )', '( param ( E
 F G H ) polygon )', '( assert ( cong H F E G ) )']   

And I got errors assuming the polygons are the same when they are in fact not:

INPUT INSTRUCTIONS:                                                                
sample (A B C D) polygon ()                                                        
assert (cong A B B C)                                                              
assert (cong B C C D)                                                              
assert (cong C D D A)                                                              
assert (cong A C B D)                                                              
assert (perp (connecting A B) (connecting B C))                                    
assert (perp (connecting A D) (connecting D C))                                    
assert (perp (connecting A C) (connecting B D))                                    
assert (para (connecting A D) (connecting B C))                                    
assert (para (connecting A B) (connecting C D))                                    
sample (E F G H) polygon ()                                                        
assert (cong H F E G)                                                              
Processing instructions...:  83%|███████████████   | 10/12 [00:00<00:00, 26.06it/s]

the most relevant traceback:

tf_prefix=outp, encode_fig=encode_fig, plot_path=az_path2img)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/shengli/code/shengli/geo-model-builder/src/gbml_verifier.py", line 7
9, in build_aux
    solver.preprocess()
  File "/Users/shengli/code/shengli/geo-model-builder/src/optimizer.py", line 72, i
n preprocess
    self.process_instruction(i)
  File "/Users/shengli/code/shengli/geo-model-builder/src/optimizer.py", line 83, i
n process_instruction
    self.sample(i)
  File "/Users/shengli/code/shengli/geo-model-builder/src/optimizer.py", line 373, 
in sample
    elif s_method == "polygon": self.sample_polygon(i.points)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/shengli/code/shengli/geo-model-builder/src/optimizer.py", line 390, 
in sample_polygon
    angle_zs = [self.mkvar(name=f"polygon_angle_zs_{i}", lo=-2.0, hi=2.0) for i in 
range(len(ps))]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^
  File "/Users/shengli/code/shengli/geo-model-builder/src/optimizer.py", line 390, 
in <listcomp>
    angle_zs = [self.mkvar(name=f"polygon_angle_zs_{i}", lo=-2.0, hi=2.0) for i in 
range(len(ps))]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/shengli/code/shengli/geo-model-builder/src/tf_optimizer.py", line 48
, in mkvar
    return tf.compat.v1.get_variable(name=name, shape=shape, dtype=tf.float64, init
ializer=init, trainable=trainable)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/shengli/.pyenv/versions/3.11.5/lib/python3.11/site-packages/tensorfl
ow/python/ops/variable_scope.py", line 1617, in get_variable
    return get_variable_scope().get_variable(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/shengli/.pyenv/versions/3.11.5/lib/python3.11/site-packages/tensorfl
ow/python/ops/variable_scope.py", line 1327, in get_variable
    return var_store.get_variable(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/shengli/.pyenv/versions/3.11.5/lib/python3.11/site-packages/tensorfl
ow/python/ops/variable_scope.py", line 583, in get_variable
    return _true_getter(
           ^^^^^^^^^^^^^
  File "/Users/shengli/.pyenv/versions/3.11.5/lib/python3.11/site-packages/tensorfl
ow/python/ops/variable_scope.py", line 536, in _true_getter
    return self._get_single_variable(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/shengli/.pyenv/versions/3.11.5/lib/python3.11/site-packages/tensorfl
ow/python/ops/variable_scope.py", line 899, in _get_single_variable
    raise ValueError("%s Originally defined at:\n\n%s" %
ValueError: Variable polygon_angle_zs_0 already exists, disallowed. Did you mean to
 set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at:

  File "/Users/shengli/code/shengli/geo-model-builder/src/tf_optimizer.py", line 48
, in mkvar
    return tf.compat.v1.get_variable(name=name, shape=shape, dtype=tf.float64, init
ializer=init, trainable=trainable)
  File "/Users/shengli/code/shengli/geo-model-builder/src/optimizer.py", line 390, 
in <listcomp>
    angle_zs = [self.mkvar(name=f"polygon_angle_zs_{i}", lo=-2.0, hi=2.0) for i in 
range(len(ps))]
  File "/Users/shengli/code/shengli/geo-model-builder/src/optimizer.py", line 390, 
in sample_polygon
    angle_zs = [self.mkvar(name=f"polygon_angle_zs_{i}", lo=-2.0, hi=2.0) for i in 
range(len(ps))]
  File "/Users/shengli/code/shengli/geo-model-builder/src/optimizer.py", line 373, 
in sample
    elif s_method == "polygon": self.sample_polygon(i.points)
  File "/Users/shengli/code/shengli/geo-model-builder/src/optimizer.py", line 83, i
n process_instruction
    self.sample(i)

does anyone know how to resolve this issue? thanks a bunch!