You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to define a cost on a function that depends on the optimization variables (input and state) at each node. To do that I'm using getVarOffset(). I'm doing different tests to understand how this method works and I'm encountering issues abut the nodes where the offset variable is defined.
For example, if i do q.getVarOffset(-k) with k=n_nodes, the only node where the variable is defined is the last one and hence on this variable i can set a final cost prb.createFinalCost('q_final', q.getVarOffset(-k)). However the following error in the function setNodes() comes out :
Exception has occurred: IndexError
index 20 is out of bounds for axis 1 with size 1
because the nodes_mask is a vector of only one element and when i do nodes_mask[:, nodes] = 1 the only admissible index is nodes=0 but here is nodes=n_nodes.
Since q.getVarOffset(-n_nodes) is supposed to be the variable at the first node it makes sense for me that the only admissible node is the first one but when I try to set the cost, the only admissible node is the last one. But anyway I cannot set the cost because the only nodes that i can set is the first one,
Here a simple example of the code:
n_nodes = 20
q_n = q.getVarOffset( - 20 )
prb.createFinalCost('test_cost_qn', - q_n)
Therefore I'm wandering if you have a solution
thank you for your help
The text was updated successfully, but these errors were encountered:
dear all,
I'm trying to define a cost on a function that depends on the optimization variables (input and state) at each node. To do that I'm using getVarOffset(). I'm doing different tests to understand how this method works and I'm encountering issues abut the nodes where the offset variable is defined.
For example, if i do q.getVarOffset(-k) with k=n_nodes, the only node where the variable is defined is the last one and hence on this variable i can set a final cost prb.createFinalCost('q_final', q.getVarOffset(-k)). However the following error in the function setNodes() comes out :
Exception has occurred: IndexError
index 20 is out of bounds for axis 1 with size 1
because the nodes_mask is a vector of only one element and when i do nodes_mask[:, nodes] = 1 the only admissible index is nodes=0 but here is nodes=n_nodes.
Since q.getVarOffset(-n_nodes) is supposed to be the variable at the first node it makes sense for me that the only admissible node is the first one but when I try to set the cost, the only admissible node is the last one. But anyway I cannot set the cost because the only nodes that i can set is the first one,
Here a simple example of the code:
n_nodes = 20
q_n = q.getVarOffset( - 20 )
prb.createFinalCost('test_cost_qn', - q_n)
Therefore I'm wandering if you have a solution
thank you for your help
The text was updated successfully, but these errors were encountered: