Opened 6 years ago

Closed 4 years ago

#3559 closed enhancement (fixed)

Allow mixing models and optimzation problems in CasADiInterface transfer

Reported by: toivo Owned by: toivo
Priority: major Milestone: Pending
Component: CasADiInterface Version: trunk
Keywords: Cc:

Description

Currently, only two kinds of transfer are supported with CasADiInterface:

  • Transferring a model into a Model, from an .mo file
  • Transferring an optimization into an OptimizationProblem, from an .mop file

It can also be useful to be able to

  • Transfer a model that resides in an .mop file
  • Transfer a model into an OptimizationProblem, and then fill in the optimization information from a script

Attachments (2)

model.mop (38 bytes) - added by Fredrik Magnusson 5 years ago.
model_mop.py (285 bytes) - added by Fredrik Magnusson 5 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 6 years ago by toivo

CasADiInterface: Add ability to transfer a model from an .mo file into an OptimizationProblem, in r6117:

  • Add keyword argument accept_model to transfer_optimization_problem to indicate that a model is allowed
  • Better initialization of Model and OptimizationProblem objects at construction time, don't rely on the right transfer function to be called just after
    • Change default value of normalizedTime in OptimizationProblem to false
  • Refactor model transfer tests in test_casadiinterface_transfer.py to allow the tests to run twice; once with regular transfer and once with transfer into an OptimizationProblem
  • Update tests to match

comment:2 Changed 6 years ago by toivo

It is still not possible to transfer a model from a .mop file. The fix would involve quite a lot of the template machinery in the transfer functionality.

comment:3 Changed 6 years ago by toivo

Milestone: 1.14.xPending

It is not clear that this is a priority; moving to pending.

comment:4 Changed 5 years ago by toivo

Remove two debug printouts that were mistakenly included in r6117, for in r6866.

comment:5 in reply to:  2 Changed 5 years ago by Fredrik Magnusson

Replying to toivo:

It is still not possible to transfer a model from a .mop file. The fix would involve quite a lot of the template machinery in the transfer functionality.

This was supposed to be fixed in https://trac.jmodelica.org/ticket/3949#comment:21. However, it does not seem to handle all cases. Specifically, it seems to fail if the .mop file contains both models and optimizations, see attachments.

Changed 5 years ago by Fredrik Magnusson

Attachment: model.mop added

Changed 5 years ago by Fredrik Magnusson

Attachment: model_mop.py added

comment:6 Changed 5 years ago by toivo

Make it possible to use transfer_model to import a model from a .mop file, in r7450.

  • Make transfer_model detect if it is given any .mop files and invoke transferModelFromOptimicaCompiler in that case
  • Make transferModelFromOptimicaCompiler work on a Model and not an OptimizationProblem

Should hopefully be the last part needed for this ticket?

comment:7 Changed 4 years ago by toivo

Resolution: fixed
Status: newclosed

This seems to be working; reopen otherwise.

Note: See TracTickets for help on using tickets.