stanfordnqp/spins-b

Composite Parametrization

Closed this issue · 2 comments

I am struggling to get a composite parametrization to work:
Unfortunately there is not much documentation on it, so what I tried so far was to create two dummy simspaces (actually you would only need the design space as far as I can tell, but I found no way of feeding that in directly) for the generation of the selection matices. Then I do the following:

cont_param_si = optplan.PixelParametrization(
    simulation_space=sim_spaces[1], 
    init_method=optplan.UniformInitializer(min_val=0, max_val=1))
cont_param_sin = optplan.PixelParametrization(
    simulation_space=sim_spaces[2], 
    init_method=optplan.UniformInitializer(min_val=0, max_val=1))

to create two paramtrizations and

cont_param_comp = optplan.CompositeParametrization(param_list=[cont_param_si, cont_param_sin])

which does not throw an error at first, but when I add it to the transformation list and execute the optplan I run into the following problem:

[2021-02-23 11:02:36,224][INFO][solver][run_plan] Setting up workspace.
[2021-02-23 11:02:36,226][INFO][solver][run_plan] Running transformation opt_cont.
<path-to-spins>/spins-env/lib/python3.6/site-packages/scipy/sparse/data.py:72: ComplexWarning: Casting complex values to real discards the imaginary part
  self._deduped_data().astype(dtype, casting=casting, copy=copy),
Traceback (most recent call last):
  File "spins-b/examples/invdes/grating_coupler_bilayer/grating.py", line 747, in <module>
    run_opt(args.save_folder+"({})".format(i), grating_len=grating_len, wg_width=wg_width, wlength=cfg[0], angle_theta=cfg[1])
  File "spins-b/examples/invdes/grating_coupler_bilayer/grating.py", line 88, in run_opt
    problem_graph.run_plan(plan, ".", save_folder=save_folder)
  File "<path-to-spins>/spins-env/lib/python3.6/site-packages/spins/invdes/problem_graph/solver.py", line 61, in run_plan
    work.run(transformation_param, event_data)
  File "<path-to-spins>/spins-env/lib/python3.6/site-packages/spins/invdes/problem_graph/workspace.py", line 134, in run
    transform(self.get_object(node.parametrization), event_data)
  File "<path-to-spins>/spins-env/lib/python3.6/site-packages/spins/invdes/problem_graph/workspace.py", line 198, in get_object
    self._objects[node.name] = creator(node, self)
  File "<path-to-spins>/spins-env/lib/python3.6/site-packages/spins/invdes/problem_graph/optplan/__init__.py", line 56, in not_implemented
    "Node type has no creator implemented: {}".format(node_type))
NotImplementedError: Node type has no creator implemented: parametrization.composite

Can you be more specific about what you are looking to do? Are you looking to do inverse design on two separate layers? We've done that before and I can track down some notes to share with you if it's relevant.

That was exactly what I was trying to do, I actually got it to work using goos. So that is basically solved. Would be interesting, to also see it in invdes, but I think I will permanently migrate to goos. I will close the issue. Should you want to add something feel free to reopen it :)