Skip to content

Commit ab7e111

Browse files
committed
Add initial guess upon defining optimization.
1 parent 3379947 commit ab7e111

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

wedoco_optimo/model.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def initialize_optimization(self, ipopt_options: dict=None, prescribed_inputs: d
144144

145145
def define_optimization(self,
146146
x0: np.array=None,
147+
initial_guess: dict=None,
147148
constraints: dict=None,
148149
objective_terms: list=None,
149150
ipopt_options: dict=None,
@@ -164,6 +165,11 @@ def define_optimization(self,
164165
for x_name in self.dae.x():
165166
self.ocp.set_initial(self.dae.var(x_name), x0[x_name])
166167

168+
# Set the initial guess for other provided variables
169+
if initial_guess is not None:
170+
for v_name in initial_guess:
171+
self.ocp.set_initial(self.dae.var(v_name), initial_guess[v_name])
172+
167173
# Set initial time
168174
t0 = 0
169175
self.ocp.set_t0(0)

0 commit comments

Comments
 (0)