Jonas-Nicodemus / PINNs-based-MPC

We discuss nonlinear model predictive control (NMPC) for multi-body dynamics via physics-informed machine learning methods. Physics-informed neural networks (PINNs) are a promising tool to approximate (partial) differential equations. PINNs are not suited for control tasks in their original form since they are not designed to handle variable control actions or variable initial values. We thus present the idea of enhancing PINNs by adding control actions and initial conditions as additional network inputs. The high-dimensional input space is subsequently reduced via a sampling strategy and a zero-hold assumption. This strategy enables the controller design based on a PINN as an approximation of the underlying system dynamics. The additional benefit is that the sensitivities are easily computed via automatic differentiation, thus leading to efficient gradient-based algorithms. Finally, we present our results using our PINN-based MPC to solve a tracking problem for a complex mechanical system, a multi-link manipulator.
MIT License
82 stars 22 forks source link

Problems running the code #1

Open moowees opened 1 year ago

moowees commented 1 year ago

Hi, i have problems running the code. Seems to be soething with tensorflow. Have you had this issue?

2023-11-03 10:42:15.612564: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE SSE2 SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
INFO:root:TensorFlow version: 2.14.0
INFO:root:Eager execution: True
INFO:root:MPC parameters:
INFO:root:  H:  5
INFO:root:  tau:    0.2
Traceback (most recent call last):
  File "E:\PINNs-based-MPC-1.0.0\src\main.py", line 56, in <module>
    pinn.load_weights(weights_path)
  File "E:\PINNs-based-MPC-1.0.0\src\model\nn.py", line 265, in load_weights
    self.model.load_weights(tf.train.latest_checkpoint(path))
  File "E:\PINNs-based-MPC-1.0.0\venv\lib\site-packages\tensorflow\python\keras\engine\training.py", line 2317, in load_weights
    status = self._checkpoint.read(filepath, options)
  File "E:\PINNs-based-MPC-1.0.0\venv\lib\site-packages\tensorflow\python\checkpoint\checkpoint.py", line 2540, in read
    result = self._saver.restore(save_path=save_path, options=options)
  File "E:\PINNs-based-MPC-1.0.0\venv\lib\site-packages\tensorflow\python\checkpoint\checkpoint.py", line 1461, in restore
    restore_lib.CheckpointPosition(
  File "E:\PINNs-based-MPC-1.0.0\venv\lib\site-packages\tensorflow\python\checkpoint\restore.py", line 62, in restore
    restore_ops = self._restore_descendants(reader)
  File "E:\PINNs-based-MPC-1.0.0\venv\lib\site-packages\tensorflow\python\checkpoint\restore.py", line 459, in _restore_descendants
    _queue_children_for_restoration(current_position, visit_queue)
  File "E:\PINNs-based-MPC-1.0.0\venv\lib\site-packages\tensorflow\python\checkpoint\restore.py", line 606, in _queue_children_for_restoration
    local_object = trackable._lookup_dependency(child.local_name,
TypeError: _lookup_dependency() takes 2 positional arguments but 3 were given
WARNING:tensorflow:Detecting that an object or model or tf.train.Checkpoint is being deleted with unrestored values. See the following logs for the specific values in question. To silence these warnings, use `status.expect_partial()`. See https://www.tensorflow.org/api_docs/python/tf/train/Checkpoint#restorefor details about the status object returned by the restore function.
WARNING:tensorflow:Detecting that an object or model or tf.train.Checkpoint is being deleted with unrestored values. See the following logs for the specific values in question. To silence these warnings, use `status.expect_partial()`. See https://www.tensorflow.org/api_docs/python/tf/train/Checkpoint#restorefor details about the status object returned by the restore function.
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-0.kernel
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-0.kernel
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-0.bias
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-0.bias
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-1.kernel
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-1.kernel
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-1.bias
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-1.bias
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-2.kernel
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-2.kernel
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-2.bias
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-2.bias
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-3.kernel
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-3.kernel
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-3.bias
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-3.bias
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-4.kernel
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-4.kernel
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-4.bias
WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).layer_with_weights-4.bias

Best Regards

Jonas-Nicodemus commented 1 year ago

Hi, I updated the requirements.txt to fixed versions. Can you try to run it again with those versions? And I think you should use python 3.9 if possible.